# qais-hweidi/rent-it-out architecture

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

- Interactive diagram: https://gitdiagram.com/qais-hweidi/rent-it-out
- Repository: https://github.com/qais-hweidi/rent-it-out

## Overview

##### Main Components

A. Core Services Layer:
- User Management Service (userController)
- Item Management Service (itemController)
- Transaction Service (transactionController)
- Review System (reviewController)
- Dispute Resolution Service (DisputeController)
- Category Management (categoryController)
- Delivery Management (deliveryOptionController)
- Security Service (securityController)
- Admin Service (AdminController)

B. Database Layer:
- MySQL Database (as mentioned in technologies)
- Sequelize ORM Layer
- All models should be represented (User, Item, Transaction, Review, Dispute, etc.)

C. Middleware Layer:
- Error Handling Middleware
- Authentication/Authorization
- Request Validation

D. External Services:
- Currency Service (as indicated by currencyService.js)
- Apache Server (XAMPP)

**[Client Layer (Not in repo but should be shown)]**
- ↓
**[API Routes Layer]**
- ↓
**[Controllers Layer]**
- ↓
**[Services Layer]**
- ↓
**[Models Layer (Sequelize ORM)]**
- ↓
**[Database Layer (MySQL)]**

##### Key Relationships to Highlight

- How the routes connect to their respective controllers
- Relationship between controllers and models
- Demonstrate the flow of authentication and error handling
- How the admin system interacts with other components
- External service integrations

##### Additional Elements

- Database relationships between models
- Error handling pathways
- Test coverage areas

##### Technical Details

- Node.js runtime environment
- Sequelize ORM interactions
- MySQL database connections
- Jest testing framework coverage
- API endpoints grouping

Remember to include the technologies mentioned in the README (Node.js, MySQL, Sequelize, Jest) and show how they interact within the system architecture.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        CL[Client Applications]
    end

    subgraph API_Routes
        AR[API Gateway]
        UR["User Routes"]:::route
        IR["Item Routes"]:::route
        TR["Transaction Routes"]:::route
        RR["Review Routes"]:::route
        DR["Dispute Routes"]:::route
        CR["Category Routes"]:::route
        DOR["Delivery Routes"]:::route
        SR["Security Routes"]:::route
        ADR["Admin Routes"]:::route
        CUR["Currency Routes"]:::route
    end

    subgraph Controllers
        UC["User Controller"]:::controller
        IC["Item Controller"]:::controller
        TC["Transaction Controller"]:::controller
        RC["Review Controller"]:::controller
        DC["Dispute Controller"]:::controller
        CC["Category Controller"]:::controller
        DOC["Delivery Controller"]:::controller
        SC["Security Controller"]:::controller
        AC["Admin Controller"]:::controller
    end

    subgraph Services
        CUS["Currency Service"]:::service
    end

    subgraph Middleware
        EH["Error Handler"]:::middleware
        Auth["Authentication"]:::middleware
        Val["Request Validation"]:::middleware
    end

    subgraph Models
        MI["Model Index"]:::model
        UM["User Model"]:::model
        IM["Item Model"]:::model
        TM["Transaction Model"]:::model
        RM["Review Model"]:::model
        DM["Dispute Model"]:::model
        CM["Category Model"]:::model
        DOM["Delivery Model"]:::model
        SM["Security Model"]:::model
    end

    subgraph Database
        DB[(MySQL Database)]
        DBC["Database Config"]:::config
    end

    %% Connections
    CL --> AR
    AR --> |Routes| UR & IR & TR & RR & DR & CR & DOR & SR & ADR & CUR

    UR --> UC
    IR --> IC
    TR --> TC
    RR --> RC
    DR --> DC
    CR --> CC
    DOR --> DOC
    SR --> SC
    ADR --> AC
    CUR --> CUS

    UC & IC & TC & RC & DC & CC & DOC & SC & AC --> Auth
    Auth --> EH
    Val --> EH

    UC --> UM
    IC --> IM
    TC --> TM
    RC --> RM
    DC --> DM
    CC --> CM
    DOC --> DOM
    SC --> SM

    UM & IM & TM & RM & DM & CM & DOM & SM --> MI
    MI --> DBC
    DBC --> DB

    %% Click Events
    click UC "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/controllers/userController.js"
    click IC "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/controllers/itemController.js"
    click TC "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/controllers/transactionController.js"
    click RC "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/controllers/reviewController.js"
    click DC "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/controllers/DisputeController.js"
    click CC "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/controllers/categoryController.js"
    click DOC "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/controllers/deliveryOptionController.js"
    click SC "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/controllers/securityController.js"
    click AC "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/controllers/AdminController.js"
    
    click UM "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/models/userModel.js"
    click IM "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/models/itemModel.js"
    click TM "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/models/transactionModel.js"
    click RM "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/models/reviews.js"
    click DM "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/models/Dispute.js"
    click CM "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/models/categoryModel.js"
    click DOM "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/models/deliveryOption.js"
    click SM "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/models/securityModel.js"
    click MI "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/models/index.js"
    
    click UR "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/routes/userRouter.js"
    click IR "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/routes/itemRouter.js"
    click TR "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/routes/transactionRouter.js"
    click RR "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/routes/reviews.js"
    click DR "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/routes/disputeRoutes.js"
    click CR "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/routes/categoryRouter.js"
    click DOR "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/routes/deliveryOptionRoutes.js"
    click SR "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/routes/securityRouter.js"
    click ADR "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/routes/AdminRouter.js"
    click CUR "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/routes/currencyRouter.js"
    
    click DBC "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/config/dbConfig.js"
    click EH "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/middleware/errorHandler.js"
    click CUS "https://github.com/Qais-Hweidi/Rent-It-Out/blob/main/services/currencyService.js"

    %% Styles
    classDef controller fill:#2374ab
    classDef model fill:#57a773
    classDef route fill:#deba6f
    classDef service fill:#fe7f2d
    classDef middleware fill:#fcca46
    classDef config fill:#619b8a

    %% Legend
    subgraph Legend
        L1[Controllers]:::controller
        L2[Models]:::model
        L3[Routes]:::route
        L4[Services]:::service
        L5[Middleware]:::middleware
        L6[Configuration]:::config
    end
```
