Learning & Examples

July 5, 2026 ยท View on GitHub

Welcome to the RustAPI learning resources! This section provides structured learning paths and links to comprehensive real-world examples to help you master the framework.

๐ŸŽ“ Structured Curriculum

New to RustAPI? Follow our step-by-step Structured Learning Path to go from beginner to production-ready.

๐Ÿ“š Learning Resources

Official Examples Repository

We maintain a comprehensive examples repository with 18 real-world projects demonstrating RustAPI's full capabilities:

๐Ÿ”— rustapi-rs-examples - Complete examples from hello-world to production microservices

Cookbook Internal Path

If you prefer reading through documentation first, follow this path through the cookbook:

  1. Foundations: Start with Handlers & Extractors and System Overview.
  2. Core Crates: Read about rustapi-core and rustapi-macros.
  3. Building Blocks: Try the Creating Resources recipe.
  4. Security: Implement JWT Authentication and CSRF Protection.
  5. Advanced: Explore Performance Tuning and HTTP/3.
  6. Background Jobs: Master rustapi-jobs for async processing.

Why Use the Examples Repository?

BenefitDescription
Structured LearningProgress from beginner โ†’ intermediate โ†’ advanced
Real-world PatternsProduction-ready implementations you can adapt
Feature DiscoveryFind examples by the features you want to learn
AI-FriendlyModule-level docs help AI assistants understand your code

๐ŸŽฏ Learning Paths

Choose a learning path based on your goals:

๐Ÿš€ Path 1: REST API Developer

Build production-ready REST APIs with RustAPI.

StepExampleSkills Learned
1hello-worldBasic routing, handlers, server setup
2crud-apiCRUD operations, extractors, error handling
3auth-apiJWT authentication, protected routes
4middleware-chainCustom middleware, logging, CORS
5sqlx-crudDatabase integration, async queries

Related Cookbook Recipes:


๐Ÿ—๏ธ Path 2: Microservices Architect

Design and build distributed systems with RustAPI.

StepExampleSkills Learned
1crud-apiService fundamentals
2middleware-chainCross-cutting concerns
3rate-limit-demoAPI protection, throttling
4microservicesService communication patterns
5microservices-advancedService discovery, Consul integration
6Service MockingTesting microservices with MockServer from rustapi-testing
7Background jobs (conceptual)Background processing with rustapi-jobs, Redis/Postgres backends

Note: The Background jobs (conceptual) step refers to using the rustapi-jobs crate rather than a standalone example project. Related Cookbook Recipes:


โšก Path 3: Real-time Applications

Build interactive, real-time features with WebSockets.

StepExampleSkills Learned
1hello-worldFramework basics
2websocketWebSocket connections, message handling
3middleware-chainConnection middleware
4graphql-apiSubscriptions, real-time queries

Related Cookbook Recipes:


๐Ÿค– Path 4: AI/LLM Integration

Build AI-friendly APIs with TOON format and MCP support.

StepExampleSkills Learned
1crud-apiAPI fundamentals
2toon-apiTOON format for LLM-friendly responses
3mcp-serverModel Context Protocol implementation
4proof-of-conceptCombining multiple AI features

Related Cookbook Recipes:


๐Ÿข Path 5: Enterprise Platform

Build robust, observable, and secure systems.

StepFeatureDescription
1ObservabilitySet up OpenTelemetry and Structured Logging
2ResilienceImplement Circuit Breakers and Retries
3Advanced SecurityAdd OAuth2 and Security Headers
4OptimizationConfigure Caching and Deduplication
5Background JobsImplement Reliable Job Queues
6DebuggingSet up Time-Travel Debugging
7Reliable TestingMaster Mocking and Integration Testing

Related Cookbook Recipes:


๐Ÿ“ฆ Examples by Category

Getting Started

ExampleDescriptionDifficulty
hello-worldMinimal RustAPI serverโญ Beginner
crud-apiComplete CRUD operationsโญ Beginner

Authentication & Security

ExampleDescriptionDifficulty
auth-apiJWT authentication flowโญโญ Intermediate
middleware-chainMiddleware compositionโญโญ Intermediate
rate-limit-demoAPI rate limitingโญโญ Intermediate

Database Integration

ExampleDescriptionDifficulty
sqlx-crudSQLx with PostgreSQL/SQLiteโญโญ Intermediate
event-sourcingEvent sourcing patternsโญโญโญ Advanced

AI & LLM

ExampleDescriptionDifficulty
toon-apiTOON format responsesโญโญ Intermediate
mcp-serverModel Context Protocolโญโญโญ Advanced

Real-time & GraphQL

ExampleDescriptionDifficulty
websocketWebSocket chat exampleโญโญ Intermediate
graphql-apiGraphQL with async-graphqlโญโญโญ Advanced

Production Patterns

ExampleDescriptionDifficulty
microservicesBasic service communicationโญโญโญ Advanced
microservices-advancedConsul service discoveryโญโญโญ Advanced
serverless-lambdaAWS Lambda deploymentโญโญโญ Advanced

๐Ÿ”ง Feature Matrix

Find examples by the RustAPI features they demonstrate:

FeatureExamples
#[get], #[post] macrosAll examples
State<T> extractorcrud-api, auth-api, sqlx-crud
Json<T> extractorcrud-api, auth-api, graphql-api
ValidatedJson<T>auth-api, crud-api
JWT (extras-jwt feature)auth-api, microservices
CORS (extras-cors feature)middleware-chain, auth-api
Rate Limitingrate-limit-demo, auth-api
WebSockets (protocol-ws feature)websocket, graphql-api
TOON (protocol-toon feature)toon-api, mcp-server
OAuth2 (oauth2-client)auth-api (extended)
Circuit Breakermicroservices
Replay (extras-replay feature)microservices (conceptual)
OpenTelemetry (otel)microservices-advanced
OpenAPI/SwaggerAll examples

๐Ÿšฆ Getting Started with Examples

Clone the Repository

git clone https://github.com/Tuntii/rustapi-rs-examples.git
cd rustapi-rs-examples

Run an Example

cd hello-world
cargo run

Test an Example

# Most examples have tests
cargo test

# Or use the TestClient
cd ../crud-api
cargo test

Explore the Structure

Each example includes:

  • README.md - Detailed documentation with API endpoints
  • src/main.rs - Entry point with server setup
  • src/handlers.rs - Request handlers (where applicable)
  • Cargo.toml - Dependencies and feature flags
  • Tests demonstrating the TestClient

๐Ÿ“– Cross-Reference: Cookbook โ†” Examples

Cookbook RecipeRelated Examples
Creating Resourcescrud-api, sqlx-crud
JWT Authenticationauth-api
CSRF Protectionauth-api, middleware-chain
Database Integrationsqlx-crud, event-sourcing
File Uploadsfile-upload (planned)
Custom Middlewaremiddleware-chain
Real-time Chatwebsocket
Production Tuningmicroservices-advanced
Resilience Patternsmicroservices
Time-Travel Debuggingmicroservices
Deploymentserverless-lambda

๐Ÿ’ก Contributing Examples

Have a great example to share? We welcome contributions!

  1. Fork the rustapi-rs-examples repository
  2. Create your example following our structure guidelines
  3. Add comprehensive documentation in README.md
  4. Submit a pull request

Example Guidelines

  • Include a clear README with prerequisites and API endpoints
  • Add code comments explaining RustAPI-specific patterns
  • Include working tests using rustapi-testing
  • List the feature flags used

๐Ÿ”— Additional Resources


๐Ÿ’ฌ Need help? Open an issue in the examples repository or join our community discussions!