9 Rust Project Tutorials: From Web Servers to Operating Systems
The Project-Based Learning repository curates nine hands-on Rust tutorials that guide you through building production-grade projects including HTTP servers, bare-metal operating systems, browser engines, and NES emulators.
The practical-tutorials/project-based-learning repository aggregates community-driven tutorials for developers who learn by building. According to the Rust subsection in README.md (lines 6260–6465), you can construct nine distinct Rust projects that span async web frameworks, bare-metal kernels, and browser-based neural networks. Each tutorial provides complete architectural walkthroughs rather than isolated snippets, giving you production-relevant experience with crates like tokio, actix-web, yew, and bootloader.
1. Build a Simple Rust Web App with Actix or Rocket
Tutorial: Simple Web App – Part 1, Part 2a, Part 2b
This project teaches you to create a minimal HTTP server exposing CRUD endpoints (such as a notes API) with server-side HTML rendering. You will architect a layered application separating routing, business logic, persistence, and templating.
Key architectural layers:
| Layer | Responsibility | Typical Crate |
|---|---|---|
| Router / Request handling | Maps URLs to handler functions | actix-web or rocket |
| Business logic | Validates input, updates in-memory store | plain Rust modules |
| Persistence | Optional JSON file or SQLite via diesel |
serde + rusqlite |
| Templating | Server-side HTML rendering | tera or askama |
Code example (Actix-Web):
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
async fn hello() -> impl Responder {
HttpResponse::Ok().body("Hello from Rust!")
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| App::new().route("/", web::get().to(hello)))
.bind(("127.0.0.1", 8080))?
.run()
.await
}
2. Write an Operating System in Pure Rust
Tutorial: Write an OS in pure Rust
This Rust project guides you through building a bare-metal kernel that boots on x86_64, sets up paging, handles interrupts, and prints to VGA text mode. It requires extensive use of unsafe Rust and low-level hardware interaction.
Core components:
| Component | Role | Typical Crate / Feature |
|---|---|---|
| Bootloader | Transfers control to kernel | bootloader crate |
| Memory Management | Paging, frame allocation | custom unsafe code |
| Interrupts | IDT, PIC/APIC handling | x86_64 crate |
| Drivers | Keyboard, VGA | low-level I/O |
| Scheduler (optional) | Multitasking | spin + custom task structs |
Kernel entry point:
#![no_std]
#![no_main]
use core::panic::PanicInfo;
use bootloader::BootInfo;
#[no_mangle]
pub extern "C" fn _start(boot_info: &'static BootInfo) -> ! {
// Initialize hardware, set up paging, etc.
loop {}
}
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}
3. Create a Browser Engine in Rust
Tutorial: Build a browser engine in Rust
You will construct a tiny HTML parser, CSS selector engine, and layout engine that renders simple pages to a bitmap. This project demonstrates how to model complex recursive data structures (the DOM) in Rust and implement layout algorithms.
Architecture highlights:
- Parsing – use
html5everfor HTML,cssparserfor CSS. - DOM construction – tree of
Nodestructs. - Styling – compute computed style per node.
- Layout – box model, flex algorithm (simplified).
- Rasterization – draw rectangles onto a pixel buffer (
imagecrate).
HTML token processing:
use html5ever::tokenizer::{Tokenizer, Token, TokenSink};
struct SimpleSink;
impl TokenSink for SimpleSink {
type Handle = ();
fn process_token(&mut self, token: Token, _line: u64) -> html5ever::Result<()> {
println!("{:?}", token);
Ok(())
}
}
// In main()
let mut tokenizer = Tokenizer::new(SimpleSink, Default::default());
tokenizer.feed("<html><body>Hello</body></html>");
tokenizer.end();
4. Develop a REST Microservice in Rust
Tutorial: Write a Microservice in Rust
Build a JSON-based CRUD service (such as a todo list) exposing GET/POST/PUT/DELETE endpoints. This tutorial emphasizes async database access and container-ready deployment patterns.
Typical stack:
- Web framework –
warporaxum(async, tokio-based). - Database –
sqlx(async Postgres) orsled(embedded). - Serialization –
serde_json.
Axum + SQLite example:
use axum::{routing::post, Router, Json};
use serde::{Deserialize, Serialize};
use sqlx::SqlitePool;
#[derive(Deserialize, Serialize)]
struct Todo { id: i64, title: String }
async fn create_todo(
Json(payload): Json<Todo>,
sqlx::Extension(pool): sqlx::Extension<SqlitePool>,
) -> Json<Todo> {
let rec = sqlx::query_as::<_, Todo>("INSERT INTO todos (title) VALUES (?) RETURNING id, title")
.bind(&payload.title)
.fetch_one(&pool)
.await
.unwrap();
Json(rec)
}
#[tokio::main]
async fn main() {
let pool = SqlitePool::connect("sqlite:todos.db").await.unwrap();
let app = Router::new()
.route("/todos", post(create_todo))
.layer(sqlx::Extension(pool));
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
.serve(app.into_make_service())
.await
.unwrap();
}
5. Build a Scalable Chat Service with WebSockets
Tutorial: Writing Scalable Chat Service from Scratch – Part 1 & Part 2
This Rust project creates a server that upgrades HTTP connections to WebSocket, routes messages between clients, and persists chat history. It teaches concurrent connection management using tokio and shared state handling.
Core crates:
tokio-tungstenitefor async WebSocket.serdefor JSON payloads.dashmaporRwLock<HashMap>for shared client registry.
Connection handler:
use tokio::net::TcpListener;
use tokio_tungstenite::accept_async;
use futures_util::{StreamExt, SinkExt};
#[tokio::main]
async fn main() {
let listener = TcpListener::bind("127.0.0.1:9001").await.unwrap();
while let Ok((stream, _)) = listener.accept().await {
tokio::spawn(async move {
let ws = accept_async(stream).await.unwrap();
let (mut tx, mut rx) = ws.split();
while let Some(msg) = rx.next().await {
let msg = msg.unwrap();
// Broadcast to other peers, persist, etc.
tx.send(msg).await.unwrap();
}
});
}
}
6. Code a Roguelike Game for Desktop and WebAssembly
Tutorial: Writing a Rust Roguelike for the Desktop and the Web
Build a tile-based dungeon crawler rendered with tcod on the desktop and with wasm-bindgen + web-sys in the browser. This project demonstrates cross-platform Rust architecture where core game logic remains pure while rendering adapts to the target.
Key layers:
| Layer | Desktop | Web |
|---|---|---|
| Rendering | tcod (terminal graphics) |
wasm-bindgen + <canvas> |
| Game loop | std::thread::sleep + event poll |
requestAnimationFrame via web-sys |
| Input | Keyboard events via tcod |
web-sys keyboard listeners |
| State | Pure Rust structs (player, map, entities) | Shared unchanged |
Desktop game loop:
use tcod::Console;
fn main() {
let mut console = tcod::Console::init_root(80, 50, "Roguelike", false);
while !tcod::input::key_pressed(tcod::KeyCode::Escape) {
console.clear();
console.print(1, 1, "You are in a dark dungeon.");
console.flush();
tcod::system::delay(100);
}
}
7. Create a Single-Page Application with Yew and WebAssembly
Tutorial: Single Page Applications using Rust
Construct a client-side SPA (such as a markdown editor) compiled to WebAssembly using the Yew framework. This Rust project introduces component-based architecture in the browser without JavaScript.
Architectural pieces:
- Component hierarchy –
function_componentorstruct Component. - State management –
use_state,use_reducer. - Routing –
yew_router. - Interop –
wasm_bindgenfor JS APIs (localStorage, fetch).
Yew component example:
use yew::prelude::*;
#[function_component(App)]
fn app() -> Html {
let count = use_state(|| 0);
let onclick = {
let count = count.clone();
Callback::from(move |_| count.set(*count + 1))
};
html! {
<div>
<button {onclick}>{ "Increment" }</button>
<p>{ format!("Count: {}", *count) }</p>
</div>
}
}
Build with trunk or wasm-pack and serve the generated index.html.
8. Build an NES Emulator in Rust
Tutorial: Writing NES Emulator in Rust
Develop a faithful emulation of the Nintendo Entertainment System, covering the 6502 CPU, PPU (Picture Processing Unit), input handling, and cartridge loading. This is one of the most complex Rust projects, teaching bitwise operations, memory mapping, and cycle-accurate simulation.
Major subsystems:
| Subsystem | Key Tasks |
|---|---|
| CPU (6502) | Decode/execute opcodes, registers, flags |
| Memory mapper | Bank switching for ROM cartridges |
| PPU | Render tiles, sprites, handle scrolling |
| APU | Audio synthesis (optional) |
| Input | Controller state via SDL2 or gilrs |
CPU fetch-decode-execute loop:
fn step(&mut self) {
let opcode = self.read(self.pc);
self.pc += 1;
match opcode {
0xA9 => { // LDA Immediate
let value = self.read(self.pc);
self.pc += 1;
self.a = value;
self.set_zero_and_negative_flags(self.a);
}
// … other opcodes …
_ => panic!("Unimplemented opcode: {:02X}", opcode),
}
}
9. Evolution Simulation with Neural Networks and WebAssembly
Tutorial: Learning to Fly – Evolution simulation with WebAssembly (parts 1‑4)
Create a physics-based simulation where "birds" learn to navigate obstacles via a neural network trained by a genetic algorithm, running entirely in the browser as WASM. This Rust project combines machine learning concepts with high-performance browser computing.
Core parts:
- Physics engine – simple 2D kinematics.
- Neural network – feed-forward, weights stored in a flat
Vec<f32>. - Genetic algorithm – selection, crossover, mutation applied each generation.
- Rendering –
<canvas>withwasm-bindgen.
Genome crossover implementation:
fn crossover(parent1: &[f32], parent2: &[f32]) -> Vec<f32> {
let mut child = Vec::with_capacity(parent1.len());
for i in 0..parent1.len() {
// Randomly pick gene from either parent
child.push(if js_sys::Math::random() < 0.5 {
parent1[i]
} else {
parent2[i]
});
}
child
}
Summary
The practical-tutorials/project-based-learning repository provides a graduated path through the Rust ecosystem via these nine tutorials:
- Web Development: Build HTTP servers with Actix-Web, REST microservices with Axum, and real-time chat systems with WebSockets.
- Systems Programming: Develop a bare-metal operating system kernel and a cycle-accurate NES emulator.
- Frontend & WASM: Create browser-based SPAs with Yew, cross-platform roguelikes, and AI-driven evolution simulations.
- Language Features: Master async/await with tokio, unsafe code for kernel development, and zero-cost abstractions for game engines.
Each project references external, up-to-date guides listed in README.md (lines 6260–6465) that you can follow to build a comprehensive portfolio demonstrating systems-level and application-level Rust expertise.
Frequently Asked Questions
What prerequisites do I need for these Rust projects?
Most tutorials assume basic familiarity with Rust syntax and ownership concepts. The web and WASM projects require understanding of async programming with tokio, while the operating system and emulator tutorials require comfort with unsafe Rust and low-level memory manipulation. The README.md in the repository provides direct links to each tutorial's specific requirements.
Which Rust project is best for learning async programming?
The Scalable Chat Service (using tokio-tungstenite) and REST Microservice (using axum or warp) tutorials specifically focus on async Rust patterns, including concurrent connection handling, shared state with Arc<RwLock<_>>, and non-blocking I/O. These are ideal for mastering Rust's async/await ecosystem.
Are these tutorials updated for the latest Rust edition?
The tutorials are curated in the repository's README.md (lines 6260–6465) and link to external guides maintained by their original authors. While the repository itself does not ship Rust source files, the linked tutorials are actively maintained and updated for current Rust editions (2021/2024). Always check the tutorial's date and Rust version requirements before starting.
Can I deploy these Rust projects to production?
Yes. The Simple Web App, REST Microservice, and Chat Service tutorials specifically teach container-ready patterns and can be deployed to platforms like AWS, Fly.io, or Docker. The Operating System and NES Emulator projects are educational but demonstrate architectural patterns applicable to embedded and systems production environments. The WASM projects compile to static files suitable for any CDN.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →