# harry-huynh/to-do-frontend architecture

> Architecture diagram of the GitHub repository harry-huynh/to-do-frontend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harry-huynh/to-do-frontend
- Repository: https://github.com/harry-huynh/to-do-frontend

## Overview

##### Project type and purpose
- This is a Next.js full-stack application bootstrapped with create-next-app.
- It provides both a React-based frontend (pages + components) and a minimal backend via Next.js API routes.
- Its primary purpose appears to be a simple task management UI, with client-side state and one example API endpoint (`/api/hello`).

##### File structure
- Top-level files and config:
- package.json, next.config.mjs, jsconfig.json, eslint.config.mjs, postcss.config.mjs
- public/ (static assets)
- src/pages/
- index.js (main page)
- _app.js, _document.js (app shell and custom HTML document)
- api/hello.js (API route)
- src/components/ (React UI components: Button, TaskContainer, CompletedTasks, UncompletedTasks)
- src/store.js (global state management, e.g., Context or Redux)
- src/styles/globals.css (global styles)

##### README for additional insights
- Confirms Next.js pages router, API routes, next/font usage, dev and deploy instructions.

##### Main components and their relationships
a. Frontend (React in Next.js)
- Pages layer:
– pages/index.js orchestrates TaskContainer and renders CompletedTasks and UncompletedTasks via Button interactions.
- Components layer: reusable UI building blocks under src/components.
- Client-side Store: global state in src/store.js, consumed by components.
b. Backend/API (Next.js serverless functions)
- /api/hello endpoint returns JSON, demonstrating how to add more API routes.
- Next.js handles SSR for pages, SSG or ISR if configured.
c. Static assets
- public/ directory serves images, favicon, etc.
d. Styles
- globals.css for base styling; per-component CSS can be added as modules.

##### Architectural patterns and design principles
- Component-based UI (React)
- Pages-as-routes (Next.js pages router)
- Serverless API routes (Next.js API)
- Single source of truth for UI state (store.js)
- Separation of concerns:
- UI components vs. pages vs. data layer
- Static asset directory

##### Detail without over-splitting
- Pages/index.js separately as the entry point
- Store.js as a single node, not each action or reducer

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers
    subgraph "Client Browser"
        direction TB
        Browser["Browser"]:::client
        subgraph "Pages Layer"
            direction TB
            Index["Index Page"]:::client
            AppWrapper["_app.js"]:::client
            Document["_document.js"]:::client
        end
        subgraph "UI Components"
            direction TB
            Button["Button"]:::client
            TaskContainer["TaskContainer"]:::client
            CompletedTasks["CompletedTasks"]:::client
            UncompletedTasks["UncompletedTasks"]:::client
        end
        Store["Global Store"]:::client
        Styles["Global Stylesheet"]:::client
    end

    subgraph "Next.js Server (SSR/SSG & API)"
        direction TB
        subgraph "Pages Layer"
            direction TB
            PagesDir["src/pages"]:::server
        end
        subgraph "API Routes"
            direction TB
            ApiDir["src/pages/api"]:::server
            Hello["/api/hello"]:::server
        end
        subgraph "Configuration"
            direction TB
            NextConfig["next.config.mjs"]:::server
            JSConfig["jsconfig.json"]:::server
            ESLint["eslint.config.mjs"]:::server
            PostCSS["postcss.config.mjs"]:::server
            Package["package.json"]:::server
        end
    end

    subgraph "Static Assets Host"
        direction TB
        Public["public/"]:::static
    end

    %% Connections
    Browser -->|"requests page"| PagesDir
    PagesDir -->|renders via SSR/SSG| Browser
    Browser -->|"fetches JS & CSS"| AppWrapper
    AppWrapper -->|wraps| Index
    Index -->|uses| TaskContainer
    TaskContainer -->|renders| CompletedTasks
    TaskContainer -->|renders| UncompletedTasks
    Button -->|triggers state change| Store
    Store -->|provides state| CompletedTasks
    Store -->|provides state| UncompletedTasks
    Browser -->|calls API| Hello
    Hello -->|returns JSON| Browser
    Browser -->|loads assets| Public

    %% Click Events
    click PagesDir "https://github.com/harry-huynh/to-do-frontend/tree/main/src/pages"
    click Index "https://github.com/harry-huynh/to-do-frontend/blob/main/src/pages/index.js"
    click AppWrapper "https://github.com/harry-huynh/to-do-frontend/blob/main/src/pages/_app.js"
    click Document "https://github.com/harry-huynh/to-do-frontend/blob/main/src/pages/_document.js"
    click ApiDir "https://github.com/harry-huynh/to-do-frontend/tree/main/src/pages/api"
    click Hello "https://github.com/harry-huynh/to-do-frontend/blob/main/src/pages/api/hello.js"
    click Button "https://github.com/harry-huynh/to-do-frontend/blob/main/src/components/Button.js"
    click TaskContainer "https://github.com/harry-huynh/to-do-frontend/blob/main/src/components/TaskContainer.js"
    click CompletedTasks "https://github.com/harry-huynh/to-do-frontend/blob/main/src/components/CompletedTasks.js"
    click UncompletedTasks "https://github.com/harry-huynh/to-do-frontend/blob/main/src/components/UncompletedTasks.js"
    click Store "https://github.com/harry-huynh/to-do-frontend/blob/main/src/store.js"
    click Styles "https://github.com/harry-huynh/to-do-frontend/blob/main/src/styles/globals.css"
    click Public "https://github.com/harry-huynh/to-do-frontend/tree/main/public/"
    click NextConfig "https://github.com/harry-huynh/to-do-frontend/blob/main/next.config.mjs"
    click JSConfig "https://github.com/harry-huynh/to-do-frontend/blob/main/jsconfig.json"
    click ESLint "https://github.com/harry-huynh/to-do-frontend/blob/main/eslint.config.mjs"
    click PostCSS "https://github.com/harry-huynh/to-do-frontend/blob/main/postcss.config.mjs"
    click Package "https://github.com/harry-huynh/to-do-frontend/blob/main/package.json"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#555,stroke-width:1px
    classDef server fill:#D0FFD8,stroke:#555,stroke-width:1px
    classDef static fill:#E0E0E0,stroke:#555,stroke-width:1px
```
