# dtc04/linkudp architecture

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

- Interactive diagram: https://gitdiagram.com/dtc04/linkudp
- Repository: https://github.com/dtc04/linkudp

## Overview

##### Project type and purpose
- This is a backend-only REST API service for the LinkUDP platform.
- It’s built with NestJS (Node.js framework), uses Prisma as the ORM, and PostgreSQL as the persistent data store.
- It exposes endpoints (controllers) to connect students with university tutors.

##### File structure
- Top‐level “Backend” directory contains:
- src/ with NestJS modules, controllers (app.controller.ts) and services (app.service.ts)
- prisma/ with schema.prisma, migration files, and Prisma config
- docker-compose.yml for spinning up PostgreSQL
- config files: nest-cli.json, tsconfig.json, eslint, Prettier, .nvmrc
- tests under test/ and src/*.spec.ts for unit and e2e testing
- dist/ is the compiled output of the TypeScript build.
- package.json defines scripts (start:dev, start:prod, test) and dependencies.

##### README for additional insights
- Tech stack: NestJS, Prisma, PostgreSQL, Docker
- Development workflow: Docker Compose for DB, .env for DATABASE_URL, Prisma migrations, Prisma Studio.
- Emphasis on hot reload in development, separate production command.

##### Details to capture
- NestJS module boundaries (app.module → registers controller & service).
- The fact that environment variables (DATABASE_URL) configure Prisma’s connection.
- The use of Docker Compose: map port 5432 and network links.
- Migration flow: Prisma Migrate → applies schema changes to PostgreSQL.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    Client["REST Client"]:::external

    %% API Service Subgraph
    subgraph "API Service"
        direction TB
        Main["Application Entry Point\nmain.ts"]:::app
        Module["NestJS Module\napp.module.ts"]:::app
        Controller["NestJS Controller\napp.controller.ts"]:::app
        Service["NestJS Service\napp.service.ts"]:::app
        PrismaClient["Prisma Client\ngenerated"]:::app
    end

    %% Database Container
    PostgreSQL["PostgreSQL DB (Docker)"]:::db

    %% Dev Tools
    subgraph "Development Tools"
        direction TB
        PrismaMigrate["Prisma Migrate\nmigration.sql"]:::dev
        PrismaStudio["Prisma Studio"]:::dev
        DockerCompose["Docker Compose\ndocker-compose.yml"]:::dev
    end

    %% Test Suites
    subgraph "Tests"
        direction TB
        E2E["End-to-End Tests\napp.e2e-spec.ts"]:::dev
        Unit["Unit Tests\napp.controller.spec.ts"]:::dev
    end

    %% Configuration Files
    subgraph "Config Files"
        direction TB
        NestCLI["nest-cli.json"]:::dev
        TSConfig["tsconfig.json\ntsconfig.build.json"]:::dev
        ESLint["eslint.config.mjs"]:::dev
        Prettier[".prettierrc"]:::dev
        NVM[".nvmrc"]:::dev
        PackageJSON["package.json"]:::dev
    end

    %% Connections
    Client -->|"HTTP/REST"| Controller
    Main -->|"initializes"| Module
    Module -->|"registers"| Controller
    Module -->|"registers"| Service
    Controller -->|"calls"| Service
    Service -->|"uses"| PrismaClient
    PrismaClient -->|"SQL over TCP"| PostgreSQL
    PostgreSQL -->|"response data"| PrismaClient
    PrismaClient -->|"returns results"| Service
    Service -->|"returns DTO"| Controller
    Controller -->|"HTTP Response"| Client

    DockerCompose -->|"spins up"| PostgreSQL
    PrismaMigrate -->|"applies migrations to"| PostgreSQL
    PrismaStudio -->|"connects to"| PostgreSQL

    %% Click Events
    click Main "https://github.com/dtc04/linkudp/blob/main/Backend/src/main.ts"
    click Module "https://github.com/dtc04/linkudp/blob/main/Backend/src/app.module.ts"
    click Controller "https://github.com/dtc04/linkudp/blob/main/Backend/src/app.controller.ts"
    click Service "https://github.com/dtc04/linkudp/blob/main/Backend/src/app.service.ts"
    click PrismaClient "https://github.com/dtc04/linkudp/blob/main/Backend/prisma/schema.prisma"
    click PrismaMigrate "https://github.com/dtc04/linkudp/blob/main/Backend/prisma/migrations/20250512035425_init/migration.sql"
    click DockerCompose "https://github.com/dtc04/linkudp/blob/main/Backend/docker-compose.yml"
    click Unit "https://github.com/dtc04/linkudp/blob/main/Backend/src/app.controller.spec.ts"
    click E2E "https://github.com/dtc04/linkudp/blob/main/Backend/test/app.e2e-spec.ts"
    click NestCLI "https://github.com/dtc04/linkudp/blob/main/Backend/nest-cli.json"
    click TSConfig "https://github.com/dtc04/linkudp/blob/main/Backend/tsconfig.json"
    click Prettier "https://github.com/dtc04/linkudp/blob/main/Backend/.prettierrc"
    click ESLint "https://github.com/dtc04/linkudp/blob/main/Backend/eslint.config.mjs"
    click NVM "https://github.com/dtc04/linkudp/blob/main/Backend/.nvmrc"
    click PackageJSON "https://github.com/dtc04/linkudp/blob/main/Backend/package.json"

    %% Styles
    classDef app fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef db fill:#FFA500,stroke:#000,stroke-width:1px
    classDef dev fill:#DDDDDD,stroke:#000,stroke-dasharray: 5 5
    classDef external fill:#90EE90,stroke:#000,stroke-width:1px
```
