# sonimonish00/crud-x architecture

> Architecture diagram of the GitHub repository sonimonish00/crud-x, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sonimonish00/crud-x
- Repository: https://github.com/sonimonish00/crud-x

## Overview

##### Main Components

a. Client-Side (Frontend):
- React Application Layer
- Components structure (core, user, post)
- Redux state management
- Navigation/Routing
- Services/API calls
- Asset management

b. Server-Side (Backend):
- Express.js Application Layer
- API Routes (v1)
- Controllers
- Services
- Models
- Middleware layers
- Validation layer
- Error handling

c. Database:
- MongoDB (with future expansion to other databases)
- Mongoose ODM

d. External Services:
- Authentication providers (JWT, Google OAuth 2.0)
- Email service (SMTP)
- Logging services

##### Component Relationships and Flow

**[Client Layer] ←→ [API Gateway/Routes] ←→ [Controllers] ←→ [Services] ←→ [Models] ←→ [Database]**

##### Specific Implementation Details

Specialized sections for:
- Authentication flow (JWT + Google OAuth)
- Error handling middleware
- Validation pipeline
- Logging system
- API documentation (Swagger)

##### Architectural Patterns to Highlight

Key architectural elements:
**Client Side (React):**
**[Components] → [Services] → [API Calls]**
- ↑
- [Redux Store]

**Server Side (Express):**
**[Routes] → [Middleware] → [Controllers] → [Services] → [Models]**
- ↓
- [Error Handling]
- ↓
- [Response]

##### Cross-Cutting Concerns

Horizontal layers for:
- Security (auth middleware)
- Logging (winston/morgan)
- Validation (Joi)
- Error handling

##### Deployment Flow

A section showing:
**[Local Development] → [CI/CD Pipeline] → [Production Deployment]**
- (Render.com + MongoDB Atlas)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE[React Application]:::frontend
        COMP[Components]:::frontend
        REDUX[Redux Store]:::frontend
        FSERV[Frontend Services]:::frontend
        
        FE --> COMP
        COMP --> REDUX
        COMP --> FSERV
    end

    subgraph API_Gateway
        ROUTES[API Routes v1]:::api
        VAL[Validation Layer]:::middleware
        RATELIMIT[Rate Limiter]:::security
        
        ROUTES --> VAL
        ROUTES --> RATELIMIT
    end

    subgraph Core_Application
        CTRL[Controllers]:::controller
        SERV[Services Layer]:::service
        AUTH[Authentication System]:::security
        TOKEN[Token Management]:::security
        ROLES[Role Management]:::security
        EMAIL[Email Service]:::service
    end

    subgraph Data_Layer
        MOD[Database Models]:::model
        DB[(MongoDB)]:::database
    end

    subgraph Cross_Cutting
        LOG[Logging System]:::utility
        ERR[Error Handler]:::utility
        DOCS[API Documentation]:::utility
    end

    FSERV --> ROUTES
    ROUTES --> CTRL
    CTRL --> SERV
    SERV --> MOD
    MOD --> DB
    
    CTRL --> AUTH
    AUTH --> TOKEN
    AUTH --> ROLES
    SERV --> EMAIL
    
    VAL --> ERR
    RATELIMIT --> ERR
    CTRL --> ERR
    
    ROUTES --> LOG
    CTRL --> LOG
    SERV --> LOG

    %% Click Events
    click FE "https://github.com/sonimonish00/CRUD-X/blob/main/client/src/App.js"
    click ROUTES "https://github.com/sonimonish00/CRUD-X/tree/main/server/app/routes/v1"
    click CTRL "https://github.com/sonimonish00/CRUD-X/tree/main/server/app/controllers"
    click SERV "https://github.com/sonimonish00/CRUD-X/tree/main/server/app/services"
    click MOD "https://github.com/sonimonish00/CRUD-X/tree/main/server/app/models"
    click AUTH "https://github.com/sonimonish00/CRUD-X/blob/main/server/app/services/auth.service.js"
    click VAL "https://github.com/sonimonish00/CRUD-X/tree/main/server/app/validations"
    click ERR "https://github.com/sonimonish00/CRUD-X/blob/main/server/app/middlewares/errorHandler.middleware.js"
    click LOG "https://github.com/sonimonish00/CRUD-X/blob/main/server/app/config/logger.js"
    click EMAIL "https://github.com/sonimonish00/CRUD-X/blob/main/server/app/services/email.service.js"
    click DOCS "https://github.com/sonimonish00/CRUD-X/tree/main/server/app/docs"
    click RATELIMIT "https://github.com/sonimonish00/CRUD-X/blob/main/server/app/middlewares/rateLimiter.middleware.js"
    click TOKEN "https://github.com/sonimonish00/CRUD-X/blob/main/server/app/services/tokenAuth.service.js"
    click ROLES "https://github.com/sonimonish00/CRUD-X/blob/main/server/app/config/roles.js"

    %% Styling
    classDef frontend fill:#2196F3,color:white
    classDef api fill:#4CAF50,color:white
    classDef controller fill:#FF9800,color:white
    classDef service fill:#FFC107,color:black
    classDef model fill:#9C27B0,color:white
    classDef database fill:#673AB7,color:white
    classDef security fill:#f44336,color:white
    classDef middleware fill:#795548,color:white
    classDef utility fill:#607D8B,color:white

    %% Legend
    subgraph Legend
        L1[Frontend]:::frontend
        L2[API]:::api
        L3[Controller]:::controller
        L4[Service]:::service
        L5[Model]:::model
        L6[Database]:::database
        L7[Security]:::security
        L8[Middleware]:::middleware
        L9[Utility]:::utility
    end
```
