# nish-mitha/qp-assessment architecture

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

- Interactive diagram: https://gitdiagram.com/nish-mitha/qp-assessment
- Repository: https://github.com/nish-mitha/qp-assessment

## Overview

Based on our analysis of the file tree and README, this project is a full-stack grocery booking system comprising two main services:

##### Backend Service (grocery-booking-api)
- Built on the NestJS framework.
- Utilizes TypeORM for managing a PostgreSQL database.
- Implements two main role-based endpoints for Admin and User operations.

##### Frontend Service (grocery-booking-app)
- Developed using Angular.
- Provides distinct user interfaces for both admin and user roles.
- Dockerized for container deployment alongside the API service.

a. Frontend (grocery-booking-app):
- This using a block labeled “Angular UI (grocery-booking-app)”.
- Sub-components or modules if needed (e.g., Admin Dashboard, User Booking Interface, Common components for header, dialogs, etc.)
b. Backend (grocery-booking-api):
- With a block labeled “NestJS API Service (grocery-booking-api)”.
- Inside, denote sub-modules like “Admin Module”, “User Module”, “Database Module”, “Common/Utils” (for filters, DTOs, swagger schemas).
- Existence of configuration files and environment setups (.env, docker configurations) that enable containerized deployments.
c. Database:
- A “PostgreSQL Database” block.
- Specific tables (tbl_grocery_items and tbl_cart) and mention that data operations are handled via TypeORM.
d. Additional Deployment/Containerization Layers:
- “Docker” containers enveloping backend and frontend services.
- Optionally, add cloud deployment services (Render for backend and ElephantSQL for the PostgreSQL database) to indicate live hosting.

##### Relationships and Data Flows
- How each component is deployed (Docker containers managed by docker-compose locally, Render/ElephantSQL in live environments).

##### Important Architectural Patterns and Technologies
- Point out the role-based split in the backend (admin vs. user endpoints).
- Modular separation in the NestJS API (modules for admin, user, database, and common functionalities).
- How the Angular frontend is structured with components, services, and routing that align with the project’s UI flow.
- Containerized architecture provided by Docker for both services, hinting at microservice separation even in a single repository.

##### Additional Specifics
- Under the “NestJS API Service” block, indicate sub-modules such as “Admin Module”, “User Module”, “Database Module”, and “Common (e.g., Filters, DTOs, Swagger Schemas)” to reflect the file structure.
- How the Docker Compose orchestration ties together both services for local development.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Service (Angular)"
        F1["Angular UI (grocery-booking-app)"]:::frontend
        F2["Admin Dashboard (Angular)"]:::frontend
        F3["User Booking Interface (Angular)"]:::frontend
        F4["Common Angular Components"]:::frontend
    end

    subgraph "Backend Service (NestJS API)"
        B1["NestJS API Service (grocery-booking-api)"]:::backend
        B2["Admin Module (NestJS)"]:::backend
        B3["User Module (NestJS)"]:::backend
        B4["Database Module (NestJS/TypeORM)"]:::backend
        B4a["Entities (TypeORM)"]:::backend
        B5["Common (NestJS)"]:::backend
        B6["Common (Filters & DTOs)"]:::backend
        B7["Swagger Schemas"]:::backend
    end

    subgraph "Database"
        DB["PostgreSQL Database\n(tbl_grocery_items, tbl_cart)"]:::database
    end

    subgraph "Deployment"
        D1["Docker Compose Orchestration"]:::deployment
        D2["Docker Config (API)"]:::deployment
        D3["Docker Config (App)"]:::deployment
        D4["Cloud Deployment (Render & ElephantSQL)"]:::deployment
    end

    %% Inter-service Relationships
    F1 -->|"REST_API"| B1
    B1 -->|"TypeORM_Operations"| DB

    %% Backend internal module relationships
    B1 --> B2
    B1 --> B3
    B1 --> B4
    B4 --> B4a
    B1 --> B5
    B1 --> B6
    B1 --> B7

    %% Frontend internal component relationships
    F1 --> F2
    F1 --> F3
    F1 --> F4

    %% Deployment relationships
    D1 --> F1
    D1 --> B1
    D1 --> DB
    D2 --> B1
    D3 --> F1
    D4 --> B1
    D4 --> DB

    %% Click Events for Frontend Components
    click F1 "https://github.com/nish-mitha/qp-assessment/tree/main/grocery-booking-app/"
    click F2 "https://github.com/nish-mitha/qp-assessment/tree/main/grocery-booking-app/src/app/pages/admin/"
    click F3 "https://github.com/nish-mitha/qp-assessment/tree/main/grocery-booking-app/src/app/pages/user/"
    click F4 "https://github.com/nish-mitha/qp-assessment/tree/main/grocery-booking-app/src/app/common/"

    %% Click Events for Backend Components
    click B1 "https://github.com/nish-mitha/qp-assessment/tree/main/grocery-booking-api/"
    click B2 "https://github.com/nish-mitha/qp-assessment/tree/main/grocery-booking-api/src/admin/"
    click B3 "https://github.com/nish-mitha/qp-assessment/tree/main/grocery-booking-api/src/user/"
    click B4 "https://github.com/nish-mitha/qp-assessment/tree/main/grocery-booking-api/src/database/"
    click B4a "https://github.com/nish-mitha/qp-assessment/tree/main/grocery-booking-api/src/database/entities/"
    click B5 "https://github.com/nish-mitha/qp-assessment/tree/main/grocery-booking-api/src/common/"
    click B6 "https://github.com/nish-mitha/qp-assessment/tree/main/grocery-booking-api/src/filters/"
    click B7 "https://github.com/nish-mitha/qp-assessment/tree/main/grocery-booking-api/src/swagger/"

    %% Click Events for Deployment Components
    click D1 "https://github.com/nish-mitha/qp-assessment/blob/main/docker-compose.yaml"
    click D2 "https://github.com/nish-mitha/qp-assessment/tree/main/grocery-booking-api/docker/Dockerfile"
    click D3 "https://github.com/nish-mitha/qp-assessment/tree/main/grocery-booking-app/docker/Dockerfile"

    %% Styles
    classDef frontend fill:#b3cde0,stroke:#03396c,stroke-width:2px;
    classDef backend fill:#ccebc5,stroke:#006400,stroke-width:2px;
    classDef database fill:#fbb4ae,stroke:#d53f8c,stroke-width:2px;
    classDef deployment fill:#decbe4,stroke:#6a51a3,stroke-width:2px;
```
