|
| 1 | +# VESPERA PROJECT KNOWLEDGE BASE |
| 2 | + |
| 3 | +**Generated:** 2026-01-07 |
| 4 | +**Commit:** 939a801 |
| 5 | +**Branch:** main |
| 6 | + |
| 7 | +## OVERVIEW |
| 8 | + |
| 9 | +Vespera is a fully automated OpenAPI 3.1 engine for Axum - delivers FastAPI-like DX to Rust. Zero-config route discovery via compile-time macro scanning. |
| 10 | + |
| 11 | +## STRUCTURE |
| 12 | + |
| 13 | +``` |
| 14 | +vespera/ |
| 15 | +├── crates/ |
| 16 | +│ ├── vespera/ # Public API - re-exports everything |
| 17 | +│ ├── vespera_core/ # OpenAPI types, route/schema abstractions |
| 18 | +│ └── vespera_macro/ # Proc-macros (main logic lives here) |
| 19 | +└── examples/axum-example/ # Demo app with route patterns |
| 20 | +``` |
| 21 | + |
| 22 | +## WHERE TO LOOK |
| 23 | + |
| 24 | +| Task | Location | Notes | |
| 25 | +|------|----------|-------| |
| 26 | +| Add new macro feature | `crates/vespera_macro/src/` | Main macro in `lib.rs` | |
| 27 | +| Modify OpenAPI output | `crates/vespera_macro/src/openapi_generator.rs` | JSON generation | |
| 28 | +| Add route parser feature | `crates/vespera_macro/src/parser/` | Type extraction logic | |
| 29 | +| Change schema generation | `crates/vespera_macro/src/parser/schema.rs` | Rust→JSON Schema | |
| 30 | +| Modify route attribute | `crates/vespera_macro/src/args.rs` | `#[route]` parsing | |
| 31 | +| Add core types | `crates/vespera_core/src/` | OpenAPI spec types | |
| 32 | +| Test new features | `examples/axum-example/` | Add route, run example | |
| 33 | + |
| 34 | +## KEY COMPONENTS |
| 35 | + |
| 36 | +| File | Lines | Role | |
| 37 | +|------|-------|------| |
| 38 | +| `vespera_macro/src/lib.rs` | 1044 | `vespera!`, `#[route]`, `#[derive(Schema)]` | |
| 39 | +| `vespera_macro/src/parser/schema.rs` | 1527 | Rust struct → JSON Schema conversion | |
| 40 | +| `vespera_macro/src/parser/parameters.rs` | 845 | Extract path/query params from handlers | |
| 41 | +| `vespera_macro/src/openapi_generator.rs` | 808 | OpenAPI doc assembly | |
| 42 | +| `vespera_macro/src/collector.rs` | 707 | Filesystem route scanning | |
| 43 | + |
| 44 | +## CONVENTIONS |
| 45 | + |
| 46 | +- **Rust 2024 edition** across all crates |
| 47 | +- **Workspace dependencies**: Internal crates use `{ workspace = true }` |
| 48 | +- **Version sync**: All crates at 0.1.19 |
| 49 | +- **Test frameworks**: `rstest` for unit tests, `insta` for snapshots |
| 50 | +- **No `build.rs`**: All code gen via proc-macros at compile time |
| 51 | + |
| 52 | +## ANTI-PATTERNS (THIS PROJECT) |
| 53 | + |
| 54 | +- **NEVER** add `build.rs` - macro handles compile-time generation |
| 55 | +- **NEVER** manually register routes - `vespera!` macro discovers them |
| 56 | +- **NEVER** write OpenAPI JSON by hand - generated from code |
| 57 | +- Route functions **MUST** be `pub async fn` |
| 58 | + |
| 59 | +## ARCHITECTURE FLOW |
| 60 | + |
| 61 | +``` |
| 62 | +User writes: vespera!() macro at compile-time: |
| 63 | +┌──────────────┐ ┌────────────────────────────────────────┐ |
| 64 | +│ src/routes/ │ ──── │ 1. Scan filesystem for .rs files │ |
| 65 | +│ users.rs │ │ 2. Parse #[route] attributes │ |
| 66 | +│ posts.rs │ │ 3. Extract handler signatures │ |
| 67 | +└──────────────┘ │ 4. Generate Axum Router code │ |
| 68 | + │ 5. Build OpenAPI spec │ |
| 69 | + │ 6. Write openapi.json (optional) │ |
| 70 | + │ 7. Inject Swagger/ReDoc routes │ |
| 71 | + └────────────────────────────────────────┘ |
| 72 | +``` |
| 73 | + |
| 74 | +## COMMANDS |
| 75 | + |
| 76 | +```bash |
| 77 | +# Development |
| 78 | +cargo build # Build all crates |
| 79 | +cargo test --workspace # Run all tests |
| 80 | +cargo test -p vespera_macro # Test macros only |
| 81 | + |
| 82 | +# Run example |
| 83 | +cd examples/axum-example |
| 84 | +cargo run # Starts server on :3000 |
| 85 | +# Visit http://localhost:3000/docs for Swagger UI |
| 86 | + |
| 87 | +# Check generated OpenAPI |
| 88 | +cat examples/axum-example/openapi.json |
| 89 | +``` |
| 90 | + |
| 91 | +## NOTES |
| 92 | + |
| 93 | +- Macro performs **filesystem I/O at compile time** - may affect IDE performance |
| 94 | +- OpenAPI files are **regenerated on every build** when `openapi = "..."` specified |
| 95 | +- `CARGO_MANIFEST_DIR` env var used to locate `src/routes/` folder |
| 96 | +- Generic types in schemas require `#[derive(Schema)]` on all type params |
0 commit comments