# mightyanubhav/hirebuddy-backend architecture

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

- Interactive diagram: https://gitdiagram.com/mightyanubhav/hirebuddy-backend
- Repository: https://github.com/mightyanubhav/hirebuddy-backend

## Overview

##### Project type and purpose
- It exposes RESTful endpoints for user, buddy, customer, admin, payment, and chatbot interactions.
- It persists data in a database (likely MongoDB or SQL via db/db.js), caches or session data in Redis (db/redis.js), uses Cloudinary for media uploads, and has mailing and real-time socket services.

##### File structure
- index.js: the application’s entry point where Express is configured and started.
- db/: contains database connection modules (db.js for primary data store, redis.js for caching/session).
- data/: a static JSON file (hirebuddyData.json) used perhaps for seeding or local lookups.
- middlewares/: auth.js (JWT or session auth), roles.js (RBAC enforcement).
- models/: booking.model.js, message.model.js, user.model.js (ORM/ODM schemas).
- routes/: route modules grouped by domain: adminRoutes.js, buddyRoutes.js, customerRoutes.js, chatbotRoute.js, payment.js, userRoutes.js.
- services/: auxiliary layers—editProfilesCloudinary.js (media uploads), mailer.js (SMTP or transactional email), socket.js (WebSocket logic).
- test-clients/: simple scripts simulating buddy and customer API interactions.

##### README for additional insights
- The README only contains a demo link; architectural details are not documented here.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Frontend Clients"]:::client
    subgraph "Integration Test Scripts"
        BS["Buddy Script"]:::client
        CS["Customer Script"]:::client
    end

    Client -->|HTTP| API
    BS -->|HTTP| API
    CS -->|HTTP| API

    API["Express API Server"]:::server

    subgraph "Middleware Layer"
        Auth["Auth Middleware"]:::middleware
        Roles["Roles Middleware"]:::middleware
    end

    API --> Auth --> Roles

    subgraph "Route Handlers"
        UR["User Routes"]:::route
        BR["Buddy Routes"]:::route
        CR["Customer Routes"]:::route
        AR["Admin Routes"]:::route
        PR["Payment Routes"]:::route
        ChatR["Chatbot Routes"]:::route
    end

    Roles --> UR
    Roles --> BR
    Roles --> CR
    Roles --> AR
    Roles --> PR
    Roles --> ChatR

    subgraph "Services"
        Cloudinary["Cloudinary Service"]:::external
        Mail["Mail Service"]:::external
        WS["WebSocket Service"]:::service
    end

    subgraph "Models"
        UModel["User Model"]:::model
        BModel["Booking Model"]:::model
        MModel["Message Model"]:::model
    end

    UR --> UModel
    BR --> BModel
    ChatR --> MModel
    CR --> UModel
    AR --> UModel
    PR --> UModel

    UR --> Cloudinary
    BR --> Cloudinary
    CR --> Cloudinary
    AR --> Cloudinary
    PR --> Cloudinary
    ChatR --> WS
    UR --> Mail
    BR --> Mail
    CR --> Mail
    AR --> Mail
    PR --> Mail

    subgraph "Persistence"
        DB["Database (Primary Data Store)"]:::database
        Redis["Redis (Cache/Session)"]:::database
        Seed["Static Data"]:::data
    end

    UModel --> DB
    BModel --> DB
    MModel --> DB
    UR --> Redis
    BR --> Redis
    CR --> Redis
    AR --> Redis
    PR --> Redis
    ChatR --> DB
    Seed --> DB

    API --> Cloudinary
    API --> Mail
    API --> WS
    PR -->|calls| PG["Payment Gateway"]:::external
    Client <-->|WebSocket| WS

    classDef client fill:#f9f,stroke:#333,stroke-width:1px
    classDef server fill:#bbf,stroke:#333,stroke-width:1px
    classDef middleware fill:#fcf,stroke:#333,stroke-width:1px
    classDef route fill:#aff,stroke:#333,stroke-width:1px
    classDef service fill:#bfb,stroke:#333,stroke-width:1px
    classDef external fill:#ffc,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef model fill:#fbb,stroke:#333,stroke-width:1px
    classDef database fill:#fbf,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
    classDef data fill:#ddd,stroke:#333,stroke-width:1px

    click API "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/index.js"
    click Auth "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/middlewares/auth.js"
    click Roles "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/middlewares/roles.js"
    click DB "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/db/db.js"
    click Redis "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/db/redis.js"
    click Seed "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/data/hirebuddyData.json"
    click UModel "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/models/user.model.js"
    click BModel "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/models/booking.model.js"
    click MModel "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/models/message.model.js"
    click UR "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/routes/userRoutes.js"
    click BR "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/routes/buddyRoutes.js"
    click CR "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/routes/customerRoutes.js"
    click AR "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/routes/adminRoutes.js"
    click PR "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/routes/payment.js"
    click ChatR "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/routes/chatbotRoute.js"
    click Cloudinary "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/services/editProfilesCloudinary.js"
    click Mail "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/services/mailer.js"
    click WS "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/services/socket.js"
    click BS "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/test-clients/buddy.js"
    click CS "https://github.com/mightyanubhav/hirebuddy-backend/blob/main/test-clients/customer.js"
```
