# nenertiy/backend-nenboard architecture

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

- Interactive diagram: https://gitdiagram.com/nenertiy/backend-nenboard
- Repository: https://github.com/nenertiy/backend-nenboard

## Overview

##### Main Components/Modules
- App Module – your core module that might include bootstrap or global providers such as the Prisma service (src/modules/app/prisma.service.ts).
- Auth Module – handles user authentication and authorization, with its controllers, services, dto definitions (e.g. sign-in, sign-up), and guards (located in src/modules/auth).
- Users Module – manages user data with its controllers, services, and repositories.
- Projects Module – encapsulates project creation, updating, etc.
- Tasks Module – manages task creation, updates, and their validation via DTOs.
- Media Module – handles media processing, again broken into controllers, services, repositories.
- Activity Log Module – includes a controller, service, repository and importantly a gateway (for WebSocket communications) to broadcast activity logs.
- Token Module – provides token strategies (such as the jwt.strategy) and token management services.

##### Common/Shared Modules and Utilities
- A “Common” section that shows shared decorators (e.g., decode-user.decorator.ts, project-role.decorator.ts) and types (JWT payload, user types, project types).
- A “Config Module” (src/config/config.ts) to indicate how environment-specific configurations are loaded (via .env.example and similar config files).

##### Data Layer
- Prisma layer (prisma/schema.prisma) as the underlying database connection layer that the repositories in various modules interact with.

##### Communication & Architecture Patterns
- From External Clients (e.g., via REST endpoints or WebSocket connections) to the Controllers.
- From Controllers to respective Services and then to Repositories.
- From Activity Log controllers and gateways to external clients (especially indicating WebSocket data flows).
- Use of architectural patterns like Dependency Injection (a core NestJS principle) and the layered pattern (controllers → services → repositories).
- If applicable, show the separation between synchronous (HTTP) requests in controllers and asynchronous events in gateways.

##### Technologies and Frameworks
- NestJS Framework – overall container and modules.
- TypeScript – code language and toolchain (with tsconfig.json files).
- Prisma – acts as your ORM and connects with the underlying database.
- Testing – Though not shown in the file tree directly, you might note that testing is integrated given the commands in the README (unit and e2e tests).

## Diagram (Mermaid)

```mermaid
flowchart TD
    ExternalClients["External Clients"]:::external
    Entry["Entry Point (src/main.ts)"]:::entry
    NestJS["NestJS Application"]:::nestjs

    ExternalClients -->|"HTTP/WSRequests"| Entry
    Entry -->|"Bootstraps"| NestJS

    subgraph "Modules"
      AppModule["App Module\n(Global Providers)"]:::module
      AuthModule["Auth Module"]:::module
      UsersModule["Users Module"]:::module
      ProjectsModule["Projects Module"]:::module
      TasksModule["Tasks Module"]:::module
      MediaModule["Media Module"]:::module
      ActivityLogModule["Activity Log Module"]:::module
      TokenModule["Token Module"]:::module
    end

    NestJS -->|"Initializes"| AppModule
    NestJS -->|"Initializes"| AuthModule
    NestJS -->|"Initializes"| UsersModule
    NestJS -->|"Initializes"| ProjectsModule
    NestJS -->|"Initializes"| TasksModule
    NestJS -->|"Initializes"| MediaModule
    NestJS -->|"Initializes"| ActivityLogModule
    NestJS -->|"Initializes"| TokenModule

    Prisma["Prisma ORM (prisma/schema.prisma)"]:::database
    AppModule -->|"uses"| Prisma
    AuthModule -->|"uses"| Prisma
    UsersModule -->|"uses"| Prisma
    ProjectsModule -->|"uses"| Prisma
    TasksModule -->|"uses"| Prisma
    MediaModule -->|"uses"| Prisma
    ActivityLogModule -->|"uses"| Prisma
    TokenModule -->|"uses"| Prisma

    ActivityLogModule -->|"broadcastsViaGateway"| ExternalClients

    subgraph "Common/Shared"
      CommonDecorators["Common Decorators"]:::common
      CommonTypes["Common Types"]:::common
    end

    NestJS ---|"utilizes"| CommonDecorators
    NestJS ---|"utilizes"| CommonTypes

    ConfigModule["Config Module"]:::config
    NestJS ---|"configsVia"| ConfigModule

    subgraph "Containerization"
      Dockerfile["Dockerfile"]:::container
      DockerCompose["docker-compose.yml"]:::container
    end

    Dockerfile -->|"builds"| NestJS
    DockerCompose -->|"orchestrates"| NestJS

    click Entry "https://github.com/nenertiy/backend-nenboard/blob/main/src/main.ts"
    click AppModule "https://github.com/nenertiy/backend-nenboard/blob/main/src/modules/app/app.module.ts"
    click AuthModule "https://github.com/nenertiy/backend-nenboard/tree/main/src/modules/auth"
    click UsersModule "https://github.com/nenertiy/backend-nenboard/tree/main/src/modules/users"
    click ProjectsModule "https://github.com/nenertiy/backend-nenboard/tree/main/src/modules/projects"
    click TasksModule "https://github.com/nenertiy/backend-nenboard/tree/main/src/modules/tasks"
    click MediaModule "https://github.com/nenertiy/backend-nenboard/tree/main/src/modules/media"
    click ActivityLogModule "https://github.com/nenertiy/backend-nenboard/tree/main/src/modules/activity-log"
    click TokenModule "https://github.com/nenertiy/backend-nenboard/tree/main/src/modules/token"
    click CommonDecorators "https://github.com/nenertiy/backend-nenboard/tree/main/src/common/decorators"
    click CommonTypes "https://github.com/nenertiy/backend-nenboard/tree/main/src/common/types"
    click ConfigModule "https://github.com/nenertiy/backend-nenboard/blob/main/src/config/config.ts"
    click Prisma "https://github.com/nenertiy/backend-nenboard/blob/main/prisma/schema.prisma"
    click Dockerfile "https://github.com/nenertiy/backend-nenboard/tree/main/Dockerfile"
    click DockerCompose "https://github.com/nenertiy/backend-nenboard/blob/main/docker-compose.yml"

    classDef external fill:#FFE6A7,stroke:#D17D00,stroke-width:2px;
    classDef entry fill:#FFD700,stroke:#B8860B,stroke-width:2px;
    classDef nestjs fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef module fill:#B0E0E6,stroke:#4682B4,stroke-width:2px;
    classDef common fill:#FFB6C1,stroke:#C71585,stroke-width:2px;
    classDef config fill:#E6E6FA,stroke:#8A2BE2,stroke-width:2px;
    classDef database fill:#98FB98,stroke:#008000,stroke-width:2px;
    classDef container fill:#FFFACD,stroke:#DAA520,stroke-width:2px;
```
