Giter VIP home page Giter VIP logo

fullstack-rust's Introduction

Rust Full Stack Example

Highly WIP

This repository is a proof of concept and a proposal for full stack applications using Rust. It's organized in three basic crates.

This example is mainly REST oriented, but opinions on using other API designs are very welcome (in specially interested to try GraphQL using Juniper).

Basic Architecture

Schema

The schema library contains the shared contract between server and client applications. You may use it to declare (de)serializable models and types using Serde, as well as traits for each resource.

Client (Frontend)

For the client appication, we are using a Webassembly application with javascript iteroperability. This example depends on the latest versions of Cargo web build tool, and the component based Yew framework.

Notice that we are using native Rust to webassembly compilation (target wasm-unknown-unknown), but one can also use Emscripten to compile this example to asm.js, and thus not requiring the latest versions of Firefox or Chrome.

The frontend application is basically composed of an API Service implementing the schema negotiation and a Component for managing the local state and events.

Server (Backend)

Finally, the server application is resposible for serving the static frontend application and serving the API for the given example. It's implemented using Rocket and a Redis list for simplicity.

On the server, you may find view-controllers and repositories for the schema resources. Notice that on this example we are not splitting them as we only implement a really simple CRUD API.

cargo run

Running

First, make sure you have the latest Rust Nightly version, Cargo and Cargo-web.

Run a redis instance for storing the data. If you have docker installed, do:

docker run --name redis p 6379:6379 -d redis

Next, you may build the frontend application using cargo-web and putting the resulting files on the static server dir.

cd client
cargo-web deploy
cp target/deploy/* ../server/static/

Finally, run the server application

cd server
cargo run

You may try it on locahlost:8000. Enjoy.

fullstack-rust's People

Contributors

gabisurita avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.