# fh-fahad/nest-main-service architecture

> Architecture diagram of the GitHub repository fh-fahad/nest-main-service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fh-fahad/nest-main-service
- Repository: https://github.com/fh-fahad/nest-main-service

## Overview

##### Main Components

a. Application Core:
- NestJS Application Module (app.module.ts)
- Configuration Layer
- App Config (app.config.ts)
- Database Module (db.module.ts)
- PostgreSQL Module (pg.module.ts)
- RabbitMQ Module (rmq.module.ts)

b. Feature Modules:
- User Module
- Controller Layer
- Service Layer
- DTOs
- Entities

c. External Services:
- PostgreSQL Database
- RabbitMQ Message Broker

**┌─────────────────────────────────────────────────────┐**
- Client Requests                     │
- ┬───────────────────────────────────┘
- ↓
**┌─────────────────────────────────────────────────────┐**
- NestJS Application                  │
- ┌───────────────────┐    ┌────────────────────┐    │
- Configuration   │    │    User Module     │    │
- App Config   │    │  ┌──────────────┐  │    │
- DB Config    │    │  │  Controller  │  │    │
- PG Config    │    │  └──────┬───────┘  │    │
- RMQ Config   │    │         ↓          │    │
- ┘    │  ┌──────────────┐  │    │
- Service    │  │    │
- ┬───────┘  │    │
- ↓          │    │
- ┌──────────────┐  │    │
- Entities   │  │    │
- ┘  │    │
- ┘    │
- ┬───────────────────────┘
- ↓
**┌─────────────────────────────────────────────────────┐**
- External Services Layer               │
- ┌───────────────────┐    ┌────────────────────┐   │
- PostgreSQL     │    │     RabbitMQ       │   │
- ┘    └────────────────────┘   │
- ┘

##### Important Elements to Highlight

a. Dependency Flow:
- How the User module depends on the configuration modules
- Connection between controllers and services
- Database interactions through entities

b. Message Flow:
- RabbitMQ integration points if used for event-driven communication

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CR[Client Requests]
    end

    subgraph NestJS
        AppModule["App Module"]:::core
        click AppModule "https://github.com/FH-Fahad/nest-main-service/blob/main/src/app.module.ts"

        subgraph Config["Configuration Layer"]
            AppConfig["App Config"]:::config
            DBModule["Database Module"]:::config
            PGModule["PostgreSQL Module"]:::config
            RMQModule["RabbitMQ Module"]:::config

            click AppConfig "https://github.com/FH-Fahad/nest-main-service/blob/main/src/configuration/app.config.ts"
            click DBModule "https://github.com/FH-Fahad/nest-main-service/blob/main/src/configuration/db.module.ts"
            click PGModule "https://github.com/FH-Fahad/nest-main-service/blob/main/src/configuration/pg.module.ts"
            click RMQModule "https://github.com/FH-Fahad/nest-main-service/blob/main/src/configuration/rmq.module.ts"
        end

        subgraph UserMod["User Module"]
            UserModule["User Module Definition"]:::module
            UserController["User Controller"]:::controller
            UserService["User Service"]:::service
            UserDTO["User DTOs"]:::dto
            UserEntity["User Entities"]:::entity

            click UserModule "https://github.com/FH-Fahad/nest-main-service/blob/main/src/modules/user/user.module.ts"
            click UserController "https://github.com/FH-Fahad/nest-main-service/blob/main/src/modules/user/user.controller.ts"
            click UserService "https://github.com/FH-Fahad/nest-main-service/blob/main/src/modules/user/user.service.ts"
            click UserDTO "https://github.com/FH-Fahad/nest-main-service/blob/main/src/modules/user/dto/user.dto.ts"
            click UserEntity "https://github.com/FH-Fahad/nest-main-service/blob/main/src/modules/user/entity/user.entity.ts"

            UserController --> UserService
            UserService --> UserEntity
            UserService --> UserDTO
        end
    end

    subgraph External["External Services Layer"]
        DB[(PostgreSQL)]:::database
        RMQ{{"RabbitMQ"}}:::messagebroker
    end

    CR --> AppModule
    AppModule --> Config
    AppModule --> UserMod
    UserEntity --> DB
    UserService --> RMQ

    classDef core fill:#2E8BC0,stroke:#333,stroke-width:2px
    classDef config fill:#B8E0F9,stroke:#333,stroke-width:1px
    classDef module fill:#98FB98,stroke:#333,stroke-width:1px
    classDef controller fill:#90EE90,stroke:#333,stroke-width:1px
    classDef service fill:#98FB98,stroke:#333,stroke-width:1px
    classDef dto fill:#F0FFF0,stroke:#333,stroke-width:1px
    classDef entity fill:#90EE90,stroke:#333,stroke-width:1px
    classDef database fill:#FFA07A,stroke:#333,stroke-width:1px
    classDef messagebroker fill:#FFA07A,stroke:#333,stroke-width:1px

    subgraph Legend
        L1[NestJS Core]:::core
        L2[Configuration]:::config
        L3[Module Components]:::module
        L4[(Database)]:::database
        L5{{"Message Broker"}}:::messagebroker
    end
```
