# realhugn/be-it4409 architecture

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

- Interactive diagram: https://gitdiagram.com/realhugn/be-it4409
- Repository: https://github.com/realhugn/be-it4409

## Overview

##### Project type and purpose
- This is a Node.js / Express RESTful backend service (no GUI) for a housing/rental management system.
- Purpose: expose HTTP APIs for authentication, billing, room/house/owner/renter management, deposits, covenants and services, persisting data in MySQL.

##### File structure
- index.js: application entry point
- configs/: configuration modules (DB credentials, scheduler settings)
- loaders/: bootstrapping logic (app initialization, middleware registration, route mounting)
- middlewares/: request-level filters (e.g. auth)
- routes/: Express route definitions mapping URLs to controllers
- controller/: request handlers orchestrating service calls
- services/: business-logic layer, interfaces between controllers and models
- models/: ORM or query layer, definitions of DB tables (MySQL)
- utils/: reusable helper functions
- db.sql: DDL to create the schema

##### README for additional insights
- Stack: Node.js, Express, MySQL
- Commands: npm run db (launch MySQL container or seed data), npm run dev (start server)
- Postman documentation link available for all endpoints

##### Detailed capture of architectural elements
- “app.js” loader registering middleware and routes
- For each major domain (auth, house, bill, etc.), illustrate one Controller → Service → Model pipeline
- Scheduler as a side process invoking Service methods on a schedule
- Clearly separate read vs. write flows if relevant (GET vs. POST)

## Diagram (Mermaid)

```mermaid
graph TD
    classDef client fill:#f9f,stroke:#333,stroke-width:1px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef middleware fill:#FFA500,stroke:#333,stroke-width:1px
    classDef appLayers fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef db fill:#90EE90,stroke:#333,stroke-width:1px

    Client["Client (HTTP)"]:::client
    Client -->|HTTP Request| ExpressApp["Express App"]:::appLayers

    subgraph "Config & Loaders"
        ConfigIndex["configs/index.js"]:::config
        ConfigDB["configs/db.js"]:::config
        ConfigSchedule["configs/schedule.js"]:::config
        AppLoader["loaders/app.js"]:::config
        Bootstrap["loaders/index.js"]:::config
    end
    ExpressApp --> ConfigIndex
    ExpressApp --> ConfigDB
    ExpressApp --> ConfigSchedule
    ExpressApp --> AppLoader
    ExpressApp --> Bootstrap

    subgraph "Middleware Layer"
        AuthMW["Auth Middleware"]:::middleware
    end
    AppLoader --> AuthMW
    AuthMW --> Router

    subgraph "Routing Layer"
        Router["routes/index.js"]:::appLayers
        AuthRoute["routes/auth.js"]:::appLayers
        HouseRoute["routes/house.js"]:::appLayers
        BillRoute["routes/bill.js"]:::appLayers
        CovenantRoute["routes/covenant.js"]:::appLayers
        DepositRoute["routes/deposit.js"]:::appLayers
        OwnerRoute["routes/owner.js"]:::appLayers
        RenterRoute["routes/renter.js"]:::appLayers
        RoomRoute["routes/room.js"]:::appLayers
        ServiceRoute["routes/service.js"]:::appLayers
    end
    AuthMW --> Router
    Router --> AuthRoute
    Router --> HouseRoute
    Router --> BillRoute
    Router --> CovenantRoute
    Router --> DepositRoute
    Router --> OwnerRoute
    Router --> RenterRoute
    Router --> RoomRoute
    Router --> ServiceRoute

    subgraph "Controller Layer"
        AuthCtrl["controller/auth.js"]:::appLayers
        HouseCtrl["controller/house.js"]:::appLayers
        BillCtrl["controller/bill.js"]:::appLayers
        CovenantCtrl["controller/covenant.js"]:::appLayers
        DepositCtrl["controller/deposit.js"]:::appLayers
        OwnerCtrl["controller/owner.js"]:::appLayers
        RenterCtrl["controller/renter.js"]:::appLayers
        RoomCtrl["controller/room.js"]:::appLayers
        ServiceCtrl["controller/service.js"]:::appLayers
    end
    AuthRoute --> AuthCtrl
    HouseRoute --> HouseCtrl
    BillRoute --> BillCtrl
    CovenantRoute --> CovenantCtrl
    DepositRoute --> DepositCtrl
    OwnerRoute --> OwnerCtrl
    RenterRoute --> RenterCtrl
    RoomRoute --> RoomCtrl
    ServiceRoute --> ServiceCtrl

    subgraph "Service Layer"
        AuthService["services/serviceService.js"]:::appLayers
        HouseService["services/houseService.js"]:::appLayers
        BillService["services/billService.js"]:::appLayers
        CovenantService["services/covenant.js"]:::appLayers
        DepositService["services/depositService.js"]:::appLayers
        OwnerService["services/ownerService.js"]:::appLayers
        RenterService["services/renterService.js"]:::appLayers
        RoomService["services/roomService.js"]:::appLayers
    end
    AuthCtrl --> AuthService
    HouseCtrl --> HouseService
    BillCtrl --> BillService
    CovenantCtrl --> CovenantService
    DepositCtrl --> DepositService
    OwnerCtrl --> OwnerService
    RenterCtrl --> RenterService
    RoomCtrl --> RoomService
    ServiceCtrl --> AuthService

    subgraph "Model Layer"
        AuthModel["models/service.js"]:::appLayers
        HouseModel["models/houses.js"]:::appLayers
        BillModel["models/bill.js"]:::appLayers
        CovenantModel["models/covenant.js"]:::appLayers
        DepositModel["models/deposit.js"]:::appLayers
        OwnerModel["models/owner.js"]:::appLayers
        RenterModel["models/renter.js"]:::appLayers
        RoomModel["models/room.js"]:::appLayers
    end
    AuthService --> AuthModel
    HouseService --> HouseModel
    BillService --> BillModel
    CovenantService --> CovenantModel
    DepositService --> DepositModel
    OwnerService --> OwnerModel
    RenterService --> RenterModel
    RoomService --> RoomModel

    AuthModel --> DB["MySQL Database"]:::db
    HouseModel --> DB
    BillModel --> DB
    CovenantModel --> DB
    DepositModel --> DB
    OwnerModel --> DB
    RenterModel --> DB
    RoomModel --> DB

    Scheduler["Scheduler"]:::config
    Scheduler --> AuthService
    Scheduler --> HouseService

    click ConfigIndex "https://github.com/realhugn/be-it4409/blob/main/configs/index.js"
    click ConfigDB "https://github.com/realhugn/be-it4409/blob/main/configs/db.js"
    click ConfigSchedule "https://github.com/realhugn/be-it4409/blob/main/configs/schedule.js"
    click AppLoader "https://github.com/realhugn/be-it4409/blob/main/loaders/app.js"
    click Bootstrap "https://github.com/realhugn/be-it4409/blob/main/loaders/index.js"
    click AuthMW "https://github.com/realhugn/be-it4409/blob/main/middlewares/auth.js"
    click Router "https://github.com/realhugn/be-it4409/blob/main/routes/index.js"
    click AuthRoute "https://github.com/realhugn/be-it4409/blob/main/routes/auth.js"
    click HouseRoute "https://github.com/realhugn/be-it4409/blob/main/routes/house.js"
    click BillRoute "https://github.com/realhugn/be-it4409/blob/main/routes/bill.js"
    click CovenantRoute "https://github.com/realhugn/be-it4409/blob/main/routes/covenant.js"
    click DepositRoute "https://github.com/realhugn/be-it4409/blob/main/routes/deposit.js"
    click OwnerRoute "https://github.com/realhugn/be-it4409/blob/main/routes/owner.js"
    click RenterRoute "https://github.com/realhugn/be-it4409/blob/main/routes/renter.js"
    click RoomRoute "https://github.com/realhugn/be-it4409/blob/main/routes/room.js"
    click ServiceRoute "https://github.com/realhugn/be-it4409/blob/main/routes/service.js"
    click AuthCtrl "https://github.com/realhugn/be-it4409/blob/main/controller/auth.js"
    click HouseCtrl "https://github.com/realhugn/be-it4409/blob/main/controller/house.js"
    click BillCtrl "https://github.com/realhugn/be-it4409/blob/main/controller/bill.js"
    click CovenantCtrl "https://github.com/realhugn/be-it4409/blob/main/controller/covenant.js"
    click DepositCtrl "https://github.com/realhugn/be-it4409/blob/main/controller/deposit.js"
    click OwnerCtrl "https://github.com/realhugn/be-it4409/blob/main/controller/owner.js"
    click RenterCtrl "https://github.com/realhugn/be-it4409/blob/main/controller/renter.js"
    click RoomCtrl "https://github.com/realhugn/be-it4409/blob/main/controller/room.js"
    click ServiceCtrl "https://github.com/realhugn/be-it4409/blob/main/controller/service.js"
    click AuthService "https://github.com/realhugn/be-it4409/blob/main/services/serviceService.js"
    click HouseService "https://github.com/realhugn/be-it4409/blob/main/services/houseService.js"
    click BillService "https://github.com/realhugn/be-it4409/blob/main/services/billService.js"
    click CovenantService "https://github.com/realhugn/be-it4409/blob/main/services/covenant.js"
    click DepositService "https://github.com/realhugn/be-it4409/blob/main/services/depositService.js"
    click OwnerService "https://github.com/realhugn/be-it4409/blob/main/services/ownerService.js"
    click RenterService "https://github.com/realhugn/be-it4409/blob/main/services/renterService.js"
    click RoomService "https://github.com/realhugn/be-it4409/blob/main/services/roomService.js"
    click AuthModel "https://github.com/realhugn/be-it4409/blob/main/models/service.js"
    click HouseModel "https://github.com/realhugn/be-it4409/blob/main/models/houses.js"
    click BillModel "https://github.com/realhugn/be-it4409/blob/main/models/bill.js"
    click CovenantModel "https://github.com/realhugn/be-it4409/blob/main/models/covenant.js"
    click DepositModel "https://github.com/realhugn/be-it4409/blob/main/models/deposit.js"
    click OwnerModel "https://github.com/realhugn/be-it4409/blob/main/models/owner.js"
    click RenterModel "https://github.com/realhugn/be-it4409/blob/main/models/renter.js"
    click RoomModel "https://github.com/realhugn/be-it4409/blob/main/models/room.js"
    click DB "https://github.com/realhugn/be-it4409/blob/main/db.sql"

    class Client client
    class ExpressApp appLayers
```
