# xorazm92/crm_back architecture

> Architecture diagram of the GitHub repository xorazm92/crm_back, 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/xorazm92/crm_back
- Repository: https://github.com/xorazm92/crm_back

## Overview

##### Main Components
- Backend API: Represented by the NestJS application. Notice the “src/api” directory, which is subdivided into specific domains such as admin, assignments, attendance, auth, course, dashboard, fileupload, group, lesson, student, submissions, and teacher. Each module encapsulates its own controllers, services, and DTOs.
- Frontend Client: Found in “src/client” – it consists of React components (pages, layouts, etc.) that serve as the user interface.
- Database: Managed through Prisma (files in “prisma” directory, migrations, schema, and seed file). This indicates a relational database backend which can be represented as a separate data store.
- Shared Utilities & Infrastructure: The common and infrastructure folders include cross-cutting concerns such as decorators, guards, exception handling, logging, configuration, and libraries (custom JWT, bcrypt, pagination, etc.). These components support both the backend business logic and overall application stability.
- External Configurations & Deployment Artifacts: Files like Docker Compose, environment examples, and build configurations indicate that the deployment and operational environment is also part of the design (containerization, CI/CD considerations).

##### Relationships and Interactions
- The Frontend and Backend communicate via HTTP(S) requests: the React client makes API calls to the NestJS backend endpoints.
- The Backend is organized in a modular fashion where each module (admin, auth, etc.) controls its own domain logic. These modules often call shared utilities (custom JWT, base-services, and exception filters) that manage security, logging, and error handling.
- The Backend interacts with the underlying database through Prisma. All database-related changes (migrations, schema updates, and seeding) are managed here.
- External libraries (e.g., NestJS core, custom middlewares, decorators, guards) integrate with these modules to enforce business rules and secure operations.
- Development and deployment tools (Docker Compose, ESLint, Prettier) aren’t part of runtime architecture, but indicate the system’s build and deployment pipeline.

##### Architectural Patterns and Design Principles
- Modular Design: Each domain (or microfeature) is encapsulated in its module (controller, service, DTO), aligning with NestJS’s modular architecture.
- Layered Architecture: There is a clear separation between the API layer (controllers), business logic (services), and data access layer (Prisma-managed database).
- Separation of Concerns: The “common”, “infrastructure”, and “config” directories suggest the internal decoupling of cross-cutting concerns such as authentication, logging, and error handling.
- Client-Server Separation: The “src/client” directory stands alone from backend logic, emphasizing distinct development and deployment cycles.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        FE["Frontend (React/Vite)"]:::frontend
    end

    subgraph "Backend Layer"
        BE["Backend API (NestJS) - Modules: admin,auth,assignments,attendance,course,dashboard,fileupload,group,lesson,student,submissions,teacher"]:::backend
        subgraph "Shared Utilities & Infrastructure"
            U1["Common Utilities"]:::shared
            U2["Configuration Files"]:::shared
            U3["Shared Libraries"]:::shared
        end
    end

    subgraph "Database Layer"
        DB["Database (Prisma)"]:::database
        subgraph "Prisma Details"
            Schema["Schema"]:::database
            Migrations["Migrations"]:::database
            Seed["Seed"]:::database
        end
        DB --> Schema
        DB --> Migrations
        DB --> Seed
    end

    subgraph "Deployment & Tooling"
        Deploy["Docker & Env Configs"]:::deploy
        Tools["Prettier Config"]:::deploy
        Commit["Commit Lint Config"]:::deploy
        ESLint["ESLint Config"]:::deploy
    end

    FE -->|"HTTPRequests"| BE
    BE -->|"DataAccess"| DB
    BE -->|"Uses"| U1
    BE -->|"Uses"| U2
    BE -->|"Uses"| U3
    BE -.->|"Deployment"| Deploy
    BE -.->|"Deployment"| Tools
    BE -.->|"Deployment"| Commit
    BE -.->|"Deployment"| ESLint

    click FE "https://github.com/xorazm92/crm_back/tree/main/src/client"
    click BE "https://github.com/xorazm92/crm_back/tree/main/src/api"
    click DB "https://github.com/xorazm92/crm_back/tree/main/prisma"
    click Schema "https://github.com/xorazm92/crm_back/blob/main/prisma/schema.prisma"
    click Migrations "https://github.com/xorazm92/crm_back/tree/main/prisma/migrations"
    click Seed "https://github.com/xorazm92/crm_back/blob/main/prisma/seed.ts"
    click U1 "https://github.com/xorazm92/crm_back/tree/main/src/common"
    click U2 "https://github.com/xorazm92/crm_back/tree/main/src/config"
    click U3 "https://github.com/xorazm92/crm_back/tree/main/src/infrastructure/lib"
    click Deploy "https://github.com/xorazm92/crm_back/blob/main/docker-compose.yml"
    click Tools "https://github.com/xorazm92/crm_back/blob/main/.prettierrc"
    click Commit "https://github.com/xorazm92/crm_back/blob/main/.commitlintrc.json"
    click ESLint "https://github.com/xorazm92/crm_back/blob/main/eslint.config.mjs"

    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef database fill:#A9DFBF,stroke:#1D8348,stroke-width:2px;
    classDef shared fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef deploy fill:#F5CBA7,stroke:#AF601A,stroke-width:2px;
```
