# hwayeeon/u-reserve architecture

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

- Interactive diagram: https://gitdiagram.com/hwayeeon/u-reserve
- Repository: https://github.com/hwayeeon/u-reserve

## Overview

##### Project type and purpose
- This is a full‑stack (frontend‑heavy) Next.js application (using the new `/app` directory for server & client components).
- Primary features: multi‑role UI (admin vs. user), static data consumption (JSON), login flow, error handling, and a set of reusable UI components.

##### File structure
- Top‑level: configuration files (`next.config.mjs`, `postcss.config.mjs`, `jsconfig.json`, etc.), package files, and public assets.
- `src/app`: file‑based routing for pages, layouts, error handling, login, admin, user, and global styles.
- `src/components`: reusable React components (including a `ui` subfolder for primitive UI building blocks).
- `src/data`: static JSON data sources.
- `src/hooks` and `src/lib`: custom hooks and utility libraries (mobile detection, cookies, encryption, etc.).
- `middleware.js`: Next.js middleware for authentication, redirects, or headers.

##### README
- Confirms it’s a create‑next‑app scaffold, uses `next/font`, and is intended for deployment on Vercel.
- No custom backend API routes are present, so data is either static or fetched from external services.

##### Main components
a. Client Layer
- Browser (Chrome/Firefox/…)
- React hydration layer (client components)
b. Next.js Server Layer
- Next.js Server (Node.js runtime on Vercel or similar)
- Middleware (handles auth, redirects)
- Server Components (in `src/app`)
c. Data Layer
- Static JSON files (`src/data/*.json`)
d. Assets & Build Layer
- Public folder (images, favicon, manifest)
- Build pipeline (PostCSS, ESLint, bundler)
e. Third‑Party Services
- Vercel CDN / Hosting
- Google Fonts / next/font

##### Relationships and interactions
- Browser → Next.js Server: initial page request via SSR or SSG.
- Next.js Server → Data Layer: reads static JSON or calls external APIs.
- Next.js Server → Public Assets: serves images, CSS, JS bundles, manifest.
- Next.js Server → Browser: streams HTML + JSON, then hydrates React client components.
- Browser → Next.js Server: client‑side navigation requests (via the Next.js router).
- Middleware intercepts incoming requests for auth or logging.

##### Architectural patterns & design principles
- File‑based routing (Next.js `app` directory).
- Server vs. Client Components separation.
- Utility modules (`src/lib`, `src/hooks`) for cross‑cutting concerns.
- Atomic design in `src/components/ui` for consistency and reusability.
- Static‑first data approach (JSON files) with potential for extension to real APIs.

##### Essential elements
- Version control & build step optionally at the bottom (Git → Build → Deploy).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        Browser["Browser"]:::frontend
        ClientComponents["React Hydration (Client Components)"]:::frontend
    end

    %% Server Layer
    subgraph "Server Layer"
        direction TB
        Middleware["Middleware"]:::server
        NextServer["Next.js Server"]:::server

        subgraph "Server Components (src/app)"
            direction TB
            Layout["Root Layout"]:::server
            Globals["Global Styles"]:::server
            ErrorBoundaries["Error Boundaries"]:::server
            ManifestRoute["Manifest Route"]:::server
            HomePage["Home Page"]:::server

            subgraph "Admin Section"
                direction TB
                AdminDashboard["Admin Dashboard"]:::server
                AdminData["Admin Data Page"]:::server
                AdminLogs["Admin Logs Page"]:::server
            end

            subgraph "Login Flow"
                direction TB
                LoginPage["Login Page"]:::server
                LoginError["Login Error Handling"]:::server
            end

            subgraph "User Section"
                direction TB
                UserMain["User Main Page"]:::server
                UserFAQ["User FAQ Page"]:::server
            end
        end
    end

    %% Data & Assets Layer
    subgraph "Data & Assets Layer"
        direction TB
        JSONData["Static JSON Data"]:::data
        PublicAssets["Public Assets & Static Files"]:::data
        ExternalAPI["External APIs"]:::data
    end

    %% UI Components Library
    UIComponents["UI Components Library"]:::frontend

    %% Reusable Components
    ReusableComponents["Reusable React Components"]:::frontend

    %% Hooks & Lib
    Hooks["Custom Hooks"]:::server
    Libs["Utility Libraries"]:::server

    %% Build & Deployment
    subgraph "Build & Deployment Pipeline"
        direction TB
        VersionControl["Git (package.json, lock, config)"]:::infra
        Build["Build Pipeline (ESLint, PostCSS, Bundler)"]:::infra
        Deploy["Deploy to Vercel CDN"]:::infra
    end

    %% Third-Party Services
    VercelCDN["Vercel CDN / Hosting"]:::infra
    Fonts["Google Fonts / next/font"]:::infra

    %% Connections
    Browser -->|"Initial Request"| Middleware
    Middleware -->|"Route/Auth"| NextServer
    NextServer -->|Reads| JSONData
    NextServer -->|Serves| PublicAssets
    NextServer -->|Optionally Calls| ExternalAPI
    NextServer -->|"Streams HTML+JSON"| Browser
    Browser -->|"Client Navigation"| NextServer
    Browser -->|"Hydrate"| ClientComponents
    ClientComponents --> UIComponents
    ClientComponents --> ReusableComponents
    NextServer -->|Uses| Hooks
    NextServer -->|Uses| Libs

    VersionControl --> Build
    Build --> Deploy
    Deploy --> VercelCDN
    NextServer -->|Hosted On| VercelCDN
    NextServer -->|Loads Fonts From| Fonts

    %% Click Events
    click Middleware "https://github.com/hwayeeon/u-reserve/blob/main/middleware.js"
    click NextServer "https://github.com/hwayeeon/u-reserve/blob/main/next.config.mjs"
    click NextServer "https://github.com/hwayeeon/u-reserve/blob/main/postcss.config.mjs"
    click NextServer "https://github.com/hwayeeon/u-reserve/blob/main/jsconfig.json"
    click PublicAssets "https://github.com/hwayeeon/u-reserve/tree/main/public/"
    click Layout "https://github.com/hwayeeon/u-reserve/blob/main/src/app/layout.js"
    click Globals "https://github.com/hwayeeon/u-reserve/blob/main/src/app/globals.css"
    click ErrorBoundaries "https://github.com/hwayeeon/u-reserve/blob/main/src/app/error.js"
    click ErrorBoundaries "https://github.com/hwayeeon/u-reserve/blob/main/src/app/not-found.js"
    click ManifestRoute "https://github.com/hwayeeon/u-reserve/blob/main/src/app/manifest.js"
    click HomePage "https://github.com/hwayeeon/u-reserve/blob/main/src/app/page.js"
    click AdminDashboard "https://github.com/hwayeeon/u-reserve/blob/main/src/app/admin/page.js"
    click AdminData "https://github.com/hwayeeon/u-reserve/blob/main/src/app/admin/data/page.js"
    click AdminLogs "https://github.com/hwayeeon/u-reserve/blob/main/src/app/admin/logs/page.js"
    click LoginPage "https://github.com/hwayeeon/u-reserve/blob/main/src/app/login/page.js"
    click LoginError "https://github.com/hwayeeon/u-reserve/blob/main/src/app/login/error.js"
    click UserMain "https://github.com/hwayeeon/u-reserve/blob/main/src/app/user/page.js"
    click UserFAQ "https://github.com/hwayeeon/u-reserve/blob/main/src/app/user/faq/page.js"
    click UIComponents "https://github.com/hwayeeon/u-reserve/tree/main/src/components/ui/"
    click ReusableComponents "https://github.com/hwayeeon/u-reserve/blob/main/src/components/app-sidebar.jsx"
    click Hooks "https://github.com/hwayeeon/u-reserve/blob/main/src/hooks/use-mobile.js"
    click Libs "https://github.com/hwayeeon/u-reserve/blob/main/src/lib/cookies.js"
    click Libs "https://github.com/hwayeeon/u-reserve/blob/main/src/lib/crypt.js"
    click Libs "https://github.com/hwayeeon/u-reserve/blob/main/src/lib/utils.js"
    click JSONData "https://github.com/hwayeeon/u-reserve/blob/main/src/data/data.json"
    click JSONData "https://github.com/hwayeeon/u-reserve/blob/main/src/data/dummy.json"
    click JSONData "https://github.com/hwayeeon/u-reserve/blob/main/src/data/dummy2.json"
    click VersionControl "https://github.com/hwayeeon/u-reserve/blob/main/package.json"
    click VersionControl "https://github.com/hwayeeon/u-reserve/blob/main/package-lock.json"
    click VersionControl "https://github.com/hwayeeon/u-reserve/blob/main/eslint.config.mjs"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#007bff,color:#000;
    classDef server fill:#d4edda,stroke:#28a745,color:#000;
    classDef data fill:#fff3cd,stroke:#ffc107,color:#000;
    classDef infra fill:#e2e3e5,stroke:#6c757d,color:#000;
```
