# julien1100/stockify-back architecture

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

- Interactive diagram: https://gitdiagram.com/julien1100/stockify-back
- Repository: https://github.com/julien1100/stockify-back

## Overview

##### Main System Components

A. API Layer
- Express.js Server (Entry Point)
- Routes Layer (User and Product routes)
- Controllers Layer (Business Logic)
- Authentication Middleware
- Database Layer (MongoDB with Mongoose)

**┌─────────────────────────────────────────────┐**
- Client Requests              │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Express.js Server              │
- (src/index.js)                │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Routes                    │
- (userRoute.js and productRoute.js)      │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Auth Middleware                │
- (auth.js)                     │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Controllers                   │
- (userController.js & productController.js) │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Models                     │
- (userModel.js & productModel.js)         │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- MongoDB Database               │
- ┘

##### Important Elements to Highlight

a. Authentication Flow:
- JWT authentication middleware interaction
- Secure vs. public routes

b. Data Flow:
- Request/Response cycle
- Database operations
- Error handling paths

##### Technical Stack Indicators

- Express.js for API framework
- MongoDB for database
- Mongoose for ODM
- JWT for authentication
- Bcrypt for password hashing

##### Specific Implementation Details

- The MVC-like architecture (Routes → Controllers → Models)
- The middleware pipeline
- The separation of user and product domains
- Security layers (authentication, data validation)

##### Deployment Information

A small section showing:
- Vercel deployment configuration
- Environment variables handling
- API endpoints grouping

Remember to:
- Use consistent styling
- Version information
- Document all external service connections

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        CR[Client Requests]
    end

    subgraph Server
        EX[Express.js Server]:::server
        click EX "https://github.com/Julien1100/stockify-back/blob/develop/src/index.js"
    end

    subgraph Routes
        UR["User Routes"]:::route
        PR["Product Routes"]:::route
        click UR "https://github.com/Julien1100/stockify-back/blob/develop/src/routes/userRoute.js"
        click PR "https://github.com/Julien1100/stockify-back/blob/develop/src/routes/productRoute.js"
    end

    subgraph Middleware
        AUTH["JWT Authentication"]:::middleware
        click AUTH "https://github.com/Julien1100/stockify-back/blob/develop/src/middlewares/auth.js"
        CORS["CORS Middleware"]:::middleware
        ERR["Error Handler"]:::middleware
    end

    subgraph Controllers
        UC["User Controller"]:::controller
        PC["Product Controller"]:::controller
        click UC "https://github.com/Julien1100/stockify-back/blob/develop/src/controllers/userController.js"
        click PC "https://github.com/Julien1100/stockify-back/blob/develop/src/controllers/productController.js"
    end

    subgraph Models
        UM["User Model"]:::model
        PM["Product Model"]:::model
        click UM "https://github.com/Julien1100/stockify-back/blob/develop/src/models/userModel.js"
        click PM "https://github.com/Julien1100/stockify-back/blob/develop/src/models/productModel.js"
    end

    subgraph Database
        DB[(MongoDB)]:::database
    end

    subgraph Config
        ENV[".env Configuration"]:::config
        VER["Vercel Config"]:::config
        click ENV "https://github.com/Julien1100/stockify-back/blob/develop/exemple.env"
        click VER "https://github.com/Julien1100/stockify-back/blob/develop/vercel.json"
    end

    CR --> EX
    EX --> CORS
    CORS --> UR & PR
    UR & PR --> AUTH
    AUTH --> UC & PC
    UC & PC --> UM & PM
    UM & PM --> DB
    ERR -.-> EX
    ENV -.-> EX
    VER -.-> EX

    classDef server fill:#90EE90,stroke:#333,stroke-width:2px
    classDef route fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef middleware fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef controller fill:#FFD700,stroke:#333,stroke-width:2px
    classDef model fill:#FFA500,stroke:#333,stroke-width:2px
    classDef database fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:2px

    subgraph Legend
        L1[Server]:::server
        L2[Routes]:::route
        L3[Middleware]:::middleware
        L4[Controllers]:::controller
        L5[Models]:::model
        L6[Database]:::database
        L7[Config]:::config
    end
```
