# katonaj/study-planning-agent architecture

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

- Interactive diagram: https://gitdiagram.com/katonaj/study-planning-agent
- Repository: https://github.com/katonaj/study-planning-agent

## Overview

Study Planning Agent accepts student and assignment data, checks for missing input, requests calendar availability, plans sessions, and returns a StudyPlan. The orchestrator coordinates workflow states, calendar access, persistence, and memory; the planner applies priority/deadline ordering and session limits. The README also documents domain modeling, calendar success/failure behavior, relational persistence, request-state tracking, tool-call logs, and agent memory. The graph reflects the sampled runtime and documented capabilities; unsampled subsystem details and relationships are omitted where evidence is insufficient.

Main entry points: [`agent/orchestrator.py`](https://github.com/katonaj/study-planning-agent/blob/main/agent/orchestrator.py) (Workflow orchestrator), [`run.py`](https://github.com/katonaj/study-planning-agent/blob/main/run.py) (Demo entry point), [`adapters/sqlite_database.py`](https://github.com/katonaj/study-planning-agent/blob/main/adapters/sqlite_database.py) (SQLite connection setup), [`adapters/sqlite_repository.py`](https://github.com/katonaj/study-planning-agent/blob/main/adapters/sqlite_repository.py) (SQLite study repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Application workflow"]
  node_entry["Demo entry point<br/>[run.py]"]
  node_orchestrator["Workflow orchestrator<br/>[orchestrator.py]"]
  node_states["Workflow states<br/>[states.py]"]
  node_planner["Study planner<br/>[planner.py]"]
end

subgraph group_contracts["Domain and ports"]
  node_models["Study domain model<br/>[models.py]"]
  node_calendar_port["Calendar contract<br/>[calendar_port.py]"]
  node_repository_port["Study repository contract"]
  node_memory_port["Memory contract<br/>[memory_store.py]"]
end

subgraph group_adapters["Runtime adapters"]
  node_calendar_adapter["Fake calendar<br/>[fake_calendar.py]"]
  node_sqlite_repository["SQLite study repository"]
  node_sqlite_memory["SQLite agent memory<br/>[sqlite_memory.py]"]
end

subgraph group_persistence["Relational persistence"]
  node_db_helper["SQLite connection setup<br/>[sqlite_database.py]"]
  node_schema["Relational schema<br/>[schema.sql]"]
  node_database[("SQLite database")]
end

node_user(("Student user"))

node_user -->|"provides input"| node_entry
node_entry -->|"starts workflow"| node_orchestrator
node_orchestrator -->|"delegates planning"| node_planner
node_planner -->|"builds plan"| node_models
node_orchestrator -->|"returns plan"| node_models
node_orchestrator -->|"updates state"| node_states
node_orchestrator -->|"requests availability"| node_calendar_port
node_calendar_adapter -->|"implements contract"| node_calendar_port
node_orchestrator -->|"persists workflow"| node_repository_port
node_sqlite_repository -->|"implements contract"| node_repository_port
node_orchestrator -->|"records events"| node_memory_port
node_sqlite_memory -->|"implements contract"| node_memory_port
node_sqlite_repository -->|"opens connections"| node_db_helper
node_sqlite_memory -->|"opens connections"| node_db_helper
node_db_helper -->|"loads schema"| node_schema
node_db_helper -->|"initializes database"| node_database
node_sqlite_repository -->|"stores study data"| node_database
node_sqlite_memory -->|"stores memory events"| node_database
node_entry -->|"initializes storage"| node_database
node_entry -->|"displays plan"| node_user

click node_entry "https://github.com/katonaj/study-planning-agent/blob/main/run.py"
click node_orchestrator "https://github.com/katonaj/study-planning-agent/blob/main/agent/orchestrator.py"
click node_states "https://github.com/katonaj/study-planning-agent/blob/main/agent/states.py"
click node_planner "https://github.com/katonaj/study-planning-agent/blob/main/agent/planner.py"
click node_models "https://github.com/katonaj/study-planning-agent/blob/main/domain/models.py"
click node_calendar_port "https://github.com/katonaj/study-planning-agent/blob/main/ports/calendar_port.py"
click node_repository_port "https://github.com/katonaj/study-planning-agent/blob/main/ports/study_repository.py"
click node_memory_port "https://github.com/katonaj/study-planning-agent/blob/main/ports/memory_store.py"
click node_calendar_adapter "https://github.com/katonaj/study-planning-agent/blob/main/adapters/fake_calendar.py"
click node_sqlite_repository "https://github.com/katonaj/study-planning-agent/blob/main/adapters/sqlite_repository.py"
click node_sqlite_memory "https://github.com/katonaj/study-planning-agent/blob/main/adapters/sqlite_memory.py"
click node_db_helper "https://github.com/katonaj/study-planning-agent/blob/main/adapters/sqlite_database.py"
click node_schema "https://github.com/katonaj/study-planning-agent/blob/main/db/schema.sql"

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_entry,node_orchestrator,node_states,node_planner,node_user toneBlue
class node_models,node_calendar_port,node_repository_port,node_memory_port toneAmber
class node_calendar_adapter,node_sqlite_repository,node_sqlite_memory toneMint
class node_db_helper,node_schema,node_database toneRose
```

## Components

### Application workflow

- [Demo entry point](https://github.com/katonaj/study-planning-agent/blob/main/run.py): `run.py`
- [Workflow orchestrator](https://github.com/katonaj/study-planning-agent/blob/main/agent/orchestrator.py): `agent/orchestrator.py`
- [Workflow states](https://github.com/katonaj/study-planning-agent/blob/main/agent/states.py): `agent/states.py`
- [Study planner](https://github.com/katonaj/study-planning-agent/blob/main/agent/planner.py): `agent/planner.py`

### Domain and ports

- [Study domain model](https://github.com/katonaj/study-planning-agent/blob/main/domain/models.py): `domain/models.py`
- [Calendar contract](https://github.com/katonaj/study-planning-agent/blob/main/ports/calendar_port.py): `ports/calendar_port.py`
- [Study repository contract](https://github.com/katonaj/study-planning-agent/blob/main/ports/study_repository.py): `ports/study_repository.py`
- [Memory contract](https://github.com/katonaj/study-planning-agent/blob/main/ports/memory_store.py): `ports/memory_store.py`

### Runtime adapters

- [Fake calendar](https://github.com/katonaj/study-planning-agent/blob/main/adapters/fake_calendar.py): `adapters/fake_calendar.py`
- [SQLite study repository](https://github.com/katonaj/study-planning-agent/blob/main/adapters/sqlite_repository.py): `adapters/sqlite_repository.py`
- [SQLite agent memory](https://github.com/katonaj/study-planning-agent/blob/main/adapters/sqlite_memory.py): `adapters/sqlite_memory.py`

### Relational persistence

- [SQLite connection setup](https://github.com/katonaj/study-planning-agent/blob/main/adapters/sqlite_database.py): `adapters/sqlite_database.py`
- [Relational schema](https://github.com/katonaj/study-planning-agent/blob/main/db/schema.sql): `db/schema.sql`
- **SQLite database**

### Other components

- **Student user**

## Connections

- Student user → Demo entry point: provides input (evidence: `README.md`)
- Demo entry point → Workflow orchestrator: starts workflow (evidence: `run.py`)
- Workflow orchestrator → Study planner: delegates planning (evidence: `agent/orchestrator.py`)
- Study planner → Study domain model: builds plan (evidence: `agent/planner.py`)
- Workflow orchestrator → Study domain model: returns plan (evidence: `agent/orchestrator.py`)
- Workflow orchestrator → Workflow states: updates state (evidence: `agent/orchestrator.py`)
- Workflow orchestrator → Calendar contract: requests availability (evidence: `agent/orchestrator.py`)
- Fake calendar → Calendar contract: implements contract (evidence: `adapters/fake_calendar.py`)
- Workflow orchestrator → Study repository contract: persists workflow (evidence: `agent/orchestrator.py`)
- SQLite study repository → Study repository contract: implements contract (evidence: `adapters/sqlite_repository.py`)
- Workflow orchestrator → Memory contract: records events (evidence: `agent/orchestrator.py`)
- SQLite agent memory → Memory contract: implements contract (evidence: `adapters/sqlite_memory.py`)
- SQLite study repository → SQLite connection setup: opens connections (evidence: `adapters/sqlite_repository.py`)
- SQLite agent memory → SQLite connection setup: opens connections (evidence: `adapters/sqlite_memory.py`)
- SQLite connection setup → Relational schema: loads schema (evidence: `adapters/sqlite_database.py`)
- SQLite connection setup → SQLite database: initializes database (evidence: `adapters/sqlite_database.py`)
- SQLite study repository → SQLite database: stores study data (evidence: `adapters/sqlite_repository.py`)
- SQLite agent memory → SQLite database: stores memory events (evidence: `adapters/sqlite_memory.py`)
- Demo entry point → SQLite database: initializes storage (evidence: `run.py`)
- Demo entry point → Student user: displays plan (evidence: `run.py`)
