# nestjsx/crud architecture

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

- Interactive diagram: https://gitdiagram.com/nestjsx/crud
- Repository: https://github.com/nestjsx/crud

## Overview

##### Component Relationships

**RequestQueryBuilder -> RequestQueryParser -> CRUD Controllers -> TypeOrmCrudService -> Database**

##### Detailed Components

Specific elements:

a) Core Package Details:
- @Crud() Decorator
- CrudRoutesFactory
- CrudService Abstract
- Interceptors (Request, Response)
- Validation Helpers

b) Request Package Details:
- Query Parser
- Query Validator
- Filter Builder
- Pagination Handler
- Sorting Manager

c) TypeORM Package Details:
- Base CRUD Operations
- Query Builder
- Entity Relations Handler
- Transaction Manager

##### Integration Points

Integration points with:
- NestJS Framework
- TypeORM
- External APIs
- Client Applications

##### Additional Elements

Include:
- Version compatibility information
- Configuration flow
- Request/Response flow indicators
- Error handling paths

##### Architectural Patterns

Highlight:
- Decorator Pattern usage
- Repository Pattern implementation
- Interceptor Pattern
- Factory Pattern

##### The separation of concerns between packages

Keep the abstraction level balanced:
- High enough to show the big picture
- Detailed enough to understand component interactions
- Clear separation between public API and internal implementation

Use standardized UML or similar notation where appropriate, but prioritize clarity over strict adherence to formal notation systems.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Overview
        Title["NestJS CRUD Framework<br/>Automated CRUD Operations Generator for RESTful APIs"]
    end

    subgraph "Request Package"
        RQB["RequestQueryBuilder"]:::request
        QP["Query Parser"]:::request
        QV["Query Validator"]:::request
        PI["Request Interfaces"]:::request
    end

    subgraph "Core Package"
        CD["CRUD Decorator"]:::core
        CRF["Controller Generation"]:::core
        IC["Interceptors Chain"]:::core
        VS["Validation System"]:::core
        CS["Core Service"]:::core
        CCS["CRUD Config Service"]:::core
        COI["CRUD Options Interface"]:::core
    end

    subgraph "TypeORM Package"
        TCS["TypeOrmCrudService"]:::typeorm
    end

    subgraph "Integration Examples"
        SC["Sample Controllers"]:::example
        SS["Sample Services"]:::example
        SE["Sample Entities"]:::example
    end

    subgraph "External Systems"
        DB[(Database)]:::external
        NJS["NestJS Framework"]:::external
        API["External APIs"]:::external
    end

    %% Relationships
    RQB --> QP
    QP --> QV
    QV --> IC
    IC --> CRF
    CD --> CRF
    CRF --> CS
    CS --> TCS
    TCS --> DB
    CCS --> CD
    COI --> CD
    
    %% Integration flows
    SC -.-> CRF
    SS -.-> TCS
    SE -.-> TCS
    NJS -.-> CD
    TCS -.-> API

    %% Click events
    click RQB "https://github.com/nestjsx/crud/blob/master//packages/crud-request/src/request-query.builder.ts"
    click QP "https://github.com/nestjsx/crud/blob/master//packages/crud-request/src/request-query.parser.ts"
    click QV "https://github.com/nestjsx/crud/blob/master//packages/crud-request/src/request-query.validator.ts"
    click PI "https://github.com/nestjsx/crud/blob/master//packages/crud-request/src/interfaces/parsed-request.interface.ts"
    click CD "https://github.com/nestjsx/crud/blob/master//packages/crud/src/decorators/crud.decorator.ts"
    click CRF "https://github.com/nestjsx/crud/blob/master//packages/crud/src/crud/crud-routes.factory.ts"
    click IC "https://github.com/nestjsx/crud/tree/master//packages/crud/src/interceptors"
    click VS "https://github.com/nestjsx/crud/blob/master//packages/crud/src/crud/validation.helper.ts"
    click CS "https://github.com/nestjsx/crud/blob/master//packages/crud/src/services/crud-service.abstract.ts"
    click CCS "https://github.com/nestjsx/crud/blob/master//packages/crud/src/module/crud-config.service.ts"
    click COI "https://github.com/nestjsx/crud/blob/master//packages/crud/src/interfaces/crud-options.interface.ts"
    click TCS "https://github.com/nestjsx/crud/blob/master//packages/crud-typeorm/src/typeorm-crud.service.ts"
    click SC "https://github.com/nestjsx/crud/blob/master//integration/crud-typeorm/users/users.controller.ts"
    click SS "https://github.com/nestjsx/crud/blob/master//integration/crud-typeorm/users/users.service.ts"
    click SE "https://github.com/nestjsx/crud/blob/master//integration/crud-typeorm/users/user.entity.ts"

    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef request fill:#4CAF50,stroke:#2E7D32,color:white
    classDef typeorm fill:#FF9800,stroke:#EF6C00,color:white
    classDef external fill:#9E9E9E,stroke:#616161,color:white
    classDef example fill:#9C27B0,stroke:#6A1B9A,color:white

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Request Handling"]:::request
        L3["Database Layer"]:::typeorm
        L4["External Systems"]:::external
        L5["Examples"]:::example
    end
```
