# luandz123/basket-fl-shop architecture

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

- Interactive diagram: https://gitdiagram.com/luandz123/basket-fl-shop
- Repository: https://github.com/luandz123/basket-fl-shop

## Overview

##### Main Components
- Frontend: Built with Next.js. It consists of several pages (home, about, products, product details, login, register, checkout, etc.), custom components (e.g., Navbar, Footer, ProductCard), and API routes (for images and potentially server-side logic).
- Backend: A NestJS application assembled in modules for clean separation. Its modules include authentication, cart, categories, orders, payment, products, and users. There are also database migrations and entity definitions to support a relational database.
- Database: Although not explicitly spelled out, the presence of an SQL dump file (Dump20250402.sql) and migration scripts indicates a relational database backing the system.
- Infrastructure Components: Containers (Dockerfile, .dockerignore), deployment configurations (Railway, Vercel, and files like Procfile), and environment setup files which help in managing production and development deployments.

##### Relationships and Interactions
- Backend Processing: Within the backend, request processing is routed through NestJS controllers. Each module (auth, products, cart, etc.) encapsulates its own service and data models, managing business logic and interacting with the database.
- Deployment & Infrastructure: Note Docker and deployment platforms (Railway for the backend and Vercel for the frontend). Show environmental boundaries and deployment pipelines. For instance, Docker builds can package the backend while configuration files (e.g., vercel.json) handle the frontend deployment.

##### Architectural Patterns and Design Principles
- Modularity: The backend is split into numerous modules (auth, cart, products, orders, etc.), each encapsulating its own functionality. This is aligned with the microservice-like approach within a monorepo architecture.
- MVC/Controller-Service Pattern: The backend follows a typical NestJS setup with controllers (handling API endpoints), services (business logic), and entities (database models).
- Separation of Concerns: The system is clearly divided between the frontend presentation layer and the backend API/data management layer.
- API Layer: There is an explicit API layer communications, as seen in both frontend API routes (within the /app/api folder) and the numerous controller endpoints defined in the backend.

## Diagram (Mermaid)

```mermaid
flowchart TD

    Client["Browser/Client"]:::client

    subgraph "Frontend - Next.js"
        FE["Next.js Application"]:::frontend
        subgraph "Pages"
            Home["Home Page"]:::frontend
            About["About Page"]:::frontend
            Products["Products Page"]:::frontend
            Cart["Cart Page"]:::frontend
            Checkout["Checkout Page"]:::frontend
            Login["Login Page"]:::frontend
            Register["Register Page"]:::frontend
        end
        UI["UI Components"]:::frontend
        APIImages["API Routes - Images"]:::frontend
    end

    subgraph "Backend - NestJS"
        BEEntry["NestJS Entry (main.ts)"]:::backend
        AppModule["App Module (app.module.ts)"]:::backend
        subgraph "Modules"
            Auth["Authentication Module"]:::backend
            CartMod["Cart Module"]:::backend
            CatMod["Categories Module"]:::backend
            OrdMod["Orders Module"]:::backend
            PayMod["Payment Module"]:::backend
            ProdMod["Products Module"]:::backend
            UserMod["Users Module"]:::backend
        end
        Migrations["Migrations"]:::backend
        DataSource["Data Source"]:::backend
        SQLDump["SQL Dump"]:::backend
    end

    subgraph "Database (Relational SQL)"
        DB["SQL Database"]:::database
    end

    subgraph "Infrastructure"
        subgraph "Backend Deployment"
            Dockerfile["Dockerfile"]:::infrastructure
            DockerIgnore[".dockerignore"]:::infrastructure
            Procfile["Procfile"]:::infrastructure
            Env[".env"]:::infrastructure
            EnvRailway[".env.railway"]:::infrastructure
            RailwayJson["railway.json"]:::infrastructure
            BEVercel["Backend Vercel Config"]:::infrastructure
        end
        subgraph "Frontend Deployment"
            FEVercel["Vercel Config (Frontend)"]:::infrastructure
            NextConfig["Next.js Config"]:::infrastructure
        end
        IRailway["Railway (Backend Hosting)"]:::infrastructureCloud
        IVercel["Vercel (Frontend Hosting)"]:::infrastructureCloud
    end

    Client -->|"HTTPRequest"| FE
    FE -->|"Renders"| Home
    FE -->|"Renders"| About
    FE -->|"Renders"| Products
    FE -->|"Renders"| Cart
    FE -->|"Renders"| Checkout
    FE -->|"Renders"| Login
    FE -->|"Renders"| Register
    FE -->|"Uses"| UI
    FE -->|"Calls"| APIImages
    FE -->|"API Call"| BEEntry

    BEEntry -->|"Bootstraps"| AppModule
    AppModule -->|"Routes_to"| Auth
    AppModule -->|"Routes_to"| CartMod
    AppModule -->|"Routes_to"| CatMod
    AppModule -->|"Routes_to"| OrdMod
    AppModule -->|"Routes_to"| PayMod
    AppModule -->|"Routes_to"| ProdMod
    AppModule -->|"Routes_to"| UserMod

    Auth -->|"CRUD"| DB
    CartMod -->|"CRUD"| DB
    CatMod -->|"CRUD"| DB
    OrdMod -->|"CRUD"| DB
    PayMod -->|"CRUD"| DB
    ProdMod -->|"CRUD"| DB
    UserMod -->|"CRUD"| DB

    Migrations -->|"Migrate"| DB
    DataSource -->|"Connects"| DB
    SQLDump -->|"Restores"| DB

    BEEntry ---|"Containerized"| Dockerfile
    BEEntry ---|"Deployment"| Procfile
    Dockerfile ---|"UsedBy"| IRailway
    Procfile ---|"UsedBy"| IRailway
    AppModule ---|"ConfiguredBy"| BEVercel
    FE ---|"ConfiguredBy"| FEVercel
    FE ---|"ConfiguredBy"| NextConfig
    FEVercel ---|"Deploys_to"| IVercel

    click FE "https://github.com/luandz123/basket-fl-shop/tree/main/frontend/"
    click Home "https://github.com/luandz123/basket-fl-shop/blob/main/frontend/src/app/page.tsx"
    click About "https://github.com/luandz123/basket-fl-shop/tree/main/frontend/src/app/about"
    click Products "https://github.com/luandz123/basket-fl-shop/tree/main/frontend/src/app/products"
    click Cart "https://github.com/luandz123/basket-fl-shop/tree/main/frontend/src/app/cart"
    click Checkout "https://github.com/luandz123/basket-fl-shop/tree/main/frontend/src/app/checkout"
    click Login "https://github.com/luandz123/basket-fl-shop/tree/main/frontend/src/app/login"
    click Register "https://github.com/luandz123/basket-fl-shop/tree/main/frontend/src/app/register"
    click UI "https://github.com/luandz123/basket-fl-shop/tree/main/frontend/src/components"
    click APIImages "https://github.com/luandz123/basket-fl-shop/tree/main/frontend/src/app/api/images"
    click BEEntry "https://github.com/luandz123/basket-fl-shop/blob/main/backend/src/main.ts"
    click AppModule "https://github.com/luandz123/basket-fl-shop/blob/main/backend/src/app.module.ts"
    click Auth "https://github.com/luandz123/basket-fl-shop/tree/main/backend/src/auth"
    click CartMod "https://github.com/luandz123/basket-fl-shop/tree/main/backend/src/cart"
    click CatMod "https://github.com/luandz123/basket-fl-shop/tree/main/backend/src/categories"
    click OrdMod "https://github.com/luandz123/basket-fl-shop/tree/main/backend/src/orders"
    click PayMod "https://github.com/luandz123/basket-fl-shop/tree/main/backend/src/payment"
    click ProdMod "https://github.com/luandz123/basket-fl-shop/tree/main/backend/src/products"
    click UserMod "https://github.com/luandz123/basket-fl-shop/tree/main/backend/src/users"
    click Migrations "https://github.com/luandz123/basket-fl-shop/tree/main/backend/src/migrations"
    click DataSource "https://github.com/luandz123/basket-fl-shop/blob/main/backend/src/data-source.ts"
    click SQLDump "https://github.com/luandz123/basket-fl-shop/blob/main/backend/Dump20250402.sql"
    click Dockerfile "https://github.com/luandz123/basket-fl-shop/tree/main/backend/Dockerfile"
    click DockerIgnore "https://github.com/luandz123/basket-fl-shop/blob/main/backend/.dockerignore"
    click Procfile "https://github.com/luandz123/basket-fl-shop/tree/main/backend/Procfile"
    click Env "https://github.com/luandz123/basket-fl-shop/blob/main/backend/.env"
    click EnvRailway "https://github.com/luandz123/basket-fl-shop/blob/main/backend/.env.railway"
    click RailwayJson "https://github.com/luandz123/basket-fl-shop/blob/main/backend/railway.json"
    click BEVercel "https://github.com/luandz123/basket-fl-shop/blob/main/backend/vercel.json"
    click FEVercel "https://github.com/luandz123/basket-fl-shop/blob/main/frontend/vercel.json"
    click NextConfig "https://github.com/luandz123/basket-fl-shop/blob/main/frontend/next.config.js"

    classDef frontend fill:#ffdbac,stroke:#333,stroke-width:2px;
    classDef backend fill:#d0e6a5,stroke:#333,stroke-width:2px;
    classDef database fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#e0bbff,stroke:#333,stroke-width:2px;
    classDef infrastructureCloud fill:#ffe0ac,stroke:#333,stroke-width:2px;
    classDef client fill:#c1f7dc,stroke:#333,stroke-width:2px;
```
