# oustaa/kousta-cli architecture

> Architecture diagram of the GitHub repository oustaa/kousta-cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/oustaa/kousta-cli
- Repository: https://github.com/oustaa/kousta-cli

## Overview

##### Main Components

A. CLI Core Components:
- Command Parser/Router
- Project Generator
- Resource Generators
- Template Engine

B. Project Template Structure:
- Express Application Core
- Database Adapters (MongoDB/MySQL)
- Authentication Module
- Middleware Layer
- Resource Layer

**Layer 1: CLI Interface Layer**
**Layer 2: Generator Layer**
**Layer 3: Output Project Layer**

##### Specific Component Details

A. CLI Interface Layer (Top):
- To command handlers:
- create-project
- make:controller
- make:model
- make:request
- make:resource
- make:http-group

B. Generator Layer (Middle):
- Template Engine (Central component)
- Asset Manager (connecting to assets/ directory)
- Project Scaffolder
- Database Configuration Generator
- Authentication Generator

C. Output Project Layer (Bottom):
- Express Application Structure
- Database Layer (with two variants: MongoDB/MySQL)
- Middleware Components
- Resource Components
- Utils & Helpers

##### Important Details to Highlight

A. Template System:
- How assets/ directory templates are processed
- Flow from template to generated code

B. Database Flexibility:
- Dual database support (MongoDB/MySQL)
- How database configurations are generated

C. Authentication Module:
- As an optional component
- Integration points with the main application

##### Additional Elements

- Version information
- Notes about extensibility points
- Configuration file locations

##### Key Relationships to Emphasize

- CLI commands → Template Engine
- Template Engine → Output Project Structure
- Database Adapters → Project Configuration
- Authentication → Middleware Layer

##### Technical Stack Indicators

Technology badges or labels for:
- Node.js
- Express
- MongoDB/Mongoose
- MySQL/Sequelize
- TypeScript
- Joi

- Layered architecture representation
- Clear text labels
- Export to common formats

Recommended tools:
- Lucidchart
- PlantUML

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph CLI_Layer
        CLI[CLI Entry Point]:::cli
        CMD_PROJ[Create Project]:::command
        CMD_CTRL[Make Controller]:::command
        CMD_MOD[Make Model]:::command
        CMD_REQ[Make Request]:::command
        CMD_RES[Make Resource]:::command
        CMD_HTTP[Make HTTP Group]:::command
    end

    subgraph Generator_Layer
        TEMP[Template Engine]:::generator
        PROJ_GEN[Project Generator]:::generator
        DEP_INST[Dependencies Installer]:::generator
        ENV_SET[Environment Setup]:::generator
        ASSET_MGR[Asset Manager]:::generator
    end

    subgraph Output_Project_Layer
        APP[Main App]:::app
        
        subgraph Database
            DB_CFG[Database Config]:::database
            DB_MONGO[MongoDB Adapter]:::database
            DB_MYSQL[MySQL Adapter]:::database
        end
        
        subgraph Auth
            AUTH_CTRL[Auth Controller]:::auth
            AUTH_MODEL[User Model]:::auth
            AUTH_MID[Auth Middleware]:::auth
        end
        
        subgraph Middleware
            ERR_MID[Error Middleware]:::middleware
            VAL_MID[Validation Middleware]:::middleware
        end
        
        subgraph Resources
            RES_TYPES[Resource Types]:::resource
            CTRL_INT[Controller Interface]:::resource
        end
        
        subgraph Utils
            RESP[Response Handler]:::util
            LOG[Logger]:::util
            HELP[Helpers]:::util
        end
    end

    %% CLI Layer Connections
    CLI --> CMD_PROJ & CMD_CTRL & CMD_MOD & CMD_REQ & CMD_RES & CMD_HTTP
    
    %% Generator Layer Connections
    CMD_PROJ --> PROJ_GEN
    CMD_CTRL & CMD_MOD & CMD_REQ & CMD_RES & CMD_HTTP --> TEMP
    PROJ_GEN --> DEP_INST & ENV_SET
    TEMP --> ASSET_MGR
    
    %% Output Project Connections
    PROJ_GEN --> APP
    APP --> DB_CFG
    DB_CFG --> DB_MONGO & DB_MYSQL
    APP --> AUTH_CTRL & AUTH_MODEL
    APP --> ERR_MID & VAL_MID
    APP --> RES_TYPES & CTRL_INT
    APP --> RESP & LOG & HELP

    %% Click Events
    click CLI "https://github.com/Oustaa/kousta-cli/blob/main/index.js"
    click CMD_CTRL "https://github.com/Oustaa/kousta-cli/blob/main/utils/make/createController.js"
    click CMD_MOD "https://github.com/Oustaa/kousta-cli/blob/main/utils/make/createModel.js"
    click CMD_REQ "https://github.com/Oustaa/kousta-cli/blob/main/utils/make/createRequest.js"
    click CMD_RES "https://github.com/Oustaa/kousta-cli/blob/main/utils/make/createResource.js"
    click CMD_HTTP "https://github.com/Oustaa/kousta-cli/blob/main/utils/make/createHttp.js"
    click PROJ_GEN "https://github.com/Oustaa/kousta-cli/blob/main/utils/initProject.js"
    click DEP_INST "https://github.com/Oustaa/kousta-cli/blob/main/utils/installDependencies.js"
    click ENV_SET "https://github.com/Oustaa/kousta-cli/blob/main/utils/populateenv.js"
    click DB_CFG "https://github.com/Oustaa/kousta-cli/blob/main/project/src/database/config.ts"
    click AUTH_CTRL "https://github.com/Oustaa/kousta-cli/blob/main/assets/mysql/auth/AuthController.txt"
    click AUTH_MODEL "https://github.com/Oustaa/kousta-cli/blob/main/assets/mysql/auth/UserModel.txt"
    click AUTH_MID "https://github.com/Oustaa/kousta-cli/blob/main/project/src/kousta/@middlewares/auth-middleware.ts"
    click ERR_MID "https://github.com/Oustaa/kousta-cli/blob/main/project/src/App/Http/Middleware/error.middleware.ts"
    click VAL_MID "https://github.com/Oustaa/kousta-cli/blob/main/project/src/App/Http/Middleware/validation.middleware.ts"
    click RES_TYPES "https://github.com/Oustaa/kousta-cli/blob/main/project/src/kousta/@types/resourceTypes.ts"
    click CTRL_INT "https://github.com/Oustaa/kousta-cli/blob/main/project/src/utils/interfaces/Controller.interface.ts"
    click APP "https://github.com/Oustaa/kousta-cli/blob/main/project/src/app.ts"
    click RESP "https://github.com/Oustaa/kousta-cli/blob/main/project/src/utils/ResponseHandler.ts"
    click LOG "https://github.com/Oustaa/kousta-cli/blob/main/project/src/utils/Logger.ts"
    click HELP "https://github.com/Oustaa/kousta-cli/tree/main/project/src/kousta/@helpers/"

    %% Styles
    classDef cli fill:#2196F3,stroke:#1565C0,color:white
    classDef command fill:#90CAF9,stroke:#64B5F6,color:black
    classDef generator fill:#4CAF50,stroke:#388E3C,color:white
    classDef database fill:#FF9800,stroke:#F57C00,color:white
    classDef auth fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef middleware fill:#795548,stroke:#5D4037,color:white
    classDef resource fill:#607D8B,stroke:#455A64,color:white
    classDef util fill:#9E9E9E,stroke:#757575,color:white
    classDef app fill:#3F51B5,stroke:#303F9F,color:white
```
