# iamadityaraj02/quick-bite architecture

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

- Interactive diagram: https://gitdiagram.com/iamadityaraj02/quick-bite
- Repository: https://github.com/iamadityaraj02/quick-bite

## Overview

##### Project Type and Purpose
- Quick Bite is a full-stack, microservices-based QR ordering system using clean architecture.
- It spans multiple frontends (customer, admin, staff, kitchen), a suite of backend services (API Gateway, order processor, notification), shared/domain packages, and AWS infrastructure.

##### File Structure
- apps/ – Contains Next.js “App Router” frontends:
– web/ (customer site)
– implicitly admin/ and staff/ under web/app (monorepo uses a single Next.js app with route groups)
- packages/ – Monorepo packages:
– core/ (domain entities, use cases, ports)
– shared/ (utilities, types)
– ui/ (reusable React components)
- services/ – Independent Node.js services (Fastify + TS + Zod):
– api-gateway/
– order-processor/
– notification/
- infrastructure/terraform/ – IaC definitions for AWS (RDS, S3, SQS, Lambda, API Gateway, CloudFront).
- docker-compose.yml & Makefile – local development orchestration.
- turbo.json – TurboRepo configuration.

##### README for Insights
- Confirms Clean Architecture layers: Presentation, Application (use cases/DTOs/validators), Domain (entities/value-objects).
- Lists AWS services and tech stack.
- Describes feature set (QR ordering, real-time updates, RBAC).

##### Main Components
A. Presentation Layer (Client Apps)
– Customer Web (Next.js @ port 3000)
– Admin Panel (Next.js @ 3001)
– Staff / Kitchen Interfaces (Next.js route groups)
B. API Layer
– API Gateway service (Fastify)
– Auth, menu, orders, admin routes
C. Business Logic Layer (Application & Domain)
– core package (use-cases, entities)
– shared package
D. Backend Services
– Order Processor (consumes new-order events from SQS)
– Notification Service (publishes real-time updates via WebSocket or push)
E. Data Stores & Infrastructure (AWS)
– AWS RDS (PostgreSQL via Drizzle ORM)
– Redis (cache & sessions)
– AWS S3 (file storage)
– AWS SQS (order queue)
– AWS Lambda (serverless deploys)
– AWS API Gateway (managed HTTP endpoint)
– AWS CloudFront (CDN for web assets)

##### Relationships & Data Flows
1. User → Next.js Frontend → calls API Gateway (HTTPS)
2. API Gateway →
- Drizzle ORM → RDS (Postgres)
- Redis for session/cache
- Publishes order events to SQS
3. Order Processor → pulls from SQS → executes create-order use case → updates DB → publishes status updates
4. Notification Service → subscribes to status events (could be via SNS or direct SQS) → pushes real-time updates to frontends (WebSocket or polling)
5. Admin & Staff UIs → call admin routes on API Gateway → perform CRUD on menu/orders

##### Architectural Patterns & Principles
- Clean Architecture (layered onion):
– Outer: Presentation (Next.js + React)
– Middle: Application (use cases, DTOs)
– Inner: Domain (entities, value objects)
- Microservices: independent “api-gateway”, “order-processor”, “notification” services
- Monorepo with TurboRepo: shared packages (core, ui, shared)
- Infrastructure as Code: Terraform (infrastructure/terraform)
- CI/CD via Makefile and scripts

##### Elements
- Clear labels: component name + tech (e.g., “API Gateway (Fastify + TypeScript)”)

##### Final Touches & Detail
- Call out route handlers in api-gateway (auth, menu, orders, admin).
- Local development stack (Docker Compose) at the bottom, connected to local databases.
- Terraform folder → maps to AWS resources in the cloud group.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser Clients
    subgraph "Browser Clients"
        direction TB
        CW["Customer Web\n(Next.js)"]:::frontend
        AP["Admin Panel\n(Next.js)"]:::frontend
        ST["Staff/Kitchen Interfaces\n(Next.js)"]:::frontend
    end

    %% Monorepo Packages
    subgraph "Monorepo Shared Packages"
        direction TB
        UI["UI Components Library"]:::frontend
        SH["Shared Utilities & Types"]:::backend
        CO["Core Domain & Application"]:::backend
    end

    %% AWS Cloud
    subgraph "AWS Cloud"
        direction TB
        AG["API Gateway\n(Fastify + TypeScript)"]:::backend
        RDS["Amazon RDS\n(PostgreSQL)"]:::datastore
        REDIS["Redis\n(Cache & Sessions)"]:::datastore
        S3["Amazon S3\n(File Storage)"]:::infra
        SQS["Amazon SQS\n(Order Queue)"]:::queue
        SNSTOPIC["SNS Topic\n(Status Events)"]:::queue
        CF["CloudFront\n(CDN)"]:::infra
        LAMBDA["AWS Lambda\n(Serverless)"]:::infra
    end

    %% Microservices
    subgraph "Microservices"
        direction TB
        OP["Order Processor Service"]:::backend
        NS["Notification Service"]:::backend
    end

    %% Local Development
    subgraph "Local Development"
        direction TB
        DC["Docker Compose"]:::infra
        MF["Makefile"]:::infra
    end

    %% Connections
    CW -->|"HTTPS POST /orders"| AG
    AP -->|"HTTPS"| AG
    ST -->|"HTTPS"| AG

    AG -->|"Drizzle ORM reads/writes"| RDS
    AG -->|"session/cache"| REDIS
    AG -->|"S3 uploads/downloads"| S3
    AG -->|"SQS: new-order"| SQS

    SQS -->|"consume new-order"| OP
    OP -->|"Drizzle ORM writes"| RDS
    OP -->|"SQS: order-status"| SNSTOPIC

    SNSTOPIC -->|"subscribe status"| NS
    NS -->|"WebSocket push"| CW
    NS -->|"WebSocket push"| AP
    NS -->|"WebSocket push"| ST

    %% Package Dependencies
    CW --> UI
    AP --> UI
    ST --> UI
    CW --> SH
    AP --> SH
    ST --> SH

    AG --> CO
    OP --> CO
    NS --> CO

    AG --> SH

    %% Terraform to AWS
    subgraph "Infrastructure as Code"
        direction TB
        TF["Terraform\n(infrastructure/terraform)"]:::infra
    end
    TF --> AG
    TF --> RDS
    TF --> REDIS
    TF --> S3
    TF --> SQS
    TF --> CF
    TF --> LAMBDA

    %% Local Dev orchestration
    DC --> AG
    DC --> OP
    DC --> NS
    MF --> DC

    %% Click Events
    click CW "https://github.com/iamadityaraj02/quick-bite/tree/main/apps/web"
    click AP "https://github.com/iamadityaraj02/quick-bite/tree/main/apps/web/app/admin"
    click ST "https://github.com/iamadityaraj02/quick-bite/tree/main/apps/web/app/staff"
    click UI "https://github.com/iamadityaraj02/quick-bite/blob/main/packages/ui/src/index.ts"
    click SH "https://github.com/iamadityaraj02/quick-bite/blob/main/packages/shared/src/index.ts"
    click CO "https://github.com/iamadityaraj02/quick-bite/tree/main/packages/core/src"
    click AG "https://github.com/iamadityaraj02/quick-bite/blob/main/services/api-gateway/src/index.ts"
    click AG "https://github.com/iamadityaraj02/quick-bite/blob/main/services/api-gateway/src/routes/auth.ts"
    click AG "https://github.com/iamadityaraj02/quick-bite/blob/main/services/api-gateway/src/routes/menu.ts"
    click AG "https://github.com/iamadityaraj02/quick-bite/blob/main/services/api-gateway/src/routes/orders.ts"
    click AG "https://github.com/iamadityaraj02/quick-bite/blob/main/services/api-gateway/src/routes/admin.ts"
    click AG "https://github.com/iamadityaraj02/quick-bite/blob/main/services/api-gateway/src/db/schema.ts"
    click AG "https://github.com/iamadityaraj02/quick-bite/blob/main/services/api-gateway/src/db/client.ts"
    click AG "https://github.com/iamadityaraj02/quick-bite/blob/main/services/api-gateway/sql/init.sql"
    click AG "https://github.com/iamadityaraj02/quick-bite/blob/main/services/api-gateway/drizzle.config.ts"
    click OP "https://github.com/iamadityaraj02/quick-bite/blob/main/services/order-processor/src/index.ts"
    click NS "https://github.com/iamadityaraj02/quick-bite/blob/main/services/notification/src/index.ts"
    click TF "https://github.com/iamadityaraj02/quick-bite/blob/main/infrastructure/terraform/main.tf"
    click TF "https://github.com/iamadityaraj02/quick-bite/blob/main/infrastructure/terraform/variables.tf"
    click DC "https://github.com/iamadityaraj02/quick-bite/blob/main/docker-compose.yml"
    click MF "https://github.com/iamadityaraj02/quick-bite/tree/main/Makefile"
    click TURBO "https://github.com/iamadityaraj02/quick-bite/blob/main/turbo.json"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#1e88e5,stroke-width:1px
    classDef backend fill:#c8e6c9,stroke:#43a047,stroke-width:1px
    classDef datastore fill:#ffe0b2,stroke:#fb8c00,stroke-width:1px
    classDef queue fill:#e1bee7,stroke:#8e24aa,stroke-width:1px
    classDef infra fill:#f5f5f5,stroke:#9e9e9e,stroke-width:1px
```
