# sambaba097/easyservice-backend architecture

> Architecture diagram of the GitHub repository sambaba097/easyservice-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sambaba097/easyservice-backend
- Repository: https://github.com/sambaba097/easyservice-backend

## Overview

##### Project type and purpose
- Easy-Service is a Node.js/Express monolithic REST-API providing service management features: scheduling (planification), invoicing (facturation), customer follow-up, and Odoo ERP integration.
- The README emphasizes a modular ecosystem and integration capabilities (e.g., Odoo, Cloudinary, email).

##### File structure
- Top-level entry point: server.js
- Configuration: config/*.js (cloudinary, email, multer)
- HTTP interface: routes/*.js → controllers/*.js
- Business logic & external integrations: services/ (odooService.js), utils/ (odooAuth, odoo.js)
- Data layer: models/*.js (Mongoose schemas: User, Demande, Facture, etc.)
- Cross-cutting concerns: middleware/*.js (auth, validation)
- Batch jobs / scripts: scripts/syncServices.js, createFacture.js, updateOdooIds.js
- Dependencies/config: package.json, .gitignore

##### README for additional insights
- Must integrate with Odoo ERP and support modular additions.

##### Detail
- Every major folder as its own subcomponent
- How scripts reuse the same service & model layers
- Odoo integration path distinctly (auth → service → remote API)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Entry Point"
        Server["server.js"]:::entry
    end

    subgraph "Configuration"
        Cloudinary["config/cloudinary.js"]:::config
        EmailCfg["config/email.js"]:::config
        Multer["config/multer.js"]:::config
    end

    subgraph "API Layer"
        subgraph "Routes"
            AuthR["authRoutes.js"]:::api
            AvisR["avisRoutes.js"]:::api
            CategorieR["categorieRoutes.js"]:::api
            DashboardR["dashboardRoutes.js"]:::api
            DemandeR["demandeRoutes.js"]:::api
            FactureR["factureRoutes.js"]:::api
            MessageR["messageRoutes.js"]:::api
            PlanificationR["planificationRoutes.js"]:::api
            SearchR["searchRoutes.js"]:::api
            ServiceR["serviceRoutes.js"]:::api
        end
        subgraph "Middleware"
            AuthM["authMiddleware.js"]:::api
            ValidationM["validationMiddleware.js"]:::api
        end
        subgraph "Controllers"
            AuthC["authController.js"]:::api
            AvisC["avisController.js"]:::api
            CategorieC["categorieController.js"]:::api
            DemandeC["demandeController.js"]:::api
            FactureC["factureController.js"]:::api
            MessageC["messageController.js"]:::api
            PlanifC["planification.controller.js"]:::api
            ServiceC["serviceController.js"]:::api
            TechnicienC["technicienController.js"]:::api
        end
    end

    subgraph "Service Layer"
        OdooService["services/odooService.js"]:::service
        OdooAuth["utils/odooAuth.js"]:::service
        OdooClient["utils/odoo.js"]:::service
        EmailSvc["Email Service"]:::service
        UploadSvc["Upload Service"]:::service
    end

    subgraph "Data Layer"
        User["models/User.js"]:::data
        Technicien["models/Technicien.js"]:::data
        Compteur["models/Compteur.js"]:::data
        CategorieM["models/categorie.js"]:::data
        ServiceM["models/Service.js"]:::data
        PlanificationM["models/Planification.js"]:::data
        DemandeM["models/Demande.js"]:::data
        FactureM["models/Facture.js"]:::data
        MessageM["models/Message.js"]:::data
        AvisM["models/Avis.js"]:::data
        NumeroFacture["models/numeroFacture.js"]:::data
        MongoDB["MongoDB"]:::database
    end

    subgraph "External Systems"
        OdooERP["Odoo ERP"]:::external
        CloudinaryExt["Cloudinary"]:::external
        SMTP["SMTP Email"]:::external
    end

    subgraph "Batch & Sync Scripts"
        Sync["scripts/syncServices.js"]:::scripts
        CreateFact["createFacture.js"]:::scripts
        UpdateOdoo["updateOdooIds.js"]:::scripts
    end

    %% Connections
    Server --> Cloudinary
    Server --> EmailCfg
    Server --> Multer
    Server --> AuthR
    AuthR --> AuthM
    AvisR --> ValidationM
    CategorieR --> ValidationM
    DashboardR --> ValidationM
    DemandeR --> ValidationM
    FactureR --> ValidationM
    MessageR --> ValidationM
    PlanificationR --> ValidationM
    SearchR --> ValidationM
    ServiceR --> ValidationM

    AuthM --> AuthC
    ValidationM --> AvisC
    ValidationM --> CategorieC
    ValidationM --> DemandeC
    ValidationM --> FactureC
    ValidationM --> MessageC
    ValidationM --> PlanifC
    ValidationM --> ServiceC
    ValidationM --> TechnicienC
    ValidationM --> DashboardR

    Controllers -->|uses| OdooService
    Controllers -->|sends email| EmailSvc
    Controllers -->|uploads files| UploadSvc
    Controllers -->|CRUD| User & DemandeM & FactureM & MessageM & AvisM & CategorieM & ServiceM & PlanificationM & Technicien & Compteur & NumeroFacture
    OdooService --> OdooAuth --> OdooClient --> OdooERP
    EmailSvc --> SMTP
    UploadSvc --> CloudinaryExt
    User --> MongoDB
    DemandeM --> MongoDB
    FactureM --> MongoDB

    Sync --> OdooService
    Sync --> ServiceM
    CreateFact --> FactureM
    UpdateOdoo --> DemandeM

    %% Click events
    click Server "https://github.com/sambaba097/easyservice-backend/blob/main/server.js"
    click Cloudinary "https://github.com/sambaba097/easyservice-backend/blob/main/config/cloudinary.js"
    click EmailCfg "https://github.com/sambaba097/easyservice-backend/blob/main/config/email.js"
    click Multer "https://github.com/sambaba097/easyservice-backend/blob/main/config/multer.js"
    click AuthR "https://github.com/sambaba097/easyservice-backend/blob/main/routes/authRoutes.js"
    click AvisR "https://github.com/sambaba097/easyservice-backend/blob/main/routes/avisRoutes.js"
    click CategorieR "https://github.com/sambaba097/easyservice-backend/blob/main/routes/categorieRoutes.js"
    click DashboardR "https://github.com/sambaba097/easyservice-backend/blob/main/routes/dashboardRoutes.js"
    click DemandeR "https://github.com/sambaba097/easyservice-backend/blob/main/routes/demandeRoutes.js"
    click FactureR "https://github.com/sambaba097/easyservice-backend/blob/main/routes/factureRoutes.js"
    click MessageR "https://github.com/sambaba097/easyservice-backend/blob/main/routes/messageRoutes.js"
    click PlanificationR "https://github.com/sambaba097/easyservice-backend/blob/main/routes/planificationRoutes.js"
    click SearchR "https://github.com/sambaba097/easyservice-backend/blob/main/routes/searchRoutes.js"
    click ServiceR "https://github.com/sambaba097/easyservice-backend/blob/main/routes/serviceRoutes.js"
    click AuthC "https://github.com/sambaba097/easyservice-backend/blob/main/controllers/authController.js"
    click AvisC "https://github.com/sambaba097/easyservice-backend/blob/main/controllers/avisController.js"
    click CategorieC "https://github.com/sambaba097/easyservice-backend/blob/main/controllers/categorieController.js"
    click DemandeC "https://github.com/sambaba097/easyservice-backend/blob/main/controllers/demandeController.js"
    click FactureC "https://github.com/sambaba097/easyservice-backend/blob/main/controllers/factureController.js"
    click MessageC "https://github.com/sambaba097/easyservice-backend/blob/main/controllers/messageController.js"
    click PlanifC "https://github.com/sambaba097/easyservice-backend/blob/main/controllers/planification.controller.js"
    click ServiceC "https://github.com/sambaba097/easyservice-backend/blob/main/controllers/serviceController.js"
    click TechnicienC "https://github.com/sambaba097/easyservice-backend/blob/main/controllers/technicienController.js"
    click AuthM "https://github.com/sambaba097/easyservice-backend/blob/main/middleware/authMiddleware.js"
    click ValidationM "https://github.com/sambaba097/easyservice-backend/blob/main/middleware/validationMiddleware.js"
    click OdooService "https://github.com/sambaba097/easyservice-backend/blob/main/services/odooService.js"
    click OdooAuth "https://github.com/sambaba097/easyservice-backend/blob/main/utils/odooAuth.js"
    click OdooClient "https://github.com/sambaba097/easyservice-backend/blob/main/utils/odoo.js"
    click User "https://github.com/sambaba097/easyservice-backend/blob/main/models/User.js"
    click Technicien "https://github.com/sambaba097/easyservice-backend/blob/main/models/Technicien.js"
    click Compteur "https://github.com/sambaba097/easyservice-backend/blob/main/models/Compteur.js"
    click CategorieM "https://github.com/sambaba097/easyservice-backend/blob/main/models/categorie.js"
    click ServiceM "https://github.com/sambaba097/easyservice-backend/blob/main/models/Service.js"
    click PlanificationM "https://github.com/sambaba097/easyservice-backend/blob/main/models/Planification.js"
    click DemandeM "https://github.com/sambaba097/easyservice-backend/blob/main/models/Demande.js"
    click FactureM "https://github.com/sambaba097/easyservice-backend/blob/main/models/Facture.js"
    click MessageM "https://github.com/sambaba097/easyservice-backend/blob/main/models/Message.js"
    click AvisM "https://github.com/sambaba097/easyservice-backend/blob/main/models/Avis.js"
    click NumeroFacture "https://github.com/sambaba097/easyservice-backend/blob/main/models/numeroFacture.js"
    click Sync "https://github.com/sambaba097/easyservice-backend/blob/main/scripts/syncServices.js"
    click CreateFact "https://github.com/sambaba097/easyservice-backend/blob/main/createFacture.js"
    click UpdateOdoo "https://github.com/sambaba097/easyservice-backend/blob/main/updateOdooIds.js"

    %% Styles
    classDef entry fill:#f9f,stroke:#333,stroke-width:1px
    classDef config fill:#b3cde0,stroke:#333,stroke-width:1px
    classDef api fill:#6497b1,stroke:#333,stroke-width:1px
    classDef service fill:#b2df8a,stroke:#333,stroke-width:1px
    classDef data fill:#fdae61,stroke:#333,stroke-width:1px
    classDef database fill:#d7191c,stroke:#333,stroke-width:1px
    classDef external fill:#f46d43,stroke:#333,stroke-width:1px
    classDef scripts fill:#8dd3c7,stroke:#333,stroke-width:1px
```
