This repository now contains a complete Rust-based web API project structure implementing the Container Engine platform - an open-source alternative to Google Cloud Run. The project is built with modern Rust technologies and follows best practices for scalable web applications.
- Rust + Axum web framework setup with async/await support
- PostgreSQL database integration with SQLx for type-safe queries
- Redis caching layer for session management and performance
- JWT-based authentication with refresh tokens
- API key management for programmatic access
- Comprehensive error handling with structured error responses
- Configuration management with environment variables
- Docker containerization with multi-stage builds
- Docker Compose development environment
- User registration and login system
- Password hashing with bcrypt
- JWT token generation and validation
- API key creation, management, and revocation
- Middleware-based authentication for protected routes
- Secure password change functionality
- User profile management (view, update)
- Account creation with email validation
- User statistics (deployment count, API key count)
- Profile update with conflict detection
- Complete API endpoint structure for container deployments
- Deployment lifecycle management (create, read, update, delete)
- Scaling capabilities (horizontal scaling)
- Environment variable management
- Resource allocation and limits
- Health check configuration
- Custom domain mapping (API structure)
- Logs and metrics endpoints (API structure)
- Users table - User accounts and authentication
- API keys table - API key management with expiration
- Deployments table - Container deployment metadata
- Domains table - Custom domain mappings
- Proper indexing for performance
- Auto-updating timestamps with triggers
- Foreign key constraints for data integrity
- Makefile with common development tasks
- Docker Compose for local development
- Database migrations with SQLx
- Environment configuration with validation
- Development documentation with setup instructions
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Frontend/CLI │ │ Load Balancer │ │ API Gateway │
│ │────│ (nginx) │────│ (Axum) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
┌─────────────────────────────────┼─────────────────┐
│ │ │
┌───────────────┐ ┌─────────────────┐ ┌─────────────┐
│ PostgreSQL │ │ Redis │ │ Kubernetes │
│ Database │ │ Cache │ │ Cluster │
│ │ │ │ │ │
└───────────────┘ └─────────────────┘ └─────────────┘
| Component | Technology | Purpose |
|---|---|---|
| Backend Framework | Rust + Axum | High-performance async web server |
| Database | PostgreSQL + SQLx | Type-safe database queries |
| Cache | Redis | Session management and caching |
| Authentication | JWT + bcrypt | Secure user authentication |
| Containerization | Docker + Docker Compose | Development and deployment |
| Orchestration | Kubernetes (API ready) | Container deployment platform |
| Configuration | Environment variables | Flexible configuration management |
| Logging | Tracing + tracing-subscriber | Structured logging |
| Validation | Validator crate | Request validation |
| Error Handling | thiserror + anyhow | Comprehensive error management |
Open-Container-Engine/
├── src/
│ ├── main.rs # Application entry point
│ ├── config.rs # Configuration management
│ ├── database.rs # Database setup and connections
│ ├── error.rs # Error types and handling
│ ├── auth/ # Authentication module
│ │ ├── models.rs # User and API key models
│ │ ├── jwt.rs # JWT token management
│ │ └── middleware.rs # Auth middleware
│ ├── user/ # User management
│ │ └── models.rs # User profile models
│ ├── deployment/ # Deployment management
│ │ └── models.rs # Deployment models
│ └── handlers/ # HTTP handlers
│ ├── auth.rs # Auth endpoints
│ ├── user.rs # User endpoints
│ └── deployment.rs # Deployment endpoints
├── migrations/ # Database migrations
├── docker-compose.yml # Development environment
├── Dockerfile # Container definition
├── Makefile # Development commands
├── DEVELOPMENT.md # Setup instructions
├── .env.example # Environment template
└── Cargo.toml # Dependencies and metadata
# 1. Clone and setup
git clone https://github.com/ngocbd/Open-Container-Engine.git
cd Open-Container-Engine
make setup
# 2. Start databases and run migrations
make db-up && make migrate
# 3. Start the development server
make dev# Health check
curl http://localhost:3000/health
# Register a user
curl -X POST http://localhost:3000/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"username": "testuser",
"email": "test@example.com",
"password": "password123",
"confirmPassword": "password123"
}'- Complete Rust project structure
- Axum web server with routing
- PostgreSQL database with migrations
- Redis caching integration
- User authentication (JWT + API keys)
- User management endpoints
- Deployment API structure
- Error handling and validation
- Docker containerization
- Development environment setup
- Comprehensive documentation
- SQLx query compilation (requires database connection)
- Kubernetes integration for actual container deployment
- Container registry authentication
- Real-time logging and metrics collection
- Domain management and SSL certificates
- Fix SQLx compilation - Set up database and run
cargo sqlx prepare - Kubernetes integration - Implement actual container orchestration
- Container registry support - Add Docker Hub, GCR, ECR integration
- Monitoring and logging - Implement Prometheus metrics
- Domain management - Add DNS and SSL certificate management
- Frontend dashboard - Build user interface
- CI/CD pipeline - Automated testing and deployment
POST /v1/auth/register- User registrationPOST /v1/auth/login- User loginGET /v1/user/profile- Get user profilePOST /v1/api-keys- Create API key
POST /v1/deployments- Deploy containerGET /v1/deployments- List deploymentsGET /v1/deployments/{id}- Get deployment detailsPUT /v1/deployments/{id}- Update deploymentDELETE /v1/deployments/{id}- Delete deploymentPATCH /v1/deployments/{id}/scale- Scale deployment
- DEVELOPMENT.md - Detailed setup and development guide
- APIs.md - Complete API documentation
- README.md - Original project overview
- Inline code documentation - Comprehensive code comments
The project structure is ready for contributions! See the development guide for:
- Local setup instructions
- Code formatting and linting
- Database migration management
- Testing procedures
- Docker workflow
MIT License - See the original README.md for full license details.
This project structure provides a solid foundation for building a production-ready container orchestration platform with Rust, Axum, PostgreSQL, and Redis.