# mohit-pr-95/functowerce architecture

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

- Interactive diagram: https://gitdiagram.com/mohit-pr-95/functowerce
- Repository: https://github.com/mohit-pr-95/functowerce

## Overview

#### Purpose and Deployment Model
Functowerce is a mostly static educational platform for learning mathematical functions through explanatory content, canvas/SVG visualizations, and a quadratic calculator. The browser frontend is intended for GitHub Pages; a separate Flask service, deployable on Render, supplies calculator results. Core entry points: `index.html`, `quadratic.html`, and `brain.py`.

#### Main Educational Experience
`index.html` is the primary learning page: function theory, references, navigation, set-mapping visualization, and graphing UI are rendered as static HTML and enhanced client-side. `index2.html` is an alternate/archived enhanced layout rather than the primary product route.
- `index.html`
- `index2.html`
- `style.css`

#### Client Interaction and Visualization Layer
`script.js` owns browser-side behavior: DOM interaction, responsive/navigation controls, set-to-codomain mapping effects, and interactive graphing. The graphing stage evaluates built-in function definitions in JavaScript and draws grid, axes, curves, and tracked coordinates using browser Canvas; it does not require the API for visualization.
- `script.js`
- `index.html`
- `style.css`

#### Quadratic Calculator Flow
`quadratic.html` provides the focused calculator route. User input is validated/collected in the browser, sent as an HTTP GET query parameter (`n`) to `/calculate`, and the returned JSON `result` or `error` is displayed in the page. This API boundary isolates server-backed calculations from the static frontend.
- `quadratic.html`
- `brain.py`

#### Flask API and Math Engine
`brain.py` combines the Python mathematical-function library and Flask transport layer. Its primary public endpoints are `/calculate`, which parses a numeric request and returns the square, and `/health`, which reports service availability. The module also contains reusable operations such as powers, roots, factorial/floor, and trigonometry that can support future endpoints.
- `brain.py`
- `requirements.txt`

#### Cross-Origin and Runtime Boundary
Frontend and backend are independently hosted origins, so Flask/CORS support is material: the API must permit browser requests from the GitHub Pages frontend. The local development topology is a static HTTP server for HTML/JS/CSS plus a Python 3.7+ Flask process on port 5000; production expects Flask/Gunicorn-compatible hosting on Render.
- `brain.py`
- `requirements.txt`
- `quadratic.html`

#### Extension Points
New learning pages belong alongside the existing HTML routes; new local grapher functions are added in the client function set in `script.js`. Server-calculated functions require both a computation function and Flask endpoint in `brain.py`, followed by a frontend fetch integration. Styling and responsive presentation are centralized in `style.css`.
- `script.js`
- `brain.py`
- `style.css`

Main entry points: [`brain.py`](https://github.com/mohit-pr-95/functowerce/blob/main/brain.py) (Flask application), [`index.html`](https://github.com/mohit-pr-95/functowerce/blob/main/index.html) (Learning page), [`quadratic.html`](https://github.com/mohit-pr-95/functowerce/blob/main/quadratic.html) (Quadratic calculator), [`script.js`](https://github.com/mohit-pr-95/functowerce/blob/main/script.js) (Interaction and grapher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Static frontend"]
  node_learning_page["Learning page<br/>HTML route<br/>[index.html]"]
  node_alternate_page["Alternate layout<br/>HTML route<br/>[index2.html]"]
  node_calculator_page["Quadratic calculator<br/>HTML route<br/>[quadratic.html]"]
  node_client_behavior["Interaction and grapher<br/>browser JavaScript<br/>[script.js]"]
  node_canvas_grapher["Local function renderer<br/>Canvas visualization<br/>[script.js]"]
  node_styles["Shared presentation<br/>CSS<br/>[style.css]"]
end

subgraph group_api["Calculation API"]
  node_flask_app{{"Flask application<br/>Python service<br/>[brain.py]"}}
  node_calculate_endpoint["GET /calculate<br/>Flask endpoint<br/>[brain.py]"]
  node_math_engine["Math operations<br/>Python library<br/>[brain.py]"]
  node_health_endpoint["GET /health<br/>Flask endpoint<br/>[brain.py]"]
  node_dependencies["Python dependencies<br/>requirements<br/>[requirements.txt]"]
end

subgraph group_runtime["Deployment boundary"]
  node_static_host["Static host"]
  node_api_host["API host<br/>Render / Gunicorn runtime"]
  node_browser(("Browser<br/>client runtime"))
end

node_static_host -->|"serves"| node_learning_page
node_static_host -->|"serves"| node_calculator_page
node_learning_page -->|"enhanced by"| node_client_behavior
node_alternate_page -.->|"enhanced by"| node_client_behavior
node_client_behavior -->|"renders locally"| node_canvas_grapher
node_learning_page -->|"uses"| node_styles
node_calculator_page -->|"uses"| node_styles
node_calculator_page -->|"GET n; JSON response"| node_calculate_endpoint
node_api_host -->|"runs"| node_flask_app
node_dependencies -->|"provides runtime packages"| node_flask_app
node_flask_app -->|"exposes"| node_calculate_endpoint
node_flask_app -->|"exposes"| node_health_endpoint
node_calculate_endpoint -->|"uses square operation"| node_math_engine
node_browser -->|"loads frontend"| node_static_host
node_browser -.->|"cross-origin API request"| node_api_host

click node_learning_page "https://github.com/mohit-pr-95/functowerce/blob/main/index.html"
click node_alternate_page "https://github.com/mohit-pr-95/functowerce/blob/main/index2.html"
click node_calculator_page "https://github.com/mohit-pr-95/functowerce/blob/main/quadratic.html"
click node_client_behavior "https://github.com/mohit-pr-95/functowerce/blob/main/script.js"
click node_canvas_grapher "https://github.com/mohit-pr-95/functowerce/blob/main/script.js"
click node_styles "https://github.com/mohit-pr-95/functowerce/blob/main/style.css"
click node_flask_app "https://github.com/mohit-pr-95/functowerce/blob/main/brain.py"
click node_calculate_endpoint "https://github.com/mohit-pr-95/functowerce/blob/main/brain.py"
click node_math_engine "https://github.com/mohit-pr-95/functowerce/blob/main/brain.py"
click node_health_endpoint "https://github.com/mohit-pr-95/functowerce/blob/main/brain.py"
click node_dependencies "https://github.com/mohit-pr-95/functowerce/blob/main/requirements.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_learning_page,node_alternate_page,node_calculator_page,node_client_behavior,node_canvas_grapher,node_styles toneBlue
class node_flask_app,node_calculate_endpoint,node_math_engine,node_health_endpoint,node_dependencies toneAmber
class node_static_host,node_api_host,node_browser toneMint
```

## Components

### Static frontend

GitHub Pages-hosted learning experience.

- [Learning page](https://github.com/mohit-pr-95/functowerce/blob/main/index.html): HTML route · Primary function theory and visualization page. · `index.html`
- [Alternate layout](https://github.com/mohit-pr-95/functowerce/blob/main/index2.html): HTML route · Archived enhanced learning layout. · `index2.html`
- [Quadratic calculator](https://github.com/mohit-pr-95/functowerce/blob/main/quadratic.html): HTML route · Collects input and displays calculation responses. · `quadratic.html`
- [Interaction and grapher](https://github.com/mohit-pr-95/functowerce/blob/main/script.js): browser JavaScript · Handles UI, mapping effects, and canvas graphing. · `script.js`
- [Local function renderer](https://github.com/mohit-pr-95/functowerce/blob/main/script.js): Canvas visualization · Draws grids, curves, and tracked coordinates from built-in functions. · `script.js`
- [Shared presentation](https://github.com/mohit-pr-95/functowerce/blob/main/style.css): CSS · Centralizes styling and responsive layout. · `style.css`

### Calculation API

Separately deployable Flask service.

- [Flask application](https://github.com/mohit-pr-95/functowerce/blob/main/brain.py): Python service · Owns HTTP transport and reusable math operations. · `brain.py`
- [GET /calculate](https://github.com/mohit-pr-95/functowerce/blob/main/brain.py): Flask endpoint · Parses n and returns a JSON result or error. · `brain.py`
- [Math operations](https://github.com/mohit-pr-95/functowerce/blob/main/brain.py): Python library · Includes square, powers, roots, factorial, floor, and trigonometry. · `brain.py`
- [GET /health](https://github.com/mohit-pr-95/functowerce/blob/main/brain.py): Flask endpoint · Reports service availability. · `brain.py`
- [Python dependencies](https://github.com/mohit-pr-95/functowerce/blob/main/requirements.txt): requirements · Provides Flask and deployment dependencies. · `requirements.txt`

### Deployment boundary

Independent browser and Python runtimes.

- **Static host**: GitHub Pages / local server · Serves HTML, JavaScript, and CSS.
- **API host**: Render / Gunicorn runtime · Runs the Flask process independently.
- **Browser**: client runtime

## Connections

- Static host → Learning page: serves
- Static host → Quadratic calculator: serves
- Learning page → Interaction and grapher: enhanced by
- Alternate layout → Interaction and grapher: enhanced by
- Interaction and grapher → Local function renderer: renders locally
- Learning page → Shared presentation: uses
- Quadratic calculator → Shared presentation: uses
- Quadratic calculator → GET /calculate: GET n; JSON response · Cross-origin browser request.
- API host → Flask application: runs
- Python dependencies → Flask application: provides runtime packages
- Flask application → GET /calculate: exposes
- Flask application → GET /health: exposes
- GET /calculate → Math operations: uses square operation
- Browser → Static host: loads frontend
- Browser → API host: cross-origin API request · CORS permits requests from the static frontend.
