A production-ready, modular Rust API framework designed for scalability and maintainability. Built with Actix-web, SeaORM, and Utoipa.
- Modular Architecture: Split into
api,entity,migration,repository, andutilcrates. - REST API: Built with Actix-web.
- ORM: SeaORM for type-safe database interactions (PostgreSQL).
- Migrations: Database schema migrations managed via SeaORM Migration.
- Documentation: Auto-generated Swagger/OpenAPI documentation (
/swagger-ui). - Configuration: Environment variable based configuration.
- Containerization: Optimized Dockerfile for production.
- CI/CD: Jenkinsfile and Kubernetes manifests included.
├── api # Main API server, handlers, services, routes, DTOs
├── entity # Database entities (SeaORM models)
├── migration # Database migrations
├── repository # Data access layer (Repositories)
├── util # Shared utilities (S3, Sanitization, etc.)
├── k8s # Kubernetes manifests
├── Cargo.toml # Workspace configuration
└── Dockerfile # Multi-stage Docker build
- Rust: 1.75+
- PostgreSQL: 14+
- Docker (optional)
Copy .env.example to .env and configure your database credentials:
cp .env.example .envcargo run -p migrationcargo run -p apiThe server will start at http://localhost:3000.
- Health Check:
http://localhost:3000/health - Swagger UI:
http://localhost:3000/swagger-ui/
- Create a new migration in
migration/src/. - Create the entity file in
entity/src/entity/. - Register the entity in
entity/src/entity/mod.rs.
- Create a Repository in
repository/src/repositories/. - Create DTOs in
api/src/dto/. - Create a Service in
api/src/services/. - Create a Handler in
api/src/handlers/. - Register Routes in
api/src/routes/. - Register the service in
api/src/main.rs.
docker build -t cf-framework .
docker run -p 3000:3000 --env-file .env cf-frameworkThe k8s/ directory contains standard Kubernetes manifests:
deployment.yamlservice.yamlingress.yamlconfigmap.yamlsecret.yaml
Update configmap.yaml and secret.yaml with your production configuration before applying.