# soren-starck/budget-flow architecture

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

- Interactive diagram: https://gitdiagram.com/soren-starck/budget-flow
- Repository: https://github.com/soren-starck/budget-flow

## Overview

##### Project Type and Purpose
- Budget Flow is a single-page/full-stack-style application built on Next.js.
- It provides a UI for entering income/expense data, calculates savings allocations, and renders interactive charts (e.g. Sankey) in the browser.

##### File Structure
- Top-level: Dockerfile/docker-compose (containerization), next.config.ts, Tailwind + PostCSS configs, package manifests.
- src/app: Next.js “app” directory with layout.tsx, page.tsx (SSR/SSG entry points).
- src/components: React UI—buttons, forms, tables, Sankey chart wrapper, Shadcn-powered UI primitives.
- src/lib: schema (Zod), store (Zustand state), utils (calculation helpers).
- src/providers: theme-provider (context).
- public: static assets (logo.svg, preview.png).

##### README for Stack & Flow
- Built With: Next.js (React + SSR), Shadcn (component library), Tailwind CSS (styles), Nivo (charts), Zustand (state).
- No external API/backend—logic is executed client-side or during SSR/SSG.

A. Client (Web Browser)
B. Next.js Server/Runtime (SSR/SSG, static asset serving)
C. React UI Layer
1. Pages (layout, page)
2. Components (forms, inputs, banners, tables, Sankey chart component)
3. Providers (ThemeProvider)
D. State Management (Zustand Store)
E. Business Logic (Utils + Schema Validation)
F. Charting Engine (Nivo)
G. Static Assets (public folder via CDN or built-in server)
H. Container/Hosting (Docker + docker-compose)

##### Relationships & Data Flow
- Browser → Next.js Server: initial page request → SSR/SSG → HTML/CSS/JS delivered.
- Browser (client-side) → React UI: hydration/post-hydration rendering.
- User Input (forms) → Zustand Store (update state) → Utils (calculate savings) → Store/state updated.
- Store → React UI: re-render components (tables, Sankey charts).
- React UI → Nivo Library: generate chart visuals.
- Next.js Server → public assets (logo, CSS) served via CDN or static route.

##### Architectural Patterns
- Component-Driven Architecture (atomic Shadcn UI primitives).
- Unidirectional Data Flow (Zustand store as single source of truth).
- SSR/SSG with CSR hydration (Next.js “app” router).
- Modular separation: UI vs. state vs. business-logic utils.

##### Relevant Technologies & Frameworks
- Next.js (React, routing, SSR/SSG)
- React + TypeScript
- Zustand (state management)
- Zod (schema validation)
- Tailwind CSS (utility-first styling)
- Shadcn/UI (design system)
- Nivo (visualization)
- Docker + docker-compose (containerization)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Infra & Deployment
    subgraph "Infra & Deployment"
        Dockerfile["Dockerfile"]:::infra
        DockerCompose["docker-compose.yml"]:::infra
        NextConfig["next.config.ts"]:::infra
        TailwindConfig["tailwind.config.ts"]:::infra
        PostCSSConfig["postcss.config.mjs"]:::infra
    end

    %% Next.js Server/Runtime
    subgraph "Next.js Server/Runtime"
        Layout["src/app/layout.tsx"]:::server
        Page["src/app/page.tsx"]:::server
        GlobalsCSS["src/app/globals.css"]:::server
    end

    %% React UI Layer
    subgraph "React UI Layer"
        subgraph "Pages & Layout"
            LayoutNode["layout.tsx"]:::ui
            PageNode["page.tsx"]:::ui
        end
        subgraph "Components"
            Footer["footer.tsx"]:::ui
            SankeyWrapper["sankey.tsx"]:::ui
            DataTable["table.tsx"]:::ui
            subgraph "Banners"
                Banner["banner.tsx"]:::ui
            end
            subgraph "Buttons"
                AddButton["add-button.tsx"]:::ui
                ThemeButton["theme-button.tsx"]:::ui
            end
            subgraph "Forms"
                RevenueForm["revenue-form.tsx"]:::ui
                SavingsForm["savings-form.tsx"]:::ui
            end
            subgraph "Inputs"
                AmountInput["amount-input.tsx"]:::ui
                SelectInput["select-input.tsx"]:::ui
            end
            subgraph "UI Primitives"
                Accordion["ui/accordion.tsx"]:::ui
                UI_Button["ui/button.tsx"]:::ui
                Card["ui/card.tsx"]:::ui
                Collapsible["ui/collapsible.tsx"]:::ui
                UI_Input["ui/input.tsx"]:::ui
                Label["ui/label.tsx"]:::ui
                UI_Select["ui/select.tsx"]:::ui
                Sonner["ui/sonner.tsx"]:::ui
                Tabs["ui/tabs.tsx"]:::ui
                Toggle["ui/toggle.tsx"]:::ui
            end
        end
    end

    %% Providers, State & Logic
    subgraph "Providers, State & Logic"
        ThemeProvider["theme-provider.tsx"]:::statelogic
        ZustandStore["store.ts"]:::statelogic
        SchemaValidation["schema.ts"]:::statelogic
        CalcUtils["utils.tsx"]:::statelogic
    end

    %% Static Assets
    subgraph "Static Assets"
        PublicAssets["public/*"]:::external
    end

    %% External Charting Lib
    Nivo["Nivo Library"]:::external

    %% Data Flow
    Browser["Web Browser"]:::ui
    Browser -->|"Initial Request"| Layout
    Browser -->|"Initial Request"| Page
    Layout -->|"Uses Styles"| GlobalsCSS
    Page -->|"Uses Styles"| GlobalsCSS
    Layout --> Browser
    Page --> Browser
    Browser -->|"Hydration"| LayoutNode
    Browser -->|"Hydration"| PageNode
    LayoutNode --> Footer
    PageNode --> SankeyWrapper
    PageNode --> DataTable

    %% User Interaction Flow
    RevenueForm -->|"User Input"| ZustandStore
    SavingsForm -->|"User Input"| ZustandStore
    ZustandStore -->|"State Update"| CalcUtils
    CalcUtils -->|"Calculated Savings"| ZustandStore
    ZustandStore -->|"State Change"| DataTable
    ZustandStore -->|"State Change"| SankeyWrapper
    SankeyWrapper -->|"Render Chart"| Nivo

    %% React UI dependencies
    RevenueForm --> Accordion
    RevenueForm --> UI_Input
    RevenueForm --> UI_Select
    SavingsForm --> UI_Input
    SavingsForm --> UI_Select
    AddButton --> UI_Button
    ThemeButton --> UI_Button
    Banner --> Card

    %% Server serving static assets
    Layout -->|"Serves"| PublicAssets
    Page -->|"Serves"| PublicAssets

    %% Infra dependencies
    DockerCompose --> Dockerfile
    DockerCompose --> NextConfig

    %% Click Events
    click Dockerfile "https://github.com/soren-starck/budget-flow/tree/main/./Dockerfile"
    click DockerCompose "https://github.com/soren-starck/budget-flow/blob/main/./docker-compose.yml"
    click NextConfig "https://github.com/soren-starck/budget-flow/blob/main/./next.config.ts"
    click TailwindConfig "https://github.com/soren-starck/budget-flow/blob/main/./tailwind.config.ts"
    click PostCSSConfig "https://github.com/soren-starck/budget-flow/blob/main/./postcss.config.mjs"
    click Layout "https://github.com/soren-starck/budget-flow/blob/main/./src/app/layout.tsx"
    click Page "https://github.com/soren-starck/budget-flow/blob/main/./src/app/page.tsx"
    click GlobalsCSS "https://github.com/soren-starck/budget-flow/blob/main/./src/app/globals.css"
    click Footer "https://github.com/soren-starck/budget-flow/blob/main/./src/components/footer.tsx"
    click SankeyWrapper "https://github.com/soren-starck/budget-flow/blob/main/./src/components/sankey.tsx"
    click DataTable "https://github.com/soren-starck/budget-flow/blob/main/./src/components/table.tsx"
    click Banner "https://github.com/soren-starck/budget-flow/blob/main/./src/components/banners/banner.tsx"
    click AddButton "https://github.com/soren-starck/budget-flow/blob/main/./src/components/buttons/add-button.tsx"
    click ThemeButton "https://github.com/soren-starck/budget-flow/blob/main/./src/components/buttons/theme-button.tsx"
    click RevenueForm "https://github.com/soren-starck/budget-flow/blob/main/./src/components/forms/revenue-form.tsx"
    click SavingsForm "https://github.com/soren-starck/budget-flow/blob/main/./src/components/forms/savings-form.tsx"
    click AmountInput "https://github.com/soren-starck/budget-flow/blob/main/./src/components/inputs/amount-input.tsx"
    click SelectInput "https://github.com/soren-starck/budget-flow/blob/main/./src/components/inputs/select-input.tsx"
    click Accordion "https://github.com/soren-starck/budget-flow/blob/main/./src/components/ui/accordion.tsx"
    click UI_Button "https://github.com/soren-starck/budget-flow/blob/main/./src/components/ui/button.tsx"
    click Card "https://github.com/soren-starck/budget-flow/blob/main/./src/components/ui/card.tsx"
    click Collapsible "https://github.com/soren-starck/budget-flow/blob/main/./src/components/ui/collapsible.tsx"
    click UI_Input "https://github.com/soren-starck/budget-flow/blob/main/./src/components/ui/input.tsx"
    click Label "https://github.com/soren-starck/budget-flow/blob/main/./src/components/ui/label.tsx"
    click UI_Select "https://github.com/soren-starck/budget-flow/blob/main/./src/components/ui/select.tsx"
    click Sonner "https://github.com/soren-starck/budget-flow/blob/main/./src/components/ui/sonner.tsx"
    click Tabs "https://github.com/soren-starck/budget-flow/blob/main/./src/components/ui/tabs.tsx"
    click Toggle "https://github.com/soren-starck/budget-flow/blob/main/./src/components/ui/toggle.tsx"
    click ZustandStore "https://github.com/soren-starck/budget-flow/blob/main/./src/lib/store.ts"
    click SchemaValidation "https://github.com/soren-starck/budget-flow/blob/main/./src/lib/schema.ts"
    click CalcUtils "https://github.com/soren-starck/budget-flow/blob/main/./src/lib/utils.tsx"
    click ThemeProvider "https://github.com/soren-starck/budget-flow/blob/main/./src/providers/theme-provider.tsx"
    click PublicAssets "https://github.com/soren-starck/budget-flow/tree/main/./public"

    %% Styles
    classDef infra fill:#E5D4ED,stroke:#9B59B6
    classDef server fill:#D6EAF8,stroke:#3498DB
    classDef ui fill:#D5F5E3,stroke:#27AE60
    classDef statelogic fill:#FCF3CF,stroke:#F1C40F
    classDef external fill:#E5E8E8,stroke:#95A5A6
```
