# cube-ball/hackathon architecture

> Architecture diagram of the GitHub repository cube-ball/hackathon, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cube-ball/hackathon
- Repository: https://github.com/cube-ball/hackathon

## Overview

StudyFlow is a student study-planning app: students enter tasks, fixed commitments, and chat requests; the planner updates the plan, schedules study sessions, and presents deadlines and a calendar. The Streamlit frontend can run with demo behavior or delegate actions to the Python backend. The backend also covers AI-assisted updates, calendar event formatting, saved plans, and paid update access. Edges reflect shown calls or SOURCE INDEX references; some backend internals and the documented-but-unsampled product branches are represented only where their connections are supported.

Main entry points: [`Frontend/app.py`](https://github.com/cube-ball/hackathon/blob/main/Frontend/app.py) (StudyFlow app), [`backend/bridge.py`](https://github.com/cube-ball/hackathon/blob/main/backend/bridge.py) (Action handling), [`backend/billing.py`](https://github.com/cube-ball/hackathon/blob/main/backend/billing.py) (Stripe billing), [`backend/ai.py`](https://github.com/cube-ball/hackathon/blob/main/backend/ai.py) (AI interpretation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Student interface"]
  node_frontend_app["StudyFlow app<br/>[app.py]"]
  node_planner_service["Action planner<br/>[planner.py]"]
  node_demo_data["Demo plan data<br/>[demo_data.py]"]
  node_backend_adapter["Backend adapter<br/>[backend_bridge.py]"]
  node_chat_ui["Coach chat<br/>[chat.py]"]
  node_task_ui["Task editor<br/>[tasks.py]"]
  node_commitment_ui["Commitment editor<br/>[commitments.py]"]
  node_sidebar_ui["Plan sidebar<br/>[sidebar.py]"]
  node_calendar_ui["Week calendar<br/>[week_calendar.py]"]
  node_calendar_html["Calendar rendering<br/>[calendar_html.py]"]
  node_schedule_ui["Schedule view<br/>[schedule.py]"]
end

subgraph group_planning["Planning backend"]
  node_backend_bridge["Action handling<br/>[bridge.py]"]
  node_scheduler["Session scheduler<br/>[scheduler.py]"]
  node_demo_student["Demo student<br/>[demo_student.py]"]
  node_calendar_view["Calendar events<br/>[calendar_view.py]"]
end

subgraph group_ai["AI updates"]
  node_ai_updates["AI interpretation<br/>[ai.py]"]
end

subgraph group_account["Accounts and billing"]
  node_billing_api["Billing endpoints<br/>[app.py]"]
  node_billing["Stripe billing<br/>[billing.py]"]
  node_store[("SQLite records<br/>[store.py]")]
end

subgraph group_support["Shared services"]
  node_config["Backend settings<br/>[config.py]"]
  node_time_util["Time utilities<br/>[timeutil.py]"]
end

node_student(("Student"))
node_stripe["Stripe"]
node_openrouter["OpenRouter"]

node_student -->|"uses"| node_frontend_app
node_frontend_app -->|"dispatches actions"| node_planner_service
node_frontend_app -->|"loads demo plan"| node_demo_data
node_frontend_app -->|"renders"| node_chat_ui
node_frontend_app -->|"renders"| node_task_ui
node_frontend_app -->|"renders"| node_commitment_ui
node_frontend_app -->|"renders"| node_sidebar_ui
node_frontend_app -->|"renders"| node_calendar_ui
node_planner_service -->|"delegates actions"| node_backend_adapter
node_backend_adapter -->|"calls"| node_backend_bridge
node_calendar_ui -->|"uses"| node_calendar_html
node_backend_bridge -->|"replans"| node_scheduler
node_backend_bridge -->|"requests interpretation"| node_ai_updates
node_backend_bridge -->|"gets calendar events"| node_calendar_view
node_backend_bridge -->|"reads and saves"| node_store
node_backend_bridge -->|"creates upgrade links"| node_billing
node_backend_bridge -->|"loads demo profile"| node_demo_student
node_calendar_ui -->|"requests week events"| node_backend_adapter
node_scheduler -->|"uses time arithmetic"| node_time_util
node_ai_updates -->|"reads settings"| node_config
node_ai_updates -->|"uses time helpers"| node_time_util
node_billing_api -->|"handles checkout and webhooks"| node_billing
node_billing_api -->|"queries account"| node_store
node_billing -->|"records paid access"| node_store
node_billing -->|"creates checkout"| node_stripe
node_billing -->|"reads payment settings"| node_config
node_store -->|"uses database path"| node_config
node_ai_updates -.->|"sends AI requests"| node_openrouter

click node_frontend_app "https://github.com/cube-ball/hackathon/blob/main/Frontend/app.py"
click node_planner_service "https://github.com/cube-ball/hackathon/blob/main/Frontend/services/planner.py"
click node_demo_data "https://github.com/cube-ball/hackathon/blob/main/Frontend/services/demo_data.py"
click node_backend_adapter "https://github.com/cube-ball/hackathon/blob/main/Frontend/backend_bridge.py"
click node_chat_ui "https://github.com/cube-ball/hackathon/blob/main/Frontend/ui/chat.py"
click node_task_ui "https://github.com/cube-ball/hackathon/blob/main/Frontend/ui/tasks.py"
click node_commitment_ui "https://github.com/cube-ball/hackathon/blob/main/Frontend/ui/commitments.py"
click node_sidebar_ui "https://github.com/cube-ball/hackathon/blob/main/Frontend/ui/sidebar.py"
click node_calendar_ui "https://github.com/cube-ball/hackathon/blob/main/Frontend/ui/week_calendar.py"
click node_calendar_html "https://github.com/cube-ball/hackathon/blob/main/Frontend/ui/calendar_html.py"
click node_schedule_ui "https://github.com/cube-ball/hackathon/blob/main/Frontend/ui/schedule.py"
click node_backend_bridge "https://github.com/cube-ball/hackathon/blob/main/backend/bridge.py"
click node_scheduler "https://github.com/cube-ball/hackathon/blob/main/backend/scheduler.py"
click node_demo_student "https://github.com/cube-ball/hackathon/blob/main/backend/demo_student.py"
click node_calendar_view "https://github.com/cube-ball/hackathon/blob/main/backend/calendar_view.py"
click node_ai_updates "https://github.com/cube-ball/hackathon/blob/main/backend/ai.py"
click node_billing_api "https://github.com/cube-ball/hackathon/blob/main/backend/app.py"
click node_billing "https://github.com/cube-ball/hackathon/blob/main/backend/billing.py"
click node_store "https://github.com/cube-ball/hackathon/blob/main/backend/store.py"
click node_config "https://github.com/cube-ball/hackathon/blob/main/backend/config.py"
click node_time_util "https://github.com/cube-ball/hackathon/blob/main/backend/timeutil.py"

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_frontend_app,node_planner_service,node_demo_data,node_backend_adapter,node_chat_ui,node_task_ui,node_commitment_ui,node_sidebar_ui,node_calendar_ui,node_calendar_html,node_schedule_ui toneBlue
class node_backend_bridge,node_scheduler,node_demo_student,node_calendar_view toneAmber
class node_ai_updates,node_openrouter toneMint
class node_billing_api,node_billing,node_store toneRose
class node_config,node_time_util,node_student,node_stripe toneIndigo
```

## Components

### Student interface

- [StudyFlow app](https://github.com/cube-ball/hackathon/blob/main/Frontend/app.py): `Frontend/app.py`
- [Action planner](https://github.com/cube-ball/hackathon/blob/main/Frontend/services/planner.py): `Frontend/services/planner.py`
- [Demo plan data](https://github.com/cube-ball/hackathon/blob/main/Frontend/services/demo_data.py): `Frontend/services/demo_data.py`
- [Backend adapter](https://github.com/cube-ball/hackathon/blob/main/Frontend/backend_bridge.py): `Frontend/backend_bridge.py`
- [Coach chat](https://github.com/cube-ball/hackathon/blob/main/Frontend/ui/chat.py): `Frontend/ui/chat.py`
- [Task editor](https://github.com/cube-ball/hackathon/blob/main/Frontend/ui/tasks.py): `Frontend/ui/tasks.py`
- [Commitment editor](https://github.com/cube-ball/hackathon/blob/main/Frontend/ui/commitments.py): `Frontend/ui/commitments.py`
- [Plan sidebar](https://github.com/cube-ball/hackathon/blob/main/Frontend/ui/sidebar.py): `Frontend/ui/sidebar.py`
- [Week calendar](https://github.com/cube-ball/hackathon/blob/main/Frontend/ui/week_calendar.py): `Frontend/ui/week_calendar.py`
- [Calendar rendering](https://github.com/cube-ball/hackathon/blob/main/Frontend/ui/calendar_html.py): `Frontend/ui/calendar_html.py`
- [Schedule view](https://github.com/cube-ball/hackathon/blob/main/Frontend/ui/schedule.py): `Frontend/ui/schedule.py`

### Planning backend

- [Action handling](https://github.com/cube-ball/hackathon/blob/main/backend/bridge.py): `backend/bridge.py`
- [Session scheduler](https://github.com/cube-ball/hackathon/blob/main/backend/scheduler.py): `backend/scheduler.py`
- [Demo student](https://github.com/cube-ball/hackathon/blob/main/backend/demo_student.py): `backend/demo_student.py`
- [Calendar events](https://github.com/cube-ball/hackathon/blob/main/backend/calendar_view.py): `backend/calendar_view.py`

### AI updates

- [AI interpretation](https://github.com/cube-ball/hackathon/blob/main/backend/ai.py): `backend/ai.py`

### Accounts and billing

- [Billing endpoints](https://github.com/cube-ball/hackathon/blob/main/backend/app.py): `backend/app.py`
- [Stripe billing](https://github.com/cube-ball/hackathon/blob/main/backend/billing.py): `backend/billing.py`
- [SQLite records](https://github.com/cube-ball/hackathon/blob/main/backend/store.py): `backend/store.py`

### Shared services

- [Backend settings](https://github.com/cube-ball/hackathon/blob/main/backend/config.py): `backend/config.py`
- [Time utilities](https://github.com/cube-ball/hackathon/blob/main/backend/timeutil.py): `backend/timeutil.py`

### Other components

- **Student**
- **Stripe**
- **OpenRouter**

## Connections

- Student → StudyFlow app: uses (evidence: `Frontend/app.py`)
- StudyFlow app → Action planner: dispatches actions (evidence: `Frontend/app.py`)
- StudyFlow app → Demo plan data: loads demo plan (evidence: `Frontend/app.py`)
- StudyFlow app → Coach chat: renders (evidence: `Frontend/app.py`)
- StudyFlow app → Task editor: renders (evidence: `Frontend/app.py`)
- StudyFlow app → Commitment editor: renders (evidence: `Frontend/app.py`)
- StudyFlow app → Plan sidebar: renders (evidence: `Frontend/app.py`)
- StudyFlow app → Week calendar: renders (evidence: `Frontend/app.py`)
- Action planner → Backend adapter: delegates actions (evidence: `Frontend/services/planner.py`)
- Backend adapter → Action handling: calls (evidence: `Frontend/backend_bridge.py`)
- Week calendar → Calendar rendering: uses (evidence: `Frontend/ui/week_calendar.py`)
- Action handling → Session scheduler: replans (evidence: `backend/bridge.py`)
- Action handling → AI interpretation: requests interpretation (evidence: `backend/bridge.py`)
- Action handling → Calendar events: gets calendar events (evidence: `backend/bridge.py`)
- Action handling → SQLite records: reads and saves (evidence: `backend/bridge.py`)
- Action handling → Stripe billing: creates upgrade links (evidence: `backend/bridge.py`)
- Action handling → Demo student: loads demo profile (evidence: `backend/bridge.py`)
- Week calendar → Backend adapter: requests week events (evidence: `Frontend/ui/week_calendar.py`)
- Session scheduler → Time utilities: uses time arithmetic (evidence: `backend/scheduler.py`)
- AI interpretation → Backend settings: reads settings (evidence: `backend/ai.py`)
- AI interpretation → Time utilities: uses time helpers (evidence: `backend/ai.py`)
- Billing endpoints → Stripe billing: handles checkout and webhooks (evidence: `backend/app.py`)
- Billing endpoints → SQLite records: queries account (evidence: `backend/app.py`)
- Stripe billing → SQLite records: records paid access (evidence: `backend/billing.py`)
- Stripe billing → Stripe: creates checkout (evidence: `backend/billing.py`)
- Stripe billing → Backend settings: reads payment settings (evidence: `backend/billing.py`)
- SQLite records → Backend settings: uses database path (evidence: `backend/store.py`)
- AI interpretation → OpenRouter: sends AI requests
