# thangga7/be-csc architecture

> Architecture diagram of the GitHub repository thangga7/be-csc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thangga7/be-csc
- Repository: https://github.com/thangga7/be-csc

## Overview

##### Main Components Identification
The project appears to be a backend service with the following key components:

a) Core Application Layer
- Entry point (index.js)
- Environment configuration (.env)
- Authentication middleware
- Route handlers
- Controllers
- Data models

##### Component Relationships

Following flows:
##### Models → Database (implied from the structure)

**[Client Requests]**
- ↓
**[Route Layer]**
- ↓
**[Auth Middleware]**
- ↓
**[Controllers]**
- ↓
**[Models]**
- ↓
**[Database]**

##### Important Notes

- Keep components grouped by their function (routes together, controllers together, etc.)
- Clear boundaries between different layers
- Notes for any specific business logic or rules
- Version information and main dependencies

Remember to include any external services or dependencies that might be referenced in the .env file, even though they're not directly visible in the file structure.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Legend"
        direction TB
        L1[API Gateway]:::gateway
        L2[Route]:::route
        L3[Controller]:::controller
        L4[(Model)]:::model
        L5{{Middleware}}:::middleware
        L6[Config]:::config
    end

    subgraph "External Layer"
        direction TB
        API[API Gateway]:::gateway
        VercelConfig["Vercel Config"]:::config
        EnvConfig["Environment Config"]:::config
        Entry["Application Entry"]:::config
    end

    subgraph "Routes Layer"
        direction TB
        UserRoutes["User Routes"]:::route
        NewsRoutes["News Routes"]:::route
        NotiRoutes["Notification Routes"]:::route
        ReportRoutes["Report Routes"]:::route
    end

    subgraph "Authentication Layer"
        direction TB
        AuthMiddleware{{Auth Middleware}}:::middleware
    end

    subgraph "Controllers Layer"
        direction TB
        UserController["User Controller"]:::controller
        NewsController["News Controller"]:::controller
        NotiController["Notification Controller"]:::controller
        ReportController["Report Controller"]:::controller
    end

    subgraph "Data Layer"
        direction TB
        UserModel[(User Model)]:::model
        NewsModel[(News Model)]:::model
        NotiModel[(Notification Model)]:::model
        ReportModel[(Report Model)]:::model
    end

    %% Connections
    API --> UserRoutes & NewsRoutes & NotiRoutes & ReportRoutes
    
    UserRoutes & NewsRoutes & NotiRoutes & ReportRoutes --> AuthMiddleware
    AuthMiddleware --> UserController & NewsController & NotiController & ReportController
    
    UserController --> UserModel
    NewsController --> NewsModel
    NotiController --> NotiModel
    ReportController --> ReportModel

    EnvConfig -.-> API
    EnvConfig -.-> AuthMiddleware
    EnvConfig -.-> UserController & NewsController & NotiController & ReportController
    
    %% Styling
    classDef gateway fill:#87CEEB
    classDef route fill:#90EE90
    classDef controller fill:#FFD700
    classDef model fill:#DDA0DD
    classDef middleware fill:#FF6B6B
    classDef config fill:#D3D3D3

    %% Click Events
    click Entry "https://github.com/ThanggA7/BE-CSC/blob/main/src/index.js"
    click EnvConfig "https://github.com/ThanggA7/BE-CSC/blob/main/src/.env"
    click VercelConfig "https://github.com/ThanggA7/BE-CSC/blob/main/vercel.json"
    click AuthMiddleware "https://github.com/ThanggA7/BE-CSC/blob/main/src/middleware/auth.js"
    click UserRoutes "https://github.com/ThanggA7/BE-CSC/blob/main/src/routes/userRoutes.js"
    click NewsRoutes "https://github.com/ThanggA7/BE-CSC/blob/main/src/routes/newsRoute.js"
    click NotiRoutes "https://github.com/ThanggA7/BE-CSC/blob/main/src/routes/notiRoutes.js"
    click ReportRoutes "https://github.com/ThanggA7/BE-CSC/blob/main/src/routes/reportRoutes.js"
    click UserController "https://github.com/ThanggA7/BE-CSC/blob/main/src/controllers/userController.js"
    click NewsController "https://github.com/ThanggA7/BE-CSC/blob/main/src/controllers/NewsController.js"
    click NotiController "https://github.com/ThanggA7/BE-CSC/blob/main/src/controllers/notiController.js"
    click ReportController "https://github.com/ThanggA7/BE-CSC/blob/main/src/controllers/reportController.js"
    click UserModel "https://github.com/ThanggA7/BE-CSC/blob/main/src/models/userModel.js"
    click NewsModel "https://github.com/ThanggA7/BE-CSC/blob/main/src/models/News.js"
    click NotiModel "https://github.com/ThanggA7/BE-CSC/blob/main/src/models/notiModel.js"
    click ReportModel "https://github.com/ThanggA7/BE-CSC/blob/main/src/models/Report.js"
```
