How mrvalraven/greendash-core works
Project Type and Purpose
• This is a backend API server built on Node.js/TypeScript using Express (or a similar HTTP framework) and Drizzle ORM for SQL migrations/queries.
• Key features:
• Authentication module (login, signup, JWT)
• Mail module (sending transactional emails)
• AI module (calling external AI service)
• Database layer wired via Drizzle and raw SQL migrations
High‐Level Architectural Overview
a. Client / Consumer
b. HTTP Server (Express app)
c. Routing & Middlewares
d. Feature Modules (Authentication, Mail, AI)
e. Data Access Layer (DB schemas, Drizzle ORM)
f. External Services (SMTP/Email provider, AI API)
g. Relational Database
Detailed Component Breakdown
• HTTP Server
• src/app.ts – initializes Express, loads middleware, mounts routes
• routes.ts – defines route‐to‐controller mappings
• Middlewares
• validationMiddleware.ts – request payload validation
• authMiddleware.ts – JWT/session validation & user extraction
• Feature Modules (each under src/modules/*)
• Controllers (e.g., authentication.controller.ts)
• Config & Constants (e.g., authentication.config.ts, mail.constants.ts)
• Service/Methods Layers (e.g., authentication.methods.ts, mail.service.ts)
• Utils & Types
• Database Layer
• drizzle.config.ts – ORM configuration, connection settings
• drizzle/*.sql – raw migration scripts
• src/db/index.ts – DB connection factory
• src/db/schemas/*.ts – table schemas and helpers
• External Integrations
• Mail provider (SMTP or 3rd‐party SDK)
• AI provider (OpenAI, etc.)
Relationships & Data Flow
1. Client → HTTP Server (TCP/HTTP)
2. HTTP Server → Validation Middleware → Auth Middleware
3. Router → Specific Module Controller
4. Controller → Service/Method Layer
5. Service → Data Access Layer (Drizzle ORM / raw SQL) → Database
6. Service → External API (Mail or AI)
7. Service → Controller → HTTP Response → Client
Architectural Patterns & Principles
• Layered (Onion) Architecture: clear separation between transport, controllers, services, repositories, and external integrations.
• Modular Monolith: each feature lives in its own directory under src/modules.
• Dependency Injection (via config imports) for swapping mocks, environments, or providers.
• Convention over Configuration: migration files in drizzle/, schema definitions under src/db/schemas.
Final Checklist
• [ ] Group feature modules together, showing intra‐module layering
• [ ] Show DB migrations vs. runtime schema layer