# trantuananh1/todo-list architecture

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

- Interactive diagram: https://gitdiagram.com/trantuananh1/todo-list
- Repository: https://github.com/trantuananh1/todo-list

## Overview

##### Project Type and Purpose
- This is a single‐page application (SPA) built with Create React App.
- It implements a “Todo” UI component library plus app logic, all running in the browser.

##### High-Level Architecture Components
a. Static Hosting Layer
- public/index.html, manifest.json, robots.txt, static assets
- Served by a CDN or static file server (e.g., Netlify, GitHub Pages)
b. Bundling & Build Process
- package.json scripts (`npm start`, `npm run build`)
- Webpack/Babel under the hood (hidden until you eject)
c. Client-Side React Application
- src/index.js – application entry point; renders `<App/>` into the DOM
- src/App.jsx – root component
- src/reportWebVitals.js – optional metrics reporting
d. Todo Feature Module
- src/components/Todo/useTodo.js – custom hook for state & persistence
- src/components/Todo/Wrapper.js – container component orchestrating the UI
- src/components/Todo/Header.js – UI for adding/filtering todos
- src/components/Todo/Item.js – single todo item representation
- src/components/Todo/Footer.js – summary and controls (e.g., clear completed)
- src/components/Todo/css/style.css – visual styling

##### Relationships & Data Flow
- On page load, the Static Hosting Layer returns index.html + JS bundle → Browser.
- Browser executes bundle → React app initializes in `
`.
- `<App/>` mounts and delegates to `<TodoWrapper/>`.
- `<TodoWrapper/>` calls `useTodo()` to load and manage state (in-memory + localStorage).
- Child components (Header, Item list, Footer) receive state & dispatch functions via props.
- User actions (e.g., “add todo”) flow up through event handlers → `useTodo` state updater → React re-render.
- reportWebVitals can optionally send metrics to an analytics endpoint.

##### Architectural Patterns & Principles
- Component-based architecture: clear separation of concerns per UI piece.
- Custom hook (`useTodo`) encapsulates stateful logic and persistence.
- Unidirectional data flow: parent → child props, child → parent via callbacks.

- Use rectangles for modules/components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Static Hosting Layer"
        SH["public/ + build/ assets"]:::static
        HTML["index.html"]:::static
        MAN["manifest.json"]:::static
        ROB["robots.txt"]:::static
    end
    SCRIPTS["package.json scripts\n(npm start / build)"]:::static

    subgraph "Browser"
        IDX["src/index.js"]:::runtime
        GLOB1["src/index.css"]:::runtime
        APP["src/App.jsx"]:::runtime
        GLOB2["src/App.css"]:::runtime
        subgraph "Todo Module"
            TODOIDX["src/components/Todo/index.js"]:::runtime
            WRAP["src/components/Todo/Wrapper.js"]:::runtime
            HDR["src/components/Todo/Header.js"]:::runtime
            ITM["src/components/Todo/Item.js"]:::runtime
            FTR["src/components/Todo/Footer.js"]:::runtime
            CSS["src/components/Todo/css/style.css"]:::static
            HOOK["src/components/Todo/useTodo.js\n(persistence: localStorage)"]:::logic
        end
        RPT["src/reportWebVitals.js"]:::runtime
        ANALYTICS["External Analytics Service"]:::external
    end

    SH -->|"HTTP GET HTML & JS"| Browser
    SCRIPTS --> SH

    IDX -->|"renders into root"| APP
    IDX -->|"imports styles"| GLOB1
    APP -->|"mounts root component"| WRAP
    APP -->|"imports styles"| GLOB2

    WRAP -->|"calls hook"| HOOK
    WRAP -->|"renders children"| HDR
    WRAP -->|"renders children"| ITM
    WRAP -->|"renders children"| FTR

    HOOK -->|"provides state"| HDR
    HOOK -->|"provides state"| ITM
    HOOK -->|"provides state"| FTR
    HDR -->|"dispatch actions"| HOOK
    ITM -->|"dispatch actions"| HOOK
    FTR -->|"dispatch actions"| HOOK

    RPT -->|"sends metrics"| ANALYTICS

    %% Click Events
    click SH "https://github.com/trantuananh1/todo-list/tree/master/public/"
    click HTML "https://github.com/trantuananh1/todo-list/blob/master/public/index.html"
    click MAN "https://github.com/trantuananh1/todo-list/blob/master/public/manifest.json"
    click ROB "https://github.com/trantuananh1/todo-list/blob/master/public/robots.txt"
    click SCRIPTS "https://github.com/trantuananh1/todo-list/blob/master/package.json"
    click IDX "https://github.com/trantuananh1/todo-list/blob/master/src/index.js"
    click APP "https://github.com/trantuananh1/todo-list/blob/master/src/App.jsx"
    click GLOB1 "https://github.com/trantuananh1/todo-list/blob/master/src/index.css"
    click GLOB2 "https://github.com/trantuananh1/todo-list/blob/master/src/App.css"
    click RPT "https://github.com/trantuananh1/todo-list/blob/master/src/reportWebVitals.js"
    click TODOIDX "https://github.com/trantuananh1/todo-list/blob/master/src/components/Todo/index.js"
    click HOOK "https://github.com/trantuananh1/todo-list/blob/master/src/components/Todo/useTodo.js"
    click WRAP "https://github.com/trantuananh1/todo-list/blob/master/src/components/Todo/Wrapper.js"
    click HDR "https://github.com/trantuananh1/todo-list/blob/master/src/components/Todo/Header.js"
    click ITM "https://github.com/trantuananh1/todo-list/blob/master/src/components/Todo/Item.js"
    click FTR "https://github.com/trantuananh1/todo-list/blob/master/src/components/Todo/Footer.js"
    click CSS "https://github.com/trantuananh1/todo-list/blob/master/src/components/Todo/css/style.css"

    %% Styles
    classDef static fill:#cccccc,stroke:#333,stroke-width:1px
    classDef runtime fill:#bbdefb,stroke:#333,stroke-width:1px
    classDef logic fill:#c8e6c9,stroke:#333,stroke-width:1px
    classDef external fill:#ffcc80,stroke:#333,stroke-width:1px
```
