Based on Zero To Production In Rust, which is an opinionated introduction to backend development using Rust. Highly recommended.
You'll need to install:
There are also some OS-specific requirements.
cargo install -f cargo-binutils
rustup component add llvm-tools-preview
cargo install --version="~0.8" sqlx-cli --no-default-features --features rustls,postgres
# Ubuntu
sudo apt-get install lld clang libssl-dev postgresql-client
# Arch
sudo pacman -S lld clang postgresql
cargo install --version="~0.8" sqlx-cli --no-default-features --features rustls,postgres
brew install michaeleisel/zld/zld
cargo install --version="~0.8" sqlx-cli --no-default-features --features rustls,postgres
Launch a (migrated) Postgres database via Docker:
./scripts/init_db.sh
Launch a Redis instance via Docker:
./scripts/init_redis.sh
Launch cargo
:
cargo build
You can now try with opening a browser on http://127.0.0.1:8000/login after
having launch the web server with cargo run
.
There is a default admin
account with password
everythinghastostartsomewhere
. The available entrypoints are listed in
src/startup.rs
Launch a (migrated) Postgres database via Docker:
./scripts/init_db.sh
Launch a Redis instance via Docker:
./scripts/init_redis.sh
Launch cargo
:
cargo test
graph TD
A[User Interface] -->|Submits Code| B[API Layer]
B -->|Enqueues Task| D[Task Queue: RabbitMQ/Kafka]
D -->|Distributes Tasks| E[Worker Nodes]
E -->|Requests Compilation and Execution| C1[Code Runner]
subgraph Docker Container
C1[Code Runner]
C2[Family of Compilers]
end
C1 -->|Returns Output| E
C1 -->|Uses| C2
E -->|Sends Result via WebSocket| B
B -->|WebSocket Connection| A
subgraph Cache Layer
H[Redis] -->|Cached Response| B
end
C1 -->|Task Results| H
architecture-beta
group api(cloud)[API]
group docker(cloud)[Docker container] in api
service redis(database)[Redis Cache] in api
service kafka(server)[Kafka or RabbitMQ] in api
service server(internet)[Server] in api
service code_runner(server)[Code Runner] in docker
service family_of_compilers(disk)[Family of Compilers] in docker
server:R -- L:redis
server:T -- B:kafka
kafka:R -- L:code_runner
code_runner:R -- L:family_of_compilers
code_runner:T -- B:redis