# nduongg04/se100.p12-cafe architecture

> Architecture diagram of the GitHub repository nduongg04/se100.p12-cafe, 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/nduongg04/se100.p12-cafe
- Repository: https://github.com/nduongg04/se100.p12-cafe

## Overview

##### Main Components
- Client/Presentation Layer:
- Next.js Frontend with separate route segments like “admin”, “employee”, “login”, “feedback”, etc.
- Shared UI components (under components/ui) and domain-specific components (under components/admin and components/employee).
- Global styles and assets (app/globals.css, public/assets).

- Server/Business Logic Layer:
- API Routes: The app/api directory (e.g. export-analytics) which handles API requests.
- Lib modules: Directories such as /lib/actions and /lib/apis represent business rules and API calling logic.
- Authentication & Utility functions (lib/auth.ts, middleware.ts, etc.)

- Configuration & Deployment:
- Next.js configuration (next.config.mjs, tailwind.config.ts, tsconfig.json)
- Build and deployment settings (GitHub workflows, Vercel deployment instructions in the README)

##### Out Interactions and Data Flow
- From the browser, users first interact with the Next.js pages (e.g., login, admin/dashboard, employee views).
- The Next.js server uses middleware (e.g., middleware.ts) to manage authentication and routing.
- When a user requests data (for example, on an admin page), the frontend components make calls via the client layer. This can involve:
- API calls to server routes in app/api, which then utilize business logic in the lib directory.
- Directly invoking utility functions to fetch or manipulate data.
- The components then render the results using either server-side or client-side rendering.

##### Architectural Patterns
- Separation of Concerns: Each major feature (admin vs. employee) has its dedicated folder with clear boundaries for page components, data fetching logic, and reusable UI components.
- Modular Design: Use of lib/actions and lib/apis to encapsulate business logic and API interactions ensures that the front-end remains decoupled from data manipulation code.
- Component Reusability: Distinct directories for shared UI components (components/ui) support a reusable and extensible design.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client / Presentation Layer
    subgraph "Client/Presentation Layer"
        A("Browser"):::client
        B("Next.js Frontend"):::client
        B1("Admin Routes"):::client
        B2("Employee Routes"):::client
        B3("Login Route"):::client
        B4("Feedback Route"):::client
        B5("Page Component"):::client
        B6("Layout Component"):::client
        B7("Providers Component"):::client
        B8("Shared UI Components"):::client
        B9("Admin UI Components"):::client
        B10("Employee UI Components"):::client
        B11("Global Styles"):::client
        B12("Static Assets"):::client
    end

    %% Server / Business Logic Layer
    subgraph "Server/Business Logic Layer"
        S1("API: Export Analytics"):::server
        S2("Business Logic Actions"):::server
        S3("Business Logic API Helpers"):::server
        S4("Middleware & Auth"):::server
    end

    %% Configuration & Deployment
    subgraph "Configuration & Deployment"
        C1("Next.js Config"):::config
        C2("Tailwind Config"):::config
        C3("TypeScript Config"):::config
        C4("GitHub Workflow"):::config
        D1("Vercel Deployment"):::external
    end

    %% Data Flow - Client Layer
    A --> B
    B --> B1
    B --> B2
    B --> B3
    B --> B4
    B --> B5
    B --> B6
    B --> B7
    B --> B8
    B --> B9
    B --> B10
    B --> B11
    B --> B12

    %% Interaction: Frontend invoking Server/Business Logic Layer
    B -->|"calls"| S1
    B -->|"auth-check"| S4
    S1 -->|"uses"| S2
    S1 -->|"uses"| S3

    %% Configuration supporting both Client and Server
    C1 --- B
    C2 --- B
    C3 --- B
    C4 --- B
    C1 --- S1
    C2 --- S1
    C3 --- S1
    C4 --- S1

    %% Deployment integration
    B --> D1
    S1 --> D1

    %% Click Events for Client/Presentation Layer
    click B1 "https://github.com/nduongg04/se100.p12-cafe/tree/main/app/admin"
    click B2 "https://github.com/nduongg04/se100.p12-cafe/tree/main/app/employee"
    click B3 "https://github.com/nduongg04/se100.p12-cafe/tree/main/app/login"
    click B4 "https://github.com/nduongg04/se100.p12-cafe/tree/main/app/feedback"
    click B5 "https://github.com/nduongg04/se100.p12-cafe/blob/main/app/page.tsx"
    click B6 "https://github.com/nduongg04/se100.p12-cafe/blob/main/app/layout.tsx"
    click B7 "https://github.com/nduongg04/se100.p12-cafe/blob/main/app/providers.tsx"
    click B8 "https://github.com/nduongg04/se100.p12-cafe/tree/main/components/ui"
    click B9 "https://github.com/nduongg04/se100.p12-cafe/tree/main/components/admin"
    click B10 "https://github.com/nduongg04/se100.p12-cafe/tree/main/components/employee"
    click B11 "https://github.com/nduongg04/se100.p12-cafe/blob/main/app/globals.css"
    click B12 "https://github.com/nduongg04/se100.p12-cafe/tree/main/public/assets"

    %% Click Events for Server/Business Logic Layer
    click S1 "https://github.com/nduongg04/se100.p12-cafe/blob/main/app/api/export-analytics/route.ts"
    click S2 "https://github.com/nduongg04/se100.p12-cafe/tree/main/lib/actions"
    click S3 "https://github.com/nduongg04/se100.p12-cafe/tree/main/lib/apis"
    click S4 "https://github.com/nduongg04/se100.p12-cafe/blob/main/middleware.ts"

    %% Click Events for Configuration & Deployment
    click C1 "https://github.com/nduongg04/se100.p12-cafe/blob/main/next.config.mjs"
    click C2 "https://github.com/nduongg04/se100.p12-cafe/blob/main/tailwind.config.ts"
    click C3 "https://github.com/nduongg04/se100.p12-cafe/blob/main/tsconfig.json"
    click C4 "https://github.com/nduongg04/se100.p12-cafe/blob/main/.github/workflows/integrate.yml"

    %% Styles
    classDef client fill:#AEDFF7,stroke:#333,stroke-width:1px;
    classDef server fill:#C1FDBB,stroke:#333,stroke-width:1px;
    classDef config fill:#FFF79A,stroke:#333,stroke-width:1px;
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px;
```
