# kuldeepguptahub/sensei architecture

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

- Interactive diagram: https://gitdiagram.com/kuldeepguptahub/sensei
- Repository: https://github.com/kuldeepguptahub/sensei

## Overview

#### Purpose and Entry Points
Sensei is a Python AI learning engine that creates, teaches, assesses, and resumes personalized courses. The main user surfaces are a command-line workflow and a Streamlit dashboard. Package/command startup is rooted in `src/sensei/__main__.py`, with application orchestration in `src/sensei/main.py` and CLI commands in `src/sensei/cli/app.py`.

#### Agent Learning Lifecycle
The agent layer implements the adaptive course loop: gather learner/course context, conduct the interview and teaching conversation, evaluate performance, and advance progress. `src/sensei/agent/runner.py` is the likely session orchestrator; `src/sensei/agent/context.py`, `src/sensei/agent/evaluation.py`, and `src/sensei/agent/progression.py` define the major contextual, assessment, and advancement stages. Prompt-level behavioral rules live in `src/sensei/agent/instructions.md`.

#### Sessions, Tools, and Course Domain
Agent conversations are modeled as resumable sessions and use registered capabilities rather than directly coupling all behavior to storage or files. Key boundaries are `src/sensei/agent/session.py`, `src/sensei/agent/registry.py`, and `src/sensei/agent/tools.py`. Course management is split between domain-facing operations in `src/sensei/courses.py` and agent-accessible course skills in `src/sensei/skills/courses.py`.

#### LLM Gateway Boundary
All model-provider integration is isolated behind the gateway, supporting OpenAI-compatible and provider-specific services such as OpenRouter, OpenAI, Anthropic, Google, Ollama, and Hugging Face. `src/sensei/gateway/client.py` drives requests; `src/sensei/gateway/provider.py` and `src/sensei/gateway/providers.py` represent provider/model selection; `src/sensei/gateway/config.py` persists connection configuration. `src/sensei/gateway/retry.py` establishes resilience behavior around external API calls.

#### Persistence and Learning State
Persistent learning data is stored locally through `src/sensei/persistence/database.py`, with the repository containing a SQLite database artifact at `sensei.db`. `src/sensei/state/manager.py` provides the higher-level state boundary used to restore course/session progress. This supports the core resume flow independently of transient LLM conversation context.

#### Workspace and Artifact Capabilities
Course work is backed by filesystem-oriented skills for learner uploads, generated artifacts, and per-course workspaces. `src/sensei/skills/workspace.py`, `src/sensei/skills/artifacts.py`, and `src/sensei/skills/uploads.py` form the material-project boundary: the agent can guide implementation and inspect or manage learning outputs without embedding that logic in the LLM gateway.

#### UI and Control Flow
The CLI initiates provider setup, course lifecycle actions, and UI launch through `src/sensei/cli/app.py`. The Streamlit runtime is launched from `src/sensei/ui/app.py`; it separates course browsing/creation from interactive learning views in `src/sensei/ui/views/home.py` and `src/sensei/ui/views/chat.py`. Both interfaces should converge on shared agent, course, state, and gateway layers rather than maintaining independent learning logic.

Main entry points: [`src/sensei/agent/runner.py`](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/runner.py) (Learning session runner), [`src/sensei/courses.py`](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/courses.py) (Course operations), [`src/sensei/cli/app.py`](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/cli/app.py) (CLI commands), [`src/sensei/agent/registry.py`](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/registry.py) (Tool registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_startup["Package startup<br/>Python entry point<br/>[__main__.py]"]
  node_main["Application orchestration<br/>Python application<br/>[main.py]"]
  node_cli["CLI commands<br/>[app.py]"]
end

subgraph group_agent["Adaptive learning"]
  node_runner["Learning session runner<br/>agent orchestrator<br/>[runner.py]"]
  node_context["Learner context<br/>agent context<br/>[context.py]"]
  node_evaluation["Assessment<br/>agent stage<br/>[evaluation.py]"]
  node_progression["Progress advancement<br/>agent stage<br/>[progression.py]"]
  node_session["Resumable sessions<br/>conversation state<br/>[session.py]"]
  node_registry["Tool registry<br/>capability boundary<br/>[registry.py]"]
  node_instructions["Agent instructions<br/>prompt rules<br/>[instructions.md]"]
end

subgraph group_domain["Course and state"]
  node_courses["Course operations<br/>domain service<br/>[courses.py]"]
  node_state["Learning state manager<br/>state service<br/>[manager.py]"]
  node_database[("Local learning database<br/>SQLite persistence<br/>[database.py]")]
end

subgraph group_gateway["LLM gateway"]
  node_gateway["Model client<br/>LLM gateway<br/>[client.py]"]
  node_providers["Provider selection<br/>provider catalog<br/>[providers.py]"]
end

subgraph group_workspace["Learning workspace"]
  node_course_skills["Course skills<br/>agent skills<br/>[courses.py]"]
  node_workspace_skills["Workspace and artifacts<br/>filesystem skills<br/>[workspace.py]"]
end

subgraph group_ui["Dashboard"]
  node_dashboard["Streamlit runtime<br/>web UI<br/>[app.py]"]
  node_home["Course browser<br/>dashboard view<br/>[home.py]"]
  node_chat["Learning chat<br/>dashboard view<br/>[chat.py]"]
end

node_startup -->|"boots"| node_main
node_main -->|"runs"| node_cli
node_cli -->|"launches"| node_dashboard
node_dashboard -->|"renders"| node_home
node_dashboard -->|"renders"| node_chat
node_chat -->|"conducts learning"| node_runner
node_home -->|"browses and creates"| node_courses
node_cli -->|"manages"| node_courses
node_runner -->|"gathers"| node_context
node_runner -->|"maintains"| node_session
node_runner -->|"assesses"| node_evaluation
node_evaluation -->|"informs"| node_progression
node_runner -->|"uses capabilities"| node_registry
node_runner -.->|"follows"| node_instructions
node_runner -->|"requests responses"| node_gateway
node_gateway -->|"selects provider"| node_providers
node_registry -->|"registers"| node_course_skills
node_registry -->|"registers"| node_workspace_skills
node_course_skills -->|"accesses"| node_courses
node_workspace_skills -->|"records outputs"| node_database
node_runner -->|"restores and saves"| node_state
node_state -->|"persists"| node_database
node_courses -->|"stores courses"| node_database

click node_startup "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/__main__.py"
click node_main "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/main.py"
click node_cli "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/cli/app.py"
click node_runner "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/runner.py"
click node_context "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/context.py"
click node_evaluation "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/evaluation.py"
click node_progression "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/progression.py"
click node_session "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/session.py"
click node_registry "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/registry.py"
click node_instructions "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/instructions.md"
click node_courses "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/courses.py"
click node_state "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/state/manager.py"
click node_database "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/persistence/database.py"
click node_gateway "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/gateway/client.py"
click node_providers "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/gateway/providers.py"
click node_course_skills "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/skills/courses.py"
click node_workspace_skills "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/skills/workspace.py"
click node_dashboard "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/ui/app.py"
click node_home "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/ui/views/home.py"
click node_chat "https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/ui/views/chat.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_startup,node_main,node_cli toneBlue
class node_runner,node_context,node_evaluation,node_progression,node_session,node_registry,node_instructions toneAmber
class node_courses,node_state,node_database toneMint
class node_gateway,node_providers toneRose
class node_course_skills,node_workspace_skills toneIndigo
class node_dashboard,node_home,node_chat toneTeal
```

## Components

### Entry points

- [Package startup](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/__main__.py): Python entry point · `src/sensei/__main__.py`
- [Application orchestration](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/main.py): Python application · `src/sensei/main.py`
- [CLI commands](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/cli/app.py): CLI · Starts setup, course actions, and the dashboard. · `src/sensei/cli/app.py`

### Adaptive learning

- [Learning session runner](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/runner.py): agent orchestrator · Runs the interview, teaching, assessment, and resume loop. · `src/sensei/agent/runner.py`
- [Learner context](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/context.py): agent context · `src/sensei/agent/context.py`
- [Assessment](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/evaluation.py): agent stage · `src/sensei/agent/evaluation.py`
- [Progress advancement](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/progression.py): agent stage · `src/sensei/agent/progression.py`
- [Resumable sessions](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/session.py): conversation state · `src/sensei/agent/session.py`
- [Tool registry](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/registry.py): capability boundary · `src/sensei/agent/registry.py`
- [Agent instructions](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/agent/instructions.md): prompt rules · `src/sensei/agent/instructions.md`

### Course and state

- [Course operations](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/courses.py): domain service · `src/sensei/courses.py`
- [Learning state manager](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/state/manager.py): state service · Restores persisted course and session progress. · `src/sensei/state/manager.py`
- [Local learning database](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/persistence/database.py): SQLite persistence · `src/sensei/persistence/database.py`

### LLM gateway

- [Model client](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/gateway/client.py): LLM gateway · Executes model requests behind provider selection and retries. · `src/sensei/gateway/client.py`
- [Provider selection](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/gateway/providers.py): provider catalog · Selects OpenAI-compatible and provider-specific model services. · `src/sensei/gateway/providers.py`

### Learning workspace

- [Course skills](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/skills/courses.py): agent skills · `src/sensei/skills/courses.py`
- [Workspace and artifacts](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/skills/workspace.py): filesystem skills · Manages course workspaces, uploads, and generated outputs. · `src/sensei/skills/workspace.py`

### Dashboard

- [Streamlit runtime](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/ui/app.py): web UI · `src/sensei/ui/app.py`
- [Course browser](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/ui/views/home.py): dashboard view · `src/sensei/ui/views/home.py`
- [Learning chat](https://github.com/kuldeepguptahub/sensei/blob/main/src/sensei/ui/views/chat.py): dashboard view · `src/sensei/ui/views/chat.py`

## Connections

- Package startup → Application orchestration: boots
- Application orchestration → CLI commands: runs
- CLI commands → Streamlit runtime: launches
- Streamlit runtime → Course browser: renders
- Streamlit runtime → Learning chat: renders
- Learning chat → Learning session runner: conducts learning
- Course browser → Course operations: browses and creates
- CLI commands → Course operations: manages
- Learning session runner → Learner context: gathers
- Learning session runner → Resumable sessions: maintains
- Learning session runner → Assessment: assesses
- Assessment → Progress advancement: informs
- Learning session runner → Tool registry: uses capabilities
- Learning session runner → Agent instructions: follows
- Learning session runner → Model client: requests responses
- Model client → Provider selection: selects provider
- Tool registry → Course skills: registers
- Tool registry → Workspace and artifacts: registers
- Course skills → Course operations: accesses
- Workspace and artifacts → Local learning database: records outputs
- Learning session runner → Learning state manager: restores and saves
- Learning state manager → Local learning database: persists
- Course operations → Local learning database: stores courses
