# papysaliou/nestjs_ecommerce_backend architecture

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

- Interactive diagram: https://gitdiagram.com/papysaliou/nestjs_ecommerce_backend
- Repository: https://github.com/papysaliou/nestjs_ecommerce_backend

## Overview

##### Project type and purpose
- This is a backend-only RESTful API built on NestJS (a Node.js framework in TypeScript).
- It exposes CRUD endpoints for “produits” (products) and “categories,” and handles authentication (users, profiles, JWT-based guards).
- It uses SQLite (db.sqlite) as its data store and follows Nest’s module-controller-service pattern.

##### File structure
- Top-level files:
– package.json, tsconfig.json, nest-cli.json → Node/Nest build and run configuration
– db.sqlite → embedded database
- src/main.ts → application entry point (bootstraps Nest application)
- src/app.module.ts → root module importing all feature modules
- src/auth → authentication module: controller, service, entities (User, Produit), JWT strategy and guard
- src/categorie → category module: controller, service, entity, DTOs
- src/produit → product module: controller, service
- src/app.controller.ts, app.service.ts → example root controller/service (starter code)
- test → end-to-end test setup

##### Key insights from README
- Confirms NestJS framework, intended as a server-side starter repository.
- No frontend; focus on building and deploying the API.

##### Detailed element checklist
- Every module and its subcomponents (Controller, Service, Entity)
- The bootstrap flow (main.ts → AppModule)
- The Database connection (TypeORM, SQLite)
- The JWT authentication flow (AuthController → AuthService → JwtStrategy → Guard)
- Inter-module imports and dependencies

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Client
    Client(["External Client"]):::client

    %% Bootstrap and Root
    Main["main.ts<br/>Bootstrapper"]:::bootstrap
    AppModule["AppModule"]:::module
    AppController["AppController"]:::controller
    AppService["AppService"]:::service

    %% Auth Module
    subgraph "Auth Module"
        AuthModule["AuthModule"]:::module
        AuthController["AuthController"]:::controller
        ProfileController["ProfileController"]:::controller
        AuthService["AuthService"]:::service
        JwtStrategy["JwtStrategy"]:::jwt
        JwtAuthGuard["JwtAuthGuard"]:::jwt
        UserEntity["UserEntity"]:::entity
        ProduitEntityAuth["ProduitEntity"]:::entity
    end

    %% Categorie Module
    subgraph "Categorie Module"
        CategorieModule["CategorieModule"]:::module
        CategorieController["CategorieController"]:::controller
        CategorieService["CategorieService"]:::service
        CategorieEntity["CategorieEntity"]:::entity
        CreateCategorieDto["CreateCategorieDto"]:::dto
        UpdateCategorieDto["UpdateCategorieDto"]:::dto
    end

    %% Produit Module
    subgraph "Produit Module"
        ProduitModule["ProduitModule"]:::module
        ProduitsController["ProduitsController"]:::controller
        ProduitsService["ProduitsService"]:::service
    end

    %% Database
    DB["SQLite Database<br/>db.sqlite"]:::database

    %% Connections
    Client -->|calls HTTP| AuthController
    Client -->|calls HTTP| CategorieController
    Client -->|calls HTTP| ProduitsController

    Main -->|boots| AppModule
    AppModule --> AuthModule
    AppModule --> CategorieModule
    AppModule --> ProduitModule
    AppModule --> AppController

    AppController -->|uses| AppService

    %% Auth flow
    AuthController -->|calls| AuthService
    ProfileController -->|calls| AuthService
    AuthService -->|uses| UserEntity
    AuthService -->|uses| ProduitEntityAuth
    AuthService -->|uses| JwtStrategy
    AuthController -->|protected by| JwtAuthGuard

    UserEntity -->|persist| DB
    ProduitEntityAuth -->|persist| DB

    %% Categorie flow
    CategorieController -->|calls| CategorieService
    CategorieService -->|uses| CategorieEntity
    CategorieEntity -->|persist| DB
    CategorieController -->|validates| CreateCategorieDto
    CategorieController -->|validates| UpdateCategorieDto

    %% Produit flow
    ProduitsController -->|calls| ProduitsService
    ProduitsService -->|uses| ProduitEntityAuth
    ProduitEntityAuth -->|persist| DB

    %% Click events
    click Main "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/main.ts"
    click AppModule "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/app.module.ts"
    click AppController "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/app.controller.ts"
    click AppService "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/app.service.ts"

    click AuthModule "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/auth/auth.module.ts"
    click AuthController "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/auth/auth.controller.ts"
    click ProfileController "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/auth/profile.controller.ts"
    click AuthService "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/auth/auth.service.ts"
    click UserEntity "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/auth/user.entity.ts"
    click ProduitEntityAuth "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/auth/produit.entity.ts"
    click JwtStrategy "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/auth/jwt.strategy.ts"
    click JwtAuthGuard "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/auth/jwt-auth.guard.ts"

    click CategorieModule "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/categorie/categorie.module.ts"
    click CategorieController "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/categorie/categorie.controller.ts"
    click CategorieService "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/categorie/categorie.service.ts"
    click CategorieEntity "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/categorie/categorie.entity.ts"
    click CreateCategorieDto "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/categorie/dto/createCategorieDto.ts"
    click UpdateCategorieDto "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/categorie/dto/updateCategorieDto.ts"

    click ProduitModule "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/produit/produits.module.ts"
    click ProduitsController "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/produit/produits.controller.ts"
    click ProduitsService "https://github.com/papysaliou/nestjs_ecommerce_backend/blob/main/src/produit/produits.service.ts"

    %% Styles
    classDef client fill:#eef,stroke:#88a,stroke-width:2px
    classDef bootstrap fill:#ffd,stroke:#da0,stroke-width:2px
    classDef module fill:#def,stroke:#58a,stroke-width:2px
    classDef controller fill:#fdd,stroke:#d44,stroke-width:2px
    classDef service fill:#dfd,stroke:#4a4,stroke-width:2px
    classDef entity fill:#ddf,stroke:#44a,stroke-width:2px
    classDef dto fill:#fff5cc,stroke:#cc9,stroke-width:2px
    classDef jwt fill:#fce,stroke:#c58,stroke-width:2px
    classDef database fill:#eee,stroke:#666,stroke-width:2px,stroke-dasharray: 5 5
```
