@@ -13,20 +13,46 @@ This curriculum is designed to take you from a RustAPI beginner to an advanced u
1313- ** Expected Output:** A running server that responds to ` GET / ` with "Hello World".
1414- ** Pitfalls:** Not enabling ` tokio ` features if setting up manually.
1515
16+ #### 🧠 Knowledge Check
17+ 1 . What command scaffolds a new RustAPI project?
18+ 2 . Which feature flag is required for the async runtime?
19+ 3 . Where is the main entry point of the application typically located?
20+
1621### Module 2: Routing & Handlers
1722- ** Prerequisites:** Module 1.
1823- ** Reading:** [ Handlers & Extractors] ( ../concepts/handlers.md ) .
1924- ** Task:** Create routes for ` GET /users ` , ` POST /users ` , ` GET /users/{id} ` .
2025- ** Expected Output:** Endpoints that return static JSON data.
2126- ** Pitfalls:** Forgetting to register routes in ` main.rs ` if not using auto-discovery.
2227
28+ #### 🧠 Knowledge Check
29+ 1 . Which macro is used to define a GET handler?
30+ 2 . How do you return a JSON response from a handler?
31+ 3 . What is the return type of a typical handler function?
32+
2333### Module 3: Extractors
2434- ** Prerequisites:** Module 2.
2535- ** Reading:** [ Handlers & Extractors] ( ../concepts/handlers.md ) .
2636- ** Task:** Use ` Path ` , ` Query ` , and ` Json ` extractors to handle dynamic input.
2737- ** Expected Output:** ` GET /users/{id} ` returns the ID. ` POST /users ` echoes the JSON body.
2838- ** Pitfalls:** Consuming the body twice (e.g., using ` Json ` and ` Body ` in the same handler).
2939
40+ #### 🧠 Knowledge Check
41+ 1 . Which extractor is used for URL parameters like ` /users/:id ` ?
42+ 2 . Which extractor parses the request body as JSON?
43+ 3 . Can you use multiple extractors in a single handler?
44+
45+ ### 🏆 Phase 1 Capstone: "The Todo List API"
46+ ** Objective:** Build a simple in-memory Todo List API.
47+ ** Requirements:**
48+ - ` GET /todos ` : List all todos.
49+ - ` POST /todos ` : Create a new todo.
50+ - ` GET /todos/:id ` : Get a specific todo.
51+ - ` DELETE /todos/:id ` : Delete a todo.
52+ - Use ` State ` to store the list in a ` Mutex<Vec<Todo>> ` .
53+
54+ ---
55+
3056## Phase 2: Core Development
3157
3258** Goal:** Add real logic, validation, and documentation.
@@ -38,20 +64,45 @@ This curriculum is designed to take you from a RustAPI beginner to an advanced u
3864- ** Expected Output:** A stateful API where POST adds a user and GET retrieves it (in-memory).
3965- ** Pitfalls:** Using ` std::sync::Mutex ` instead of ` tokio::sync::Mutex ` in async code (though ` std ` is fine for simple data).
4066
67+ #### 🧠 Knowledge Check
68+ 1 . How do you inject global state into the application?
69+ 2 . Which extractor retrieves the application state?
70+ 3 . Why should you use ` Arc ` for shared state?
71+
4172### Module 5: Validation
4273- ** Prerequisites:** Module 4.
4374- ** Reading:** [ Validation] ( ../crates/rustapi_validation.md ) .
4475- ** Task:** Add ` #[derive(Validate)] ` to your ` User ` struct. Use ` ValidatedJson ` .
4576- ** Expected Output:** Requests with invalid email or short password return ` 422 Unprocessable Entity ` .
4677- ** Pitfalls:** Forgetting to add ` #[validate] ` attributes to struct fields.
4778
79+ #### 🧠 Knowledge Check
80+ 1 . Which trait must a struct implement to be validatable?
81+ 2 . What HTTP status code is returned on validation failure?
82+ 3 . How do you combine JSON extraction and validation?
83+
4884### Module 6: OpenAPI & HATEOAS
4985- ** Prerequisites:** Module 5.
5086- ** Reading:** [ OpenAPI] ( ../crates/rustapi_openapi.md ) , [ Pagination Recipe] ( ../recipes/pagination.md ) .
5187- ** Task:** Add ` #[derive(Schema)] ` to all DTOs. Implement pagination for ` GET /users ` .
5288- ** Expected Output:** Swagger UI at ` /docs ` showing full schema. Paginated responses with ` _links ` .
5389- ** Pitfalls:** Using types that don't implement ` Schema ` (like raw ` serde_json::Value ` ) inside response structs.
5490
91+ #### 🧠 Knowledge Check
92+ 1 . What does ` #[derive(Schema)] ` do?
93+ 2 . Where is the Swagger UI served by default?
94+ 3 . What is HATEOAS and why is it useful?
95+
96+ ### 🏆 Phase 2 Capstone: "The Secure Blog Engine"
97+ ** Objective:** Enhance the Todo API into a Blog Engine.
98+ ** Requirements:**
99+ - Add ` Post ` resource with title, content, and author.
100+ - Validate that titles are not empty and content is at least 10 chars.
101+ - Add pagination to ` GET /posts ` .
102+ - Enable Swagger UI to visualize the API.
103+
104+ ---
105+
55106## Phase 3: Advanced Features
56107
57108** Goal:** Security, Real-time, and Production readiness.
@@ -63,30 +114,46 @@ This curriculum is designed to take you from a RustAPI beginner to an advanced u
63114- ** Expected Output:** Protected routes return ` 401 Unauthorized ` without a valid token.
64115- ** Pitfalls:** Hardcoding secrets. Not checking token expiration.
65116
117+ #### 🧠 Knowledge Check
118+ 1 . What is the role of the ` AuthUser ` extractor?
119+ 2 . How do you protect a route with JWT?
120+ 3 . Where should you store the JWT secret?
121+
66122### Module 8: WebSockets & Real-time
67123- ** Prerequisites:** Phase 2.
68124- ** Reading:** [ WebSockets Recipe] ( ../recipes/websockets.md ) .
69125- ** Task:** Create a chat endpoint where users can broadcast messages.
70126- ** Expected Output:** Multiple clients connected via WS receiving messages in real-time.
71127- ** Pitfalls:** Blocking the WebSocket loop with long-running synchronous tasks.
72128
73- ### Module 9: Production Readiness
129+ #### 🧠 Knowledge Check
130+ 1 . How do you upgrade an HTTP request to a WebSocket connection?
131+ 2 . Can you share state between HTTP handlers and WebSocket handlers?
132+ 3 . What happens if a WebSocket handler panics?
133+
134+ ### Module 9: Production Readiness & Deployment
74135- ** Prerequisites:** Phase 3.
75- - ** Reading:** [ Production Tuning] ( ../recipes/high_performance.md ) , [ Resilience] ( ../recipes/resilience.md ) .
76- - ** Task:** Add ` RateLimitLayer ` , ` CompressionLayer ` , and ` TimeoutLayer ` .
77- - ** Expected Output:** An API that handles load gracefully and rejects abuse.
136+ - ** Reading:** [ Production Tuning] ( ../recipes/high_performance.md ) , [ Resilience] ( ../recipes/resilience.md ) , [ Deployment] ( ../recipes/deployment.md ) .
137+ - ** Task:**
138+ 1 . Add ` RateLimitLayer ` , ` CompressionLayer ` , and ` TimeoutLayer ` .
139+ 2 . Use ` cargo rustapi deploy docker ` to generate a Dockerfile.
140+ - ** Expected Output:** A resilient API ready for deployment.
78141- ** Pitfalls:** Setting timeouts too low for slow operations.
79142
80- ## Knowledge Check
143+ #### 🧠 Knowledge Check
144+ 1 . Why is rate limiting important?
145+ 2 . What command generates a production Dockerfile?
146+ 3 . How do you enable compression for responses?
147+
148+ ### 🏆 Phase 3 Capstone: "The Real-Time Collaboration Tool"
149+ ** Objective:** Build a real-time collaborative note-taking app.
150+ ** Requirements:**
151+ - ** Auth:** Users must log in to edit notes.
152+ - ** Real-time:** Changes to a note are broadcast to all viewers via WebSockets.
153+ - ** Resilience:** Rate limit API requests to prevent abuse.
154+ - ** Deployment:** specify a ` Dockerfile ` for the application.
81155
82- 1 . ** Q:** Which extractor consumes the request body?
83- * ** A:** ` Json<T> ` , ` ValidatedJson<T> ` , ` Body ` .
84- 2 . ** Q:** How do you share a database connection pool across handlers?
85- * ** A:** Use the ` State<T> ` extractor and initialize it in ` RustApi::new().with_state(state) ` .
86- 3 . ** Q:** What is the purpose of ` derive(Schema) ` ?
87- * ** A:** It generates the OpenAPI schema definition for the struct, allowing it to be documented in Swagger UI.
88- 4 . ** Q:** How do you handle pagination links automatically?
89- * ** A:** Return ` ResourceCollection<T> ` and call ` .with_pagination() ` .
156+ ---
90157
91158## Next Steps
92159
0 commit comments