# sumitatallo/trade-points-system architecture

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

- Interactive diagram: https://gitdiagram.com/sumitatallo/trade-points-system
- Repository: https://github.com/sumitatallo/trade-points-system

## Overview

##### Project type and purpose
- This is a backend monolith built with the NestJS framework (a modular, TypeScript-based Node.js server).
- Its domain is a points/leaderboard/referral/trading system: it exposes REST (or GraphQL) endpoints for users to earn points, make trades, refer others, and view leaderboards.

##### File structure
- src/app.module.ts: Root module that imports all feature modules.
- src/config/database: DatabaseModule with connection setup (likely TypeORM).
- src/leaderboards, src/points, src/referrals, src/trades, src/users: Each is a NestJS module containing entities and (presumably) controllers/services.
- src/app.controller.ts, src/app.service.ts: Default top-level health / root endpoints.
- src/main.ts: Boots the NestJS HTTP server.
- test/: End-to-end test harness.

##### README
- Confirms this is a “starter” NestJS application scaffold.
- No custom architecture doc; we infer from modules and entities that each feature module encapsulates its domain logic and data models.

## Diagram (Mermaid)

```mermaid
flowchart TB
    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef controllers fill:#ccf,stroke:#333,stroke-width:1px
    classDef services fill:#cfc,stroke:#333,stroke-width:1px
    classDef entities fill:#ffc,stroke:#333,stroke-width:1px
    classDef infra fill:#eee,stroke:#333,stroke-width:1px

    Client["External Client"]:::external
    Client --> APIGW

    APIGW["NestJS HTTP Server"]:::infra
    click APIGW "https://github.com/sumitatallo/trade-points-system/blob/main/src/main.ts"

    subgraph "Root Module"
        AppModule["AppModule"]:::infra
        AppController["AppController"]:::controllers
        AppService["AppService"]:::services
    end
    click AppModule "https://github.com/sumitatallo/trade-points-system/blob/main/src/app.module.ts"
    click AppController "https://github.com/sumitatallo/trade-points-system/blob/main/src/app.controller.ts"
    click AppService "https://github.com/sumitatallo/trade-points-system/blob/main/src/app.service.ts"

    APIGW --> AppController
    AppController --> AppService

    subgraph "Config & Database"
        EnvVal["Env Validation"]:::infra
        DBModule["DatabaseModule"]:::infra
    end
    click EnvVal "https://github.com/sumitatallo/trade-points-system/blob/main/src/config/env.validation.ts"
    click DBModule "https://github.com/sumitatallo/trade-points-system/blob/main/src/config/database/database.module.ts"

    EnvVal --> DBModule
    AppModule --> EnvVal
    AppModule --> DBModule

    subgraph "Users Module"
        UController["UsersController"]:::controllers
        UService["UsersService"]:::services
        UEntity["User Entity"]:::entities
    end
    click UEntity "https://github.com/sumitatallo/trade-points-system/blob/main/src/users/entities/user.entity.ts"
    click UController "https://github.com/sumitatallo/trade-points-system/tree/main/src/users"
    APIGW --> UController
    UController --> UService
    UService --> UEntity
    DBModule --> UService

    subgraph "Points Module"
        PController["PointsController"]:::controllers
        PService["PointsService"]:::services
        PEntity1["PointsLedger Entity"]:::entities
        PEntity2["PointsRule Entity"]:::entities
    end
    click PEntity1 "https://github.com/sumitatallo/trade-points-system/blob/main/src/points/entities/points-ledger.entity.ts"
    click PEntity2 "https://github.com/sumitatallo/trade-points-system/blob/main/src/points/entities/points-rule.entity.ts"
    click PController "https://github.com/sumitatallo/trade-points-system/tree/main/src/points"
    APIGW --> PController
    PController --> PService
    PService --> PEntity1
    PService --> PEntity2
    DBModule --> PService

    subgraph "Referrals Module"
        RController["ReferralsController"]:::controllers
        RService["ReferralsService"]:::services
        REntity["Referral Entity"]:::entities
    end
    click REntity "https://github.com/sumitatallo/trade-points-system/blob/main/src/referrals/entities/referral.entity.ts"
    click RController "https://github.com/sumitatallo/trade-points-system/tree/main/src/referrals"
    APIGW --> RController
    RController --> RService
    RService --> REntity
    DBModule --> RService
    RService -->|awards points| PService

    subgraph "Trades Module"
        TController["TradesController"]:::controllers
        TService["TradesService"]:::services
        TEntity["Trade Entity"]:::entities
    end
    click TEntity "https://github.com/sumitatallo/trade-points-system/blob/main/src/trades/entities/trade.entity.ts"
    click TController "https://github.com/sumitatallo/trade-points-system/tree/main/src/trades"
    APIGW --> TController
    TController --> TService
    TService --> TEntity
    DBModule --> TService

    subgraph "Leaderboards Module"
        LController["LeaderboardsController"]:::controllers
        LService["LeaderboardsService"]:::services
        LEntity1["LeaderboardEntry Entity"]:::entities
        LEntity2["LeaderboardType Entity"]:::entities
    end
    click LEntity1 "https://github.com/sumitatallo/trade-points-system/blob/main/src/leaderboards/entities/leaderboard-entry.entity.ts"
    click LEntity2 "https://github.com/sumitatallo/trade-points-system/blob/main/src/leaderboards/entities/leaderboard-type.entity.ts"
    click LController "https://github.com/sumitatallo/trade-points-system/tree/main/src/leaderboards"
    APIGW --> LController
    LController --> LService
    LService --> LEntity1
    LService --> LEntity2
    DBModule --> LService

    DB["PostgreSQL Database"]:::infra
    DBModule --> DB

    subgraph "E2E Test Harness"
        TestSpec["app.e2e-spec.ts"]:::external
        TestConfig["jest-e2e.json"]:::external
    end
    click TestSpec "https://github.com/sumitatallo/trade-points-system/blob/main/test/app.e2e-spec.ts"
    click TestConfig "https://github.com/sumitatallo/trade-points-system/blob/main/test/jest-e2e.json"
    TestSpec --> APIGW

    class Client,TestSpec,TestConfig external
    class AppController,PController,RController,TController,LController controllers
    class AppService,UService,PService,RService,TService,LService services
    class UEntity,PEntity1,PEntity2,REntity,TEntity,LEntity1,LEntity2 entities
    class APIGW,AppModule,EnvVal,DBModule,DB infra
```
