# adalinger/enzyme-calculator architecture

> Architecture diagram of the GitHub repository adalinger/enzyme-calculator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adalinger/enzyme-calculator
- Repository: https://github.com/adalinger/enzyme-calculator

## Overview

##### Project type + purpose (from file tree + README)
This is a **single-page frontend web application (SPA)** implemented in **React + TypeScript**. Its purpose is narrowly scoped: a **pancreatic enzyme dosage calculator**. There is **no backend service** in the repository and no database; all computation and UI happen in the browser. Deployment target is **GitHub Pages** (static hosting).

##### What the file structure implies architecturally
Key directories/files:

- `public/`
Static assets and HTML shell:
- `public/index.html` is the SPA entry document where the React bundle mounts.
- `manifest.json`, `robots.txt` are typical CRA (Create React App) artifacts.

- `src/`
The entire application code:
- `src/index.tsx`: React bootstrap (renders `<App />` into DOM).
- `src/main/App.tsx`: top-level application component (composition/root UI).
- `src/main/Calculator.tsx`: the calculator UI + logic (domain functionality).
- `src/index.css`: global styling.
- `src/reportWebVitals.ts`: performance instrumentation (optional).
- `src/setupTests.ts`: testing setup (Jest/RTL baseline).
- `src/react-app-env.d.ts`: TypeScript/CRA typings.

- `package.json`, `package-lock.json`, `tsconfig.json`: build tooling, dependencies, TypeScript config.
- Deployment is indicated by README: `npm run deploy` to GitHub Pages (commonly via `gh-pages`).

Architectural pattern: **client-only, component-based UI**, with calculator logic most likely living inside `Calculator.tsx` (or as helper functions inside it). No explicit state management library present in tree; likely React local state.

##### What the README adds
- Confirms runtime: **React**.
- Confirms hosting: **GitHub Pages**.
- Confirms lifecycle: start/test/build/deploy scripts.

##### User + Browser runtime
- “End User”
- “Web Browser (React SPA runtime)”

##### Static hosting
- “GitHub Pages (static site hosting + CDN-like delivery)”

##### App shell + React entry
- `public/index.html` (mount point)
- `src/index.tsx` (bootstraps React, renders App)

##### UI component hierarchy
- `App.tsx` (root component)
- `Calculator.tsx` (core feature component)

##### Domain logic / calculation
- “Enzyme dosage calculation logic” (even if embedded in `Calculator.tsx`, represent it as a subcomponent/module for clarity)

##### Observability (optional but real)
- `reportWebVitals.ts` (performance metrics; show as optional path)

##### Build & deploy toolchain
- “Node.js + npm scripts”
- “React build pipeline (CRA / webpack under the hood)”
- “Build artifacts (static JS/CSS bundle)”
- “Deploy script → GitHub Pages”

##### Test tooling (engineering view)
- “Jest/React Testing Library (via `setupTests.ts`)”

**Runtime flow (what users experience):**
##### `index.tsx` → renders `App.tsx` → contains/instantiates `Calculator.tsx`
6. User inputs in Calculator UI → Calculator state updates → calculation logic runs → UI renders results

**Build/deploy flow (what engineers do):**
1. Engineer → `npm run build` → build toolchain → outputs static assets (`build/` directory conceptually)
##### Engineer → `npm run deploy` → publishes build output → GitHub Pages

**Optional telemetry flow (if enabled):**
- Browser app → `reportWebVitals.ts` → (potential) external analytics endpoint
If the project doesn’t configure an endpoint, show it as “optional / not configured”.

##### Architectural patterns/design principles present
- **SPA + static hosting**: no server-side rendering, no API dependency.
- **Component-based architecture**: React components compose UI.
- **Separation of concerns (lightweight)**:
- Entry/bootstrap (`index.tsx`)
- Root composition (`App.tsx`)
- Feature module (`Calculator.tsx`)
- Styling (`index.css`)
- **Deterministic domain logic**: calculator computations are pure-ish and should be isolated (even if currently co-located).

##### Technologies that should be explicitly labeled
- React, TypeScript
- GitHub Pages
- Node.js/npm (for build/test/deploy)
- Jest/testing setup (for dev workflow view)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% =========================================================
    %% RUNTIME ARCHITECTURE (Client-only SPA)
    %% =========================================================
    U["End User"]:::external

    subgraph "Static Hosting (Internet)"
        GH["GitHub Pages (Static Site Hosting)"]:::hosting
        CDN["Static Asset Delivery (HTML/CSS/JS)"]:::hosting
        GH -->|"serves"| CDN
    end

    subgraph "User Device"
        B["Web Browser (React SPA Runtime)"]:::runtime

        subgraph "App Shell + Bootstrap"
            H["public/index.html (SPA Mount Point)"]:::doc
            I["src/index.tsx (React Bootstrap)"]:::module
        end

        subgraph "UI Component Hierarchy (React + TypeScript)"
            A["src/main/App.tsx (Root Component)"]:::component
            C["src/main/Calculator.tsx (Calculator UI + State)"]:::component

            subgraph "Domain Core"
                L["Enzyme Dosage Calculation Logic (embedded)"]:::logic
            end
        end

        subgraph "Styling"
            CSS["src/index.css (Global Styles)"]:::sty
        end

        subgraph "Observability (Optional)"
            W["src/reportWebVitals.ts (Performance Instrumentation)"]:::observability
            EXT["External Analytics Endpoint (Not Configured)"]:::external
        end
    end

    %% Runtime / network flow
    U -->|"uses"| B
    B -->|"GET / (static site)"| GH
    CDN -->|"returns index.html + bundles"| B

    %% Runtime / SPA boot flow
    B -->|"loads"| H
    H -->|"executes JS bundle"| I
    I -->|"renders"| A
    A -->|"composes"| C
    C -->|"invokes"| L
    CSS -->|"styles"| A
    CSS -->|"styles"| C

    %% Optional telemetry
    B -.->|"optional metrics"| W
    W -.->|"send (optional)"| EXT

    %% =========================================================
    %% ENGINEERING WORKFLOW (Build/Test/Deploy)
    %% =========================================================
    subgraph "Developer Workflow"
        DEV["Developer Workstation"]:::dev

        subgraph "Toolchain (Node.js + npm)"
            NPM["npm scripts (start/test/build/deploy)"]:::tooling
            PKG["package.json (scripts + deps)"]:::config
            TSC["tsconfig.json (TypeScript Config)"]:::config
            TYP["src/react-app-env.d.ts (CRA/TS Typings)"]:::config
        end

        subgraph "Quality"
            TEST["Jest + React Testing Library"]:::tooling
            SETUP["src/setupTests.ts (Test Setup)"]:::module
        end

        subgraph "Build & Release"
            BUILD["React Scripts Build Pipeline (CRA)"]:::tooling
            ART["Static Build Artifacts (JS/CSS/HTML)"]:::artifact
            DEP["npm run deploy (Publish to GitHub Pages)"]:::tooling
        end
    end

    DEV -->|"runs"| NPM
    PKG -->|"defines"| NPM
    TSC -->|"configures"| BUILD
    TYP -->|"enables TS env"| BUILD

    NPM -->|"npm test"| TEST
    SETUP -->|"configures"| TEST

    NPM -->|"npm run build"| BUILD
    BUILD -->|"outputs"| ART
    NPM -->|"npm run deploy"| DEP
    ART -->|"published"| DEP
    DEP -->|"deploys to"| GH

    %% =========================================================
    %% Click Events (from component_mapping)
    %% =========================================================
    click H "https://github.com/adalinger/enzyme-calculator/blob/main/public/index.html"
    click GH "https://github.com/adalinger/enzyme-calculator/blob/main/package.json"
    click PKG "https://github.com/adalinger/enzyme-calculator/blob/main/package.json"
    click I "https://github.com/adalinger/enzyme-calculator/blob/main/src/index.tsx"
    click CSS "https://github.com/adalinger/enzyme-calculator/blob/main/src/index.css"
    click A "https://github.com/adalinger/enzyme-calculator/blob/main/src/main/App.tsx"
    click C "https://github.com/adalinger/enzyme-calculator/blob/main/src/main/Calculator.tsx"
    click L "https://github.com/adalinger/enzyme-calculator/blob/main/src/main/Calculator.tsx"
    click W "https://github.com/adalinger/enzyme-calculator/blob/main/src/reportWebVitals.ts"
    click SETUP "https://github.com/adalinger/enzyme-calculator/blob/main/src/setupTests.ts"
    click TYP "https://github.com/adalinger/enzyme-calculator/blob/main/src/react-app-env.d.ts"
    click TSC "https://github.com/adalinger/enzyme-calculator/blob/main/tsconfig.json"

    %% also map remaining public files as nodes for click coverage
    subgraph "Public Assets (CRA)"
        MAN["public/manifest.json"]:::doc
        ROB["public/robots.txt"]:::doc
    end
    GH -->|"serves"| MAN
    GH -->|"serves"| ROB
    click MAN "https://github.com/adalinger/enzyme-calculator/blob/main/public/manifest.json"
    click ROB "https://github.com/adalinger/enzyme-calculator/blob/main/public/robots.txt"

    %% =========================================================
    %% Styles
    %% =========================================================
    classDef external fill:#ffffff,stroke:#111827,stroke-width:1.5px,color:#111827
    classDef hosting fill:#dcfce7,stroke:#166534,stroke-width:1.5px,color:#14532d
    classDef runtime fill:#dbeafe,stroke:#1d4ed8,stroke-width:1.5px,color:#1e3a8a
    classDef component fill:#bfdbfe,stroke:#1d4ed8,stroke-width:1.5px,color:#1e3a8a
    classDef module fill:#93c5fd,stroke:#1d4ed8,stroke-width:1.5px,color:#1e3a8a
    classDef logic fill:#60a5fa,stroke:#1d4ed8,stroke-width:1.5px,color:#0b3b8f
    classDef sty fill:#bae6fd,stroke:#0369a1,stroke-width:1.5px,color:#0c4a6e
    classDef observability fill:#fde68a,stroke:#b45309,stroke-width:1.5px,color:#7c2d12
    classDef tooling fill:#e5e7eb,stroke:#374151,stroke-width:1.5px,color:#111827
    classDef artifact fill:#f3f4f6,stroke:#4b5563,stroke-width:1.5px,color:#111827
    classDef dev fill:#f5d0fe,stroke:#7e22ce,stroke-width:1.5px,color:#581c87
    classDef config fill:#fecaca,stroke:#b91c1c,stroke-width:1.5px,color:#7f1d1d
    classDef doc fill:#fff7ed,stroke:#c2410c,stroke-width:1.5px,color:#7c2d12
```
