Architecture Overview
JifiJs follows a clean, modular MVC (Model-View-Controller) architecture with additional layers for separation of concerns.
Architecture Layers
┌─────────────────────────────────────┐
│ Client Application │
└──────────────┬──────────────────────┘
│ HTTP Requests
┌──────────────▼──── ──────────────────┐
│ Routes + Middleware │
│ (Authentication, Validation, │
│ Rate Limiting, Logging) │
└──────────────┬──────────────────────┘
│
┌──────────────▼──────────────────────┐
│ Controllers │
│ (Request handling, Response │
│ formatting) │
└──────────────┬──────────────────────┘
│
┌──────────────▼──────────────────────┐
│ Services │
│ (Business logic, Database │
│ operations, Caching) │
└──────────────┬──────────────────────┘
│
┌──────────────▼──────────────────────┐
│ Models (Mongoose) │
│ (Database schemas, │
│ Validation) │
└──────────────┬──────────────────────┘
│
┌──────────────▼──────────────────────┐
│ MongoDB Database │
└───────────────────────── ────────────┘
Cache Layer (Redis)
┌─────────────────────────────────────┐
│ Caching Service │
│ - Authentication cache │
│ - Query result cache │
│ - Rate limiting │
└─────────────────────────────────────┘
Queue System (Bull)
┌─────────────────────────────────────┐
│ Background Jobs │
│ - Email sending │
│ - Data processing │
└─────────────────────────────────────┘
Directory Structure
express-backend-ts/
├── bin/ # CLI tools and scripts
│ ├── cli # Main CLI entry point
│ ├── script/ # Generation scripts
│ └── templates.js # Code templates
├── configs/ # Configuration files
│ ├── app.config.ts # App-wide configuration
│ ├── database.config.ts # MongoDB configuration
│ ├── redis.config.ts # Redis configuration
│ └── response.config.ts # Response formatting
├── docs/ # API documentation
│ ├── swagger.ts # Swagger configuration
│ └── routes/ # Route documentation
├── routes/ # Route definitions
│ ├── routes.ts # Main route registry
│ ├── admin/ # Admin routes
│ ├── app/ # Application routes
│ └── auth.route.ts # Authentication routes
├── src/ # Source code
│ ├── controllers/ # Request handlers
│ │ ├── admin/
│ │ ├── app/