# mkunboxing/quicky architecture

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

- Interactive diagram: https://gitdiagram.com/mkunboxing/quicky
- Repository: https://github.com/mkunboxing/quicky

## Overview

##### Main Components
- Client-Facing Frontend: Located mainly under src/app/(client). This includes pages such as the homepage, product details, contact, account management (orders), delivery, and payment results. Also include shared UI components (header, footer, hero elements, etc.) under src/app/(client)/_components.
- Administration Interface: Found under src/app/admin with its own layout and dedicated pages (orders, inventories, products, warehouses, delivery persons). This section also contains its UI components (data table, sidebar, etc.).
- API Endpoints: Under src/app/api, there are RESTful or possibly Next.js Route Handlers for handling various actions (e.g., orders, auth, delivery-persons, inventories, products, warehouses, verify-payment). This shows the separation between UI and business logic.
- Database & Migrations: The “drizzle” folder along with drizzle.config.ts and files under src/lib/db indicate that the project uses a migration system (Drizzle ORM) with SQL migrations and corresponding schema definitions. Also include “drizzle/meta” for schema snapshots and versioning.
- State Management & Utility Services: The project includes a global store (src/store) for managing state related to products, orders, deliveries, etc., along with utility libraries (src/lib), authentication options, and API/client utilities (src/http).
- External Dependencies / Auth Providers: Key libraries include Next.js, Drizzle ORM, and integration with Supabase (src/lib/supabase.ts) along with custom font optimizations from next/font.

##### Relationships and Interactions
- Frontend Clients (both client and admin views) interact with API endpoints via HTTP or Next.js-specific routing conventions.
- API routes interact with the database layer (managed via Drizzle migrations, and schema definitions in src/lib/db) to read/write persistent data.
- UI components make use of centralized stores and validation utilities to manage state and validate user data.
- Authentication flows (in src/app/api/auth and src/lib/auth) encapsulate security aspects and tie into both API services and frontend providers.
- Providers (auth-provider, query-provider) wrap the application to manage user sessions and asynchronous data fetching.

##### Architectural Patterns & Design Principles
- Separation of Concerns: Clear separation between presentation (client/admin pages), business logic (API endpoints), data persistence (database migrations and ORM), and state management (stores).
- Modularization: Organized file structure separates concerns by context (client vs. admin), supporting a modular approach to component reuse.
- API-centric Communication: API routes serve as a clear boundary between the server-side logic and frontend, making it easier to manage data flow.
- Use of Providers: The providers encapsulate global concerns (auth, query management) and help decouple the UI from direct integration with lower-level services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Frontend Subgraph
    subgraph "Client Frontend"
        ClientPages["Client Pages"]:::frontend
        ClientUI["Client UI Components"]:::frontend
        SharedUI["Shared UI Components"]:::frontend
    end

    %% Administration Interface Subgraph
    subgraph "Admin Interface"
        AdminDashboard["Admin Dashboard"]:::frontend
        AdminUI["Admin UI Components"]:::frontend
    end

    %% Backend/API Layer Subgraph
    subgraph "Backend/API Layer"
        GenericAPI["Generic API Endpoints"]:::backend
        AuthAPI["Authentication Endpoints"]:::backend
    end

    %% Database & Migrations Subgraph
    subgraph "Database & Migrations"
        DrizzleMigrations["Drizzle Migrations"]:::database
        DrizzleConfig["Drizzle Config"]:::database
        DBSchema["DB Schema"]:::database
    end

    %% State Management & Utilities Subgraph
    subgraph "State Management & Utilities"
        StateStores["State Management Stores"]:::state
        UtilModules["Utility Modules"]:::state
        HttpClient["HTTP Client Utilities"]:::state
    end

    %% Authentication & Providers Subgraph
    subgraph "Authentication & Providers"
        AuthUtil["Auth Utilities"]:::auth
        AuthProviders["Auth Providers"]:::auth
    end

    %% Connections between components
    ClientPages -->|"HTTPCall"| GenericAPI
    AdminDashboard -->|"HTTPCall"| GenericAPI
    GenericAPI -->|"CRUD"| DBSchema

    ClientUI -->|"StateUpdate"| StateStores
    AdminUI -->|"StateUpdate"| StateStores
    SharedUI -->|"StateUpdate"| StateStores

    AuthProviders -->|"Auth"| AuthAPI
    AuthProviders -->|"Session"| ClientPages

    AuthUtil -->|"Provides"| AuthProviders
    HttpClient -->|"APIHandle"| GenericAPI

    %% Click Events
    click ClientPages "https://github.com/mkunboxing/quicky/tree/master/src/app/(client)"
    click ClientUI "https://github.com/mkunboxing/quicky/tree/master/src/app/(client)/_components"
    click SharedUI "https://github.com/mkunboxing/quicky/tree/master/src/components/ui"
    click AdminDashboard "https://github.com/mkunboxing/quicky/tree/master/src/app/admin"
    click AdminUI "https://github.com/mkunboxing/quicky/tree/master/src/app/admin/_components"
    click GenericAPI "https://github.com/mkunboxing/quicky/tree/master/src/app/api"
    click AuthAPI "https://github.com/mkunboxing/quicky/tree/master/src/app/api/auth"
    click DrizzleMigrations "https://github.com/mkunboxing/quicky/tree/master/drizzle"
    click DrizzleConfig "https://github.com/mkunboxing/quicky/blob/master/drizzle.config.ts"
    click DBSchema "https://github.com/mkunboxing/quicky/blob/master/src/lib/db/schema.ts"
    click StateStores "https://github.com/mkunboxing/quicky/tree/master/src/store"
    click UtilModules "https://github.com/mkunboxing/quicky/tree/master/src/lib"
    click HttpClient "https://github.com/mkunboxing/quicky/tree/master/src/http"
    click AuthUtil "https://github.com/mkunboxing/quicky/tree/master/src/lib/auth"
    click AuthProviders "https://github.com/mkunboxing/quicky/tree/master/src/providers"

    %% Styles
    classDef frontend fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef backend fill:#FFE0B2,stroke:#E65100,stroke-width:2px;
    classDef database fill:#E1BEE7,stroke:#6A1B9A,stroke-width:2px;
    classDef state fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef auth fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
```
