# nickmeofficial/ghardekho-backend architecture

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

- Interactive diagram: https://gitdiagram.com/nickmeofficial/ghardekho-backend
- Repository: https://github.com/nickmeofficial/ghardekho-backend

## Overview

##### Main Components
- Application Entry Point and Core Module: Represent the main.ts file and the AppModule which bootstraps the application.
- Feature Modules:
- Authentication Module: Contains controllers, DTOs, guards, and strategies (JWT and local) to handle user authentication.
- Property Module: Manages property-related operations. Note the existence of a dedicated configuration (multer for file uploads), DTOs, a controller, and a service.
- User Module: Handles user-related business logic and services.
- Common Module/Components:
- Entities: Include user, property, role, and userrole entities.
- Enums: Represent various status, type, and currency definitions.
- Services: For instance, the Custom Logger service which is shared across modules.
- Infrastructure & Deployment Considerations:
- Although not visibly depicted in the code besides configuration files (e.g., .env, tsconfig files), it’s implied that database connections and file uploads are part of the system.
- The dist folder shows the compilation artifacts, which means that the logical organization in the src folder is our source architecture.

##### Relationships and Data Flow
- Client Requests: Begin with incoming HTTP requests going to the appropriate controllers (app, auth, property).
- Controllers: Each module’s controller (e.g., auth.controller, property.controller) routes the request to its corresponding service.
- Services: The services (auth.service, property.service, user.service) contain the business logic and interact with persistence layers via entities.
- Shared Infrastructure: The common services (like the Custom Logger) and entities provide shared utilities and data models accessed by multiple feature modules.

##### Architectural Patterns and Design Principles
- Modular Architecture: Clearly separate the system into distinct modules each with its own controllers, services, DTOs, and configurations.
- Dependency Injection: Indicate how controllers depend on their services, and services might depend on shared providers (for example, a custom logger).
- Separation of Concerns: Each module is responsible for its domain (authentication, properties, users) ensuring clarity in role and responsibility.
- RESTful Design: Although not drawn explicitly, the design suggests typical REST endpoints for CRUD operations in modules such as property management.
- Configurability: Note the use of configuration files (e.g., multer.config for file uploads) that indicate how the system is adjustable.

##### Summary of Diagramic Elements
- Clear labels for each module and sub-component.
- Detailed depiction of module boundaries – explicitly show integration between modules and shared/common components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Level: Client Request and Entry Point
    Client["HTTP Request"]:::entry
    subgraph "Entry Point"
        main["main.ts"]:::entry
        appModule["AppModule"]:::entry
    end
    Client -->|"routes to"| main
    main -->|"bootstraps"| appModule

    %% Feature Modules Subgraph
    subgraph "Feature Modules"
        %% Authentication Module
        subgraph "Authentication Module"
            authCtrl["Auth Controller"]:::controller
            authService["Auth Service"]:::service
            jwtStrategy["JWT Strategy"]:::strategy
            localStrategy["Local Strategy"]:::strategy
            authGuard["JWT Auth Guard"]:::guard
            loginDTO["Login DTO"]:::dto
            registerDTO["Register DTO"]:::dto
        end

        %% Property Module
        subgraph "Property Module"
            propertyCtrl["Property Controller"]:::controller
            propertyService["Property Service"]:::service
            createPropDTO["Create-Property DTO"]:::dto
            searchPropDTO["Property-Search DTO"]:::dto
            updatePropDTO["Update-Property DTO"]:::dto
            multerConfig["Multer Config"]:::config
        end

        %% User Module
        subgraph "User Module"
            userModule["User Module"]:::module
            userService["User Service"]:::service
        end
    end

    %% Common Components Subgraph
    subgraph "Common Components"
        commonEntities["Entities (property, role, user, userrole)"]:::common
        commonEnums["Enums (status, type, usercurrency)"]:::common
        customLogger["Custom Logger Service"]:::common
    end

    %% Relationships from AppModule to Feature Modules
    appModule -->|"initializes"| authCtrl
    appModule -->|"initializes"| propertyCtrl
    appModule -->|"initializes"| userModule

    %% Inside Authentication Module
    authCtrl -->|"calls"| authService
    authCtrl -->|"securedby"| authGuard
    authCtrl -->|"validates using"| loginDTO
    authCtrl -->|"validates using"| registerDTO
    authService -->|"uses"| jwtStrategy
    authService -->|"uses"| localStrategy
    authService -->|"logs via"| customLogger

    %% Inside Property Module
    propertyCtrl -->|"calls"| propertyService
    propertyCtrl -->|"validates using"| createPropDTO
    propertyCtrl -->|"validates using"| searchPropDTO
    propertyCtrl -->|"validates using"| updatePropDTO
    propertyService -->|"configures via"| multerConfig
    propertyService -->|"persists using"| commonEntities
    propertyService -->|"logs via"| customLogger

    %% Inside User Module
    userModule -->|"integrates"| userService
    userService -->|"manages"| commonEntities
    userService -->|"logs via"| customLogger

    %% Common Dependencies
    authCtrl ---|"shares"| commonEnums
    propertyCtrl ---|"shares"| commonEnums
    userService ---|"shares"| commonEnums

    %% Click Events for Component Mapping
    click main "https://github.com/nickmeofficial/ghardekho-backend/blob/main/src/main.ts"
    click appModule "https://github.com/nickmeofficial/ghardekho-backend/blob/main/src/app.module.ts"
    click authCtrl "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/authentication"
    click authService "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/authentication"
    click jwtStrategy "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/authentication"
    click localStrategy "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/authentication"
    click authGuard "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/authentication"
    click loginDTO "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/authentication"
    click registerDTO "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/authentication"
    click propertyCtrl "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/property"
    click propertyService "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/property"
    click createPropDTO "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/property"
    click searchPropDTO "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/property"
    click updatePropDTO "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/property"
    click multerConfig "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/property"
    click userModule "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/user"
    click userService "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/user"
    click commonEntities "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/common/entity"
    click commonEnums "https://github.com/nickmeofficial/ghardekho-backend/tree/main/src/common/enums"
    click customLogger "https://github.com/nickmeofficial/ghardekho-backend/blob/main/src/common/services/custom-logger.service"

    %% Styles Definition
    classDef entry fill:#ccffff,stroke:#00aaaa,stroke-width:2px,color:#000;
    classDef controller fill:#ffdddd,stroke:#aa0000,stroke-width:2px,color:#000;
    classDef service fill:#ddffdd,stroke:#008800,stroke-width:2px,color:#000;
    classDef module fill:#ddddff,stroke:#0000aa,stroke-width:2px,color:#000;
    classDef dto fill:#ffeecc,stroke:#cc6600,stroke-width:2px,color:#000;
    classDef config fill:#e6e6fa,stroke:#663399,stroke-width:2px,color:#000;
    classDef common fill:#ffffcc,stroke:#ffcc00,stroke-width:2px,color:#000;
    classDef strategy fill:#ffe6e6,stroke:#ff3333,stroke-width:2px,color:#000;
    classDef guard fill:#e6ffe6,stroke:#33cc33,stroke-width:2px,color:#000;
```
