# rafixx/personal_schedule architecture

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

- Interactive diagram: https://gitdiagram.com/rafixx/personal_schedule
- Repository: https://github.com/rafixx/personal_schedule

## Overview

##### Project type and purpose
- This is a single-page web application (SPA) entirely running in the browser: a weekly meal-planner that persists data locally (IndexedDB via Dexie), lets users assign dishes to days (drag & drop), then computes and exports a consolidated shopping list.

##### File structure
- Top-level sources (src/):
- components/  – small, reusable UI pieces (DayCell, Toolbar, etc.)
- pages/       – route targets (PlannerPage, DishesPage, ShoppingListPage)
- layouts/     – shell around pages (DashboardLayout)
- shared/      – cross-cutting UI (Sidebar), routing definitions, helpers
- store/       – global state with Zustand (plannerStore.ts)
- data/        – Dexie DB schema (db.ts), repositories.ts, demo data
- domain/      – business logic (types, computeShoppingList)
- utils/, config files, public/ (static assets + sample menu.json), index.html
- Build & config: Vite (vite.config.ts), TypeScript (tsconfig.json), TailwindCSS, ESLint, Prettier, CI pipeline.

##### README
- Key features: drag & drop meal assignments, JSON import/export, local persistence, no server.

##### Main components & interactions
a. Presentation Layer
- Browser/Client
- index.html → main.tsx (React entry point)
- React Router (routes.tsx)
- DashboardLayout wraps individual Pages
- Pages composed of UI Components (PlannerView, WeekRow, DayCell, DishPicker, Toolbar) and shared Sidebar
b. State & Business Logic Layer
- Zustand store (plannerStore.ts): holds current plan, triggers updates
- Domain services (computeShoppingList in domain/shopping.ts): computes consolidated shopping list from state
- Utilities (date handling, helpers)
c. Data Persistence Layer
- Dexie-based repositories (data/repositories.ts) with IndexedDB schema (data/db.ts)
- Demo data loader (data/demo.ts)
- JSON import/export handlers (likely in shared/utils or domain)
d. External Libraries & Frameworks
- Vite (dev server, build pipeline)
- TailwindCSS for styling
- @dnd-kit for drag & drop interactions

##### Architectural patterns & principles
- Layered architecture (Presentation / State & Logic / Persistence)
- Repository pattern (abstract DB operations)
- Unidirectional data flow: UI actions → Zustand store → domain logic → persistence → UI
- Component-based design (atoms → molecules → organisms)
- SPA routing (React Router)

##### Detailed list of elements
- index.html & main.tsx entry
- Router component (routes.tsx)
- DashboardLayout
- PlannerPage, DishesPage, ShoppingListPage
- Core components: PlannerView, DayCell, WeekRow, DishPicker, Toolbar, Sidebar
- State container: plannerStore.ts
- Business logic: computeShoppingList (domain/shopping.ts)
- DB layer: db.ts, repositories.ts, IndexedDB
- Demo loader (demo.ts)
- JSON import/export module
- External services: @dnd-kit, Lucide-react, TailwindCSS, Vite dev/build

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser Layer
    Browser["Browser / Client"]:::external

    %% UI Layer
    subgraph "UI Layer"
        index["index.html"]:::ui
        main["main.tsx"]:::ui
        router["routes.tsx\n(React Router)"]:::ui
        layout["DashboardLayout"]:::ui
        subgraph "Pages"
            plannerPage["PlannerPage"]:::ui
            dishesPage["DishesPage"]:::ui
            shoppingPage["ShoppingListPage"]:::ui
        end
        subgraph "Components"
            plannerView["PlannerView"]:::ui
            weekRow["WeekRow"]:::ui
            dayCell["DayCell"]:::ui
            dishPicker["DishPicker"]:::ui
            toolbar["Toolbar"]:::ui
            sidebar["Sidebar"]:::ui
        end
    end

    %% State & Logic Layer
    subgraph "State & Logic Layer"
        store["plannerStore.ts\n(Zustand)"]:::state
        compute["computeShoppingList\n(domain)"]:::state
        types["types.ts"]:::state
        dateUtil["date.ts"]:::state
        helpers["helpers.ts"]:::state
        menuConfig["menuConfig.ts"]:::state
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        repo["repositories.ts"]:::persistence
        db["db.ts\n(Dexie Schema)"]:::persistence
        demo["demo.ts"]:::persistence
        json["helpers.ts\n(JSON Import/Export)"]:::persistence
        IndexedDB["IndexedDB"]:::persistence
    end

    %% External & Tools
    subgraph "External & Tools"
        vite["vite.config.ts"]:::external
        tailwind["tailwind.config.js"]:::external
        dnd["@dnd-kit"]:::external
        lucide["lucide-react"]:::external
    end

    %% Connections - UI Flow
    Browser --> index
    index --> main
    main --> router
    router --> layout
    layout --> plannerPage
    layout --> dishesPage
    layout --> shoppingPage

    plannerPage --> plannerView
    plannerPage --> weekRow
    plannerPage --> dayCell
    dishesPage --> dishPicker
    plannerPage --> toolbar
    dishesPage --> toolbar
    shoppingPage --> toolbar
    plannerPage --> sidebar
    dishesPage --> sidebar
    shoppingPage --> sidebar

    %% State Interactions
    plannerView -->|"dispatch actions"| store
    weekRow -->|"dispatch actions"| store
    dayCell -->|"dispatch actions"| store
    dishPicker -->|"dispatch actions"| store
    toolbar -->|"dispatch actions"| store

    store -->|"triggers"| compute
    compute -->|"uses types & utils"| types
    compute -->|"uses date utils"| dateUtil

    %% Persistence Interactions
    store -->|"read/write"| repo
    compute -->|"read/write"| repo
    repo --> db
    db --> IndexedDB
    repo --> demo
    json <-->|"import/export JSON"| store
    json --> plannerPage

    %% External libraries usage
    plannerView -.-> dnd
    plannerView -.-> lucide
    index -.-> vite
    index -.-> tailwind

    %% Click Events
    click index "https://github.com/rafixx/personal_schedule/blob/main/index.html"
    click main "https://github.com/rafixx/personal_schedule/blob/main/src/main.tsx"
    click router "https://github.com/rafixx/personal_schedule/blob/main/src/shared/routes/routes.tsx"
    click layout "https://github.com/rafixx/personal_schedule/blob/main/src/layouts/DashboardLayout.tsx"
    click plannerPage "https://github.com/rafixx/personal_schedule/blob/main/src/pages/PlannerPage.tsx"
    click dishesPage "https://github.com/rafixx/personal_schedule/blob/main/src/pages/DishesPage.tsx"
    click shoppingPage "https://github.com/rafixx/personal_schedule/blob/main/src/pages/ShoppingListPage.tsx"
    click plannerView "https://github.com/rafixx/personal_schedule/blob/main/src/components/PlannerView.tsx"
    click weekRow "https://github.com/rafixx/personal_schedule/blob/main/src/components/WeekRow.tsx"
    click dayCell "https://github.com/rafixx/personal_schedule/blob/main/src/components/DayCell.tsx"
    click dishPicker "https://github.com/rafixx/personal_schedule/blob/main/src/components/DishPicker.tsx"
    click toolbar "https://github.com/rafixx/personal_schedule/blob/main/src/components/Toolbar.tsx"
    click sidebar "https://github.com/rafixx/personal_schedule/blob/main/src/shared/components/organisms/Sidebar.tsx"
    click store "https://github.com/rafixx/personal_schedule/blob/main/src/store/plannerStore.ts"
    click compute "https://github.com/rafixx/personal_schedule/blob/main/src/domain/shopping.ts"
    click types "https://github.com/rafixx/personal_schedule/blob/main/src/domain/types.ts"
    click dateUtil "https://github.com/rafixx/personal_schedule/blob/main/src/utils/date.ts"
    click helpers "https://github.com/rafixx/personal_schedule/blob/main/src/shared/utils/helpers.ts"
    click menuConfig "https://github.com/rafixx/personal_schedule/blob/main/src/shared/config/menuConfig.ts"
    click db "https://github.com/rafixx/personal_schedule/blob/main/src/data/db.ts"
    click repo "https://github.com/rafixx/personal_schedule/blob/main/src/data/repositories.ts"
    click demo "https://github.com/rafixx/personal_schedule/blob/main/src/data/demo.ts"
    click json "https://github.com/rafixx/personal_schedule/blob/main/src/shared/utils/helpers.ts"
    click vite "https://github.com/rafixx/personal_schedule/blob/main/vite.config.ts"
    click tailwind "https://github.com/rafixx/personal_schedule/blob/main/tailwind.config.js"

    %% Styles
    classDef ui fill:#AEDFF7,stroke:#333,stroke-width:1px
    classDef state fill:#C2F7AE,stroke:#333,stroke-width:1px
    classDef persistence fill:#F7D6AE,stroke:#333,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#333,stroke-width:1px
```
