# zippland/worth-calculator architecture

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

- Interactive diagram: https://gitdiagram.com/zippland/worth-calculator
- Repository: https://github.com/zippland/worth-calculator

## Overview

##### Main Components
- Client/Frontend: The “app” folder contains Next.js pages like layout.tsx, page.tsx, and the share-related page, which render user interfaces.
- Components: The “components” folder includes UI components such as LanguageContext.tsx, LanguageSwitcher.tsx, ShareCard.tsx, and the calculator component. These are used across pages to encapsulate specific functionalities.
- Configuration & Styling: Files like tailwind.config.ts, postcss.config.mjs, globals.css, and next.config.ts represent the styling, build configurations, and framework-specific settings.
- Public Assets: The “public” directory holds static assets, which might include images or other files used by the UI.
- Dependencies & Build Scripts: Files such as package.json, tsconfig.json, and package-lock.json manage dependencies and TypeScript configurations.
- Tests: There are a few test files (e.g., test/test.txt) that suggest some test infrastructure.

##### Interactions and Data Flow
- The Frontend interacts with the user through various UI elements built using React in the Next.js framework. The pages defined in “app” route the requests and render layouts.
- UI components (from the “components” folder) are integrated into pages to manage specific functions, such as switching languages and handling the calculation logic.
- Input data (salary, work details, etc.) is collected from the user and processed on the client side. Although not explicitly seen, the calculation logic might be locally executed or could eventually interact with backend APIs if a server-side component is added.
- Static configuration files drive application behavior (for example, global styles, ESLint rules, and build configurations).

##### Architectural Patterns and Design Principles
- Next.js File-Based Routing: The “app” folder structure follows Next.js conventions for routing (with page.tsx and layout files).
- Component-Based UI: The use of modular components (in “components” folder) indicates a clear separation of concerns, allowing for reusable UI elements.
- Internationalization Support: The LanguageContext and LanguageSwitcher components suggest an internationalization strategy, enhancing the application’s usability across different languages.
- Responsive & Styled Interface: Tailwind CSS configuration and globals.css management ensure that the UI is responsive and styled consistently across devices.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Input
    UI("User Input"):::input

    %% Frontend Rendering Layer
    subgraph "Frontend Rendering"
        subgraph "Pages"
            L("Layout (Page)"):::page
            M("Main Page"):::page
            S("Share Page"):::page
        end
        subgraph "UI Components"
            LC("Language Context"):::component
            LS("Language Switcher"):::component
            SC("Share Card"):::component
            CAL("Calculator"):::component
        end
    end

    %% Business Logic Layer
    B("Calculation Engine"):::logic

    %% Configuration & Styling Layer
    subgraph "Configuration & Styling"
        T("Tailwind Config"):::config
        P("PostCSS Config"):::config
        G("Global Styles"):::config
        N("Next Config"):::config
    end

    %% Public Assets Layer
    subgraph "Public Assets"
        PA("Public Assets"):::asset
    end

    %% Dependencies & Build Scripts
    subgraph "Dependencies & Build"
        PK("Package.json"):::dep
        PKL("Package-lock.json"):::dep
        TS("TS Config"):::dep
        ESL("ESLint Config"):::dep
    end

    %% Test Infrastructure
    subgraph "Test Infrastructure"
        TD("Test Directory"):::test
        TT("Test File"):::test
    end

    %% Connections from User Input to Pages
    UI -->|"inputs"| M
    UI -->|"inputs"| L
    UI -->|"inputs"| S

    %% Pages integrating UI Components
    L -->|"integrates"| LC
    L -->|"integrates"| LS
    M -->|"integrates"| CAL
    S -->|"integrates"| SC

    %% Pages rendering additional components
    L -->|"renders"| CAL
    L -->|"renders"| LC
    L -->|"renders"| LS
    S -->|"renders"| SC
    M -->|"renders"| LC
    M -->|"renders"| CAL
    M -->|"renders"| LS

    %% Internationalization support between UI Components
    LC ---|"supports"| LS

    %% Calculator interaction with Calculation Engine
    CAL -->|"processes"| B
    B -->|"returns"| CAL

    %% Configuration influencing Pages
    T -->|"configures"| L
    P -->|"configures"| L
    G -->|"styles"| L
    N -->|"configures"| L

    %% Public Assets supplying content to Pages
    PA -->|"supplies"| L
    PA -->|"supplies"| M
    PA -->|"supplies"| S

    %% Dependencies & Build affecting Pages
    PK -->|"build-config"| L
    PKL -->|"build-config"| L
    TS -->|"ts-config"| L
    ESL -->|"lint-config"| L

    %% Test Infrastructure validating Pages
    TD -->|"tests"| L
    TT -->|"tests"| L

classDef page fill:#cce5ff,stroke:#004085,stroke-width:2px;
classDef component fill:#d4edda,stroke:#155724,stroke-width:2px;
classDef logic fill:#f8d7da,stroke:#721c24,stroke-width:2px;
classDef config fill:#fff3cd,stroke:#856404,stroke-width:2px;
classDef asset fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
classDef dep fill:#fff,stroke:#ffc107,stroke-width:2px;
classDef test fill:#f5c6cb,stroke:#721c24,stroke-width:2px;
classDef input fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;

click L "https://github.com/zippland/worth-calculator/blob/main/app/layout.tsx"
click M "https://github.com/zippland/worth-calculator/blob/main/app/page.tsx"
click S "https://github.com/zippland/worth-calculator/blob/main/app/share/page.tsx"

click LC "https://github.com/zippland/worth-calculator/blob/main/components/LanguageContext.tsx"
click LS "https://github.com/zippland/worth-calculator/blob/main/components/LanguageSwitcher.tsx"
click SC "https://github.com/zippland/worth-calculator/blob/main/components/ShareCard.tsx"
click CAL "https://github.com/zippland/worth-calculator/blob/main/components/calculator.tsx"

click T "https://github.com/zippland/worth-calculator/blob/main/tailwind.config.ts"
click P "https://github.com/zippland/worth-calculator/blob/main/postcss.config.mjs"
click G "https://github.com/zippland/worth-calculator/blob/main/app/globals.css"
click N "https://github.com/zippland/worth-calculator/blob/main/next.config.ts"

click PA "https://github.com/zippland/worth-calculator/tree/main/public"

click PK "https://github.com/zippland/worth-calculator/blob/main/package.json"
click PKL "https://github.com/zippland/worth-calculator/blob/main/package-lock.json"
click TS "https://github.com/zippland/worth-calculator/blob/main/tsconfig.json"
click ESL "https://github.com/zippland/worth-calculator/blob/main/.eslintrc.json"

click TD "https://github.com/zippland/worth-calculator/tree/main/test"
click TT "https://github.com/zippland/worth-calculator/blob/main/test/test.txt"
```
