$ show loco-rs/loco
Loco is a batteries-included, Rails-inspired web framework for Rust, built on Axum, Sea-ORM, and Tera. It provides a full-stack MVC architecture with built-in authentication (JWT, API tokens, magic links), background job processing (Redis, Postgres, SQLite queues), mailer (SMTP/stub), caching (in-memory, Redis), storage (local, S3, Azure, GCS), cron scheduling, and code generation via CLI. The framework emphasizes convention over configuration and includes an interactive project generator (`loco new`) that scaffolds complete SaaS or API apps with optional React frontend. It also ships an agent skill system (`.claude/skills/loco/`) for AI-assisted development, alongside a dedicated evaluation harness for measuring code-generation quality. The repository contains two example applications (`demo`, `reference_spa`), a code generation crate (`loco-gen`), a project scaffolding crate (`loco-new`), an Astro documentation website, and an integrated eval framework. The codebase is well-structured with clean trait abstractions, extensive snapshot testing, and a clear separation between generated and hand-written model code. It is actively maintained with recent commits, responsive issue triage, and regular releases tracked in a detailed CHANGELOG.
The LLM identified 5 files worth highlighting for reuse:
Provides a family of Axum extractors (`JWT`, `JWTWithUser`, `ApiToken<T: Authenticable>`, `Option<JWT>`) that validate tokens from configurable locations (Bearer header, cookie, query parameter). The `extract_token` function chains multiple location strategies with a fallback. The `get_jwt_locations` function builds the extraction pipeline from configuration. This is a self-contained, reusable authentication abstraction that can be extracted into any Axum project with minimal modification. It demonstrates clean trait-based design and separation of token validation from user lookup.
Implements a generic pagination system: `PaginationQuery` derives from a filter DTO via `#[serde(flatten)]` and builds Sea-ORM queries with offset/limit. The `paginate` and `fetch_page` methods return a `PageResponse<T>` containing `PagerMeta` (page, page_size, total_pages, total_items). This is a standard pagination abstraction that can be reused across any Sea-ORM project. The pattern is minimal, well-tested, and produces a consistent API envelope.
Defines a `Cache` struct wrapping `Arc<dyn CacheDriver>` with methods like `get`, `set`, `get_or_insert`, `with_ttl`, and `keys`. Supports null (no-op), in-memory (moka), and Redis backends. The `get_or_insert` method provides a TTL-aware, double-checked caching pattern. This is a clean, extraction-ready caching abstraction for any async Rust project, with a simple trait interface and multiple ready-made drivers.
Implements `ReplicatedStrategy` which wraps a primary `StoreDriver` and zero or more secondary drivers. Uploads fan out to all stores (with configurable `ReplicatedFailurePolicy` like fail-primary or fail-any). Reads try primary first, then secondaries on failure. The implementation handles `upload`, `upload_stream`, `delete`, and `get` operations with proper error handling. This is a non-obvious pattern for data replication that can be extracted and applied to any storage or even non-storage fan-out scenarios.
Provides a generic background worker system: `BackgroundWorker` trait with `perform`, `perform_later`, and `perform_all_later`. Workers can be `BackgroundQueue`, `ForegroundBlocking`, or `BackgroundAsync`. The `Queue` newtype wraps `Arc<dyn QueueProvider>` and offers enqueue, batch enqueue, register, run, and management methods (cancel, retry, clear). Supports priority, tags, and visibility timeout. This is a reusable, trait-based async job queue abstraction decoupled from specific queue backends (Postgres, SQLite, Redis).