# torukmaktoalpha/block-compare architecture

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

- Interactive diagram: https://gitdiagram.com/torukmaktoalpha/block-compare
- Repository: https://github.com/torukmaktoalpha/block-compare

## Overview

##### Main Components
- Frontend (UI/UX): Represented by the “app” directory, which includes Next.js page components (e.g., page.tsx, layout.tsx, globals.css) handling routing, layouts, and styling.
- Reusable Components: The “components” directory contains elements like BudgetChart.tsx and Layout.tsx that are used throughout the application to build the interface.
- Utility/Service Layer: The “utils” directory (with blockchain.ts) represents the blockchain-related logic (including SHA-256 implementations) for budget validation.
- Data Structures: The “types” directory defines the TypeScript interfaces (e.g., budget.ts) that structure the application's data.
- Configuration & Build: Files like next.config.ts, tsconfig.json, package.json, postcss.config.mjs, and eslint.config.mjs set up the project’s build, linting, and configuration environment.

##### Representing Relationships and Interactions
- How the Next.js “app” pages interact with Components to render the UI.
- That the Components (like BudgetChart) fetch or receive data validated using the blockchain logic from the utils/blockchain.ts utility.

##### Architectural Patterns & Principles
- Follow a component-based architecture inherent in React. Distinguish between layout/page-level components (in “app”) and reusable UI components (in “components”).
- Separation of concerns, where the visual presentation (UI components) is distinct from the business logic (blockchain utility).
- Adoption of clean architecture principles using well-defined TypeScript interfaces (in “types”) that enforce type safety.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend (UI/UX)
    subgraph "Frontend (UI/UX)"
        A1["Home Page (app/page.tsx)"]:::frontend
        A2["Layout (app/layout.tsx)"]:::frontend
        A3["Global Styles (app/globals.css)"]:::frontend
        A4["State Page (app/[state]/page.tsx)"]:::frontend
    end

    %% Reusable Components
    subgraph "Reusable Components"
        B1["BudgetChart (components/BudgetChart.tsx)"]:::component
        B2["Reusable Layout (components/Layout.tsx)"]:::component
    end

    %% Utility/Service Layer
    subgraph "Utility/Service Layer"
        U["Blockchain Utility (utils/blockchain.ts)"]:::util
    end

    %% Data Structures
    subgraph "Data Structures"
        T["Type Definitions (types/budget.ts)"]:::types
    end

    %% External Libraries
    subgraph "External Libraries"
        E1["Framer Motion (External Library)"]:::external
        E2["Recharts (External Library)"]:::external
    end

    %% Configuration & Build
    subgraph "Configuration & Build"
        C1["next.config.ts"]:::config
        C2["tsconfig.json"]:::config
        C3["package.json"]:::config
        C4["postcss.config.mjs"]:::config
        C5["eslint.config.mjs"]:::config
    end

    %% Connections
    A1 -->|"renders"| B1
    A1 -->|"renders"| B2
    A1 -->|"uses"| T
    A2 -->|"animatesWith"| E1
    B1 -->|"calls"| U
    B2 -->|"calls"| U
    B1 -->|"visualizes"| E2
    C3 -->|"builds"| A1

    %% Click Events
    click A1 "https://github.com/torukmaktoalpha/block-compare/blob/main/app/page.tsx"
    click A2 "https://github.com/torukmaktoalpha/block-compare/blob/main/app/layout.tsx"
    click A3 "https://github.com/torukmaktoalpha/block-compare/blob/main/app/globals.css"
    click A4 "https://github.com/torukmaktoalpha/block-compare/blob/main/app/[state]/page.tsx"
    click B1 "https://github.com/torukmaktoalpha/block-compare/blob/main/components/BudgetChart.tsx"
    click B2 "https://github.com/torukmaktoalpha/block-compare/blob/main/components/Layout.tsx"
    click U "https://github.com/torukmaktoalpha/block-compare/blob/main/utils/blockchain.ts"
    click T "https://github.com/torukmaktoalpha/block-compare/blob/main/types/budget.ts"
    click C1 "https://github.com/torukmaktoalpha/block-compare/blob/main/next.config.ts"
    click C2 "https://github.com/torukmaktoalpha/block-compare/blob/main/tsconfig.json"
    click C3 "https://github.com/torukmaktoalpha/block-compare/blob/main/package.json"
    click C4 "https://github.com/torukmaktoalpha/block-compare/blob/main/postcss.config.mjs"
    click C5 "https://github.com/torukmaktoalpha/block-compare/blob/main/eslint.config.mjs"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#333,stroke-width:2px;
    classDef component fill:#C4F7C5,stroke:#333,stroke-width:2px;
    classDef util fill:#F7D6AE,stroke:#333,stroke-width:2px;
    classDef types fill:#F7AEC4,stroke:#333,stroke-width:2px;
    classDef config fill:#E0E0E0,stroke:#333,stroke-width:2px;
    classDef external fill:#D3BDF0,stroke:#333,stroke-width:2px;
```
