Skip to content

kendopunk/rust-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rust-react

Using Rust and React together.

After playing around with the Polars data frame library, I wanted to see if I could use it in a Rust web framework to pass DF information through to a React frontend.

With the help of Actix this is possible.

I expanded the application to include some Serde implementations of serializing / deserializing.

TL/DR

The repo has two parts - the backend Actix server (actix-backend) and the React application (frontend) taking advantage of some Material UI components.

Requirements

  • Rust installed
  • Understanding of cargo
  • npm (or nvm) installed
  • yarn installed

Setting Up and Running actix-backend

# Cargo Watch watches over your project's source for changes, and runs Cargo commands when they occur.
$> cargo install cargo-watch

The Polars examples read from a CSV file called organizations-100.csv located in actix-backend/static.

# run the server
$> cd actix-backend
# may take a while to resolve all dependencies + build
$> cargo-watch -x run
# server will be running on http://localhost:3001
# generate documentation if you want
$> cd actix-backend
$> cargo doc --no-deps

actix-backend: Docker

$> cd actix-backend
$> docker build -f Dockerfile.backend -t actix-backend .
$> docker run -d -p 8080:8080 actix-backend
$> curl -X GET "http://localhost:8080/health" \
 -H "Content-Type: application/json"

Setting Up and Running frontend

$> cd frontend

# if using nvm
$> nvm use

# install dependencies + start server
$> npm i
$> npm run start
# Will be running on http://localhost:3000

Troubleshooting

If you see this Polars error, try running rustup update

...physical_plan/executors/scan/csv.rs:21:18
   |
21 |             .map(Arc::unwrap_or_clone);
   |                  ^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #93610 <https://github.com/rust-lang/rust/issues/93610> for more information

@TODO / Future / Random Thoughts

  • Integrate a database like Postgres, using Diesel or similar
  • GCP BigQuery implementation
  • WebSockets examples
  • GraphQL

About

Rust actix-web backend and React frontend to manipulate data with Polars

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors