# nabin2004/openclassrooms architecture

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

- Interactive diagram: https://gitdiagram.com/nabin2004/openclassrooms
- Repository: https://github.com/nabin2004/openclassrooms

## Overview

1. **Repository shape**
   - This is a Python 3.14, `uv`-managed monorepo with four real product areas: `manimator`, `autolecture`, `webapp`, and `amoeba`.
   - The root package (`openclassrooms`) is a lightweight metapackage plus repo-level scripts, tests, and shared developer workflows.

2. **Primary system: `manimator`**
   - `manimator` is the main end-to-end pipeline in this repo.
   - It turns a user request into a structured teaching/scene plan, generates or repairs animation code, renders Manim scenes, optionally adds narration, and packages the final video output.
   - The top-level entrypoint is `manimator/main.py`, with pipeline orchestration in `manimator/pipeline/`.

3. **Manimator pipeline boundary**
   - `manimator/pipeline/state.py` and `manimator/pipeline/graph.py` indicate a stateful, graph-driven workflow rather than a single linear script.
   - Each stage passes a shared pipeline state through agent nodes, which makes the architecture good for retries, validation loops, and repair cycles.
   - The repo’s logs and outputs suggest per-run artifacts are persisted, including scene videos, narration tracks, transcripts, and final delivery bundles.

4. **Agent layer inside `manimator`**
   - `manimator/agents/` contains specialized roles: intent classification, scene decomposition, planning, code generation, critique, validation, and repair.
   - This is a multi-agent orchestration boundary: each agent owns one decision surface and emits structured outputs consumed by the next stage.
   - The design suggests the pipeline can branch based on intent, critique outcomes, or validation failures.

5. **Structured contracts and IR**
   - `manimator/contracts/` defines the typed data exchanged between stages: intent, scene plan/spec, critique, validation, and LLM outputs.
   - `manimator/ir.py` plus `manimator/docs/ir/` show an internal representation layer used to stabilize the pipeline between language-model reasoning and executable animation code.
   - This contract layer is important for drawing the architecture: it is the seam between “LLM reasoning” and “deterministic execution.”

6. **Code safety and generation boundaries**
   - `manimator/manim_utils/` contains AST checks and class whitelisting, which implies generated code is inspected before execution.
   - That makes code generation a controlled boundary: LLM-produced Manim code is not executed directly without safety checks.
   - `manimator/exceptions.py` and `manimator/prompts/code_repair/` show explicit failure handling and recovery loops around this boundary.

7. **Audio and delivery path**
   - `manimator/audio/` handles narration generation, TTS configuration, and muxing audio back into video.
   - `manimator/video/delivery.py` likely packages the final render into a deliverable artifact, and the `outputs/delivery/` tree confirms final bundled runs are stored separately.
   - This creates a second major output path after scene rendering: visual video first, then narration and final muxed delivery.

8. **Prompting and model interaction**
   - `manimator/prompts/` contains versioned prompt templates for intent classification, scene planning, scene decomposition, and repair.
   - `manimator/runtime_env.py` and `manimator/runtime`-adjacent files imply environment-specific model/runtime settings are separated from the prompt text itself.
   - The architecture likely depends on LLM calls as a service boundary, with prompt versions treated as stable inputs to the agent layer.

9. **Observability and logging**
   - `manimator/logging/` and `manimator/observability/metrics.py` indicate explicit runtime instrumentation.
   - The README warning about `logging` name shadowing is an architectural constraint: the package layout can affect Python import resolution, so invocation style matters.
   - Repository logs under `logs/` and pipeline run artifacts under `outputs/` are part of the operational story, not just test data.

10. **`amoeba`: agent framework package**
   - `amoeba/` is a separate reusable agent framework, with core abstractions for agents, tools, memory, perception, LLM adapters, retry, and runtime.
   - It also includes environments (`envs/real.py`, `envs/sim.py`) and a graph/pipeline abstraction, so it appears to be the lower-level framework layer rather than the application.
   - In architecture terms, `amoeba` is the platform capability; `manimator` is the application built on top of agent orchestration ideas.

11. **`autolecture`: lecture-generation experiment**
   - `autolecture/` is another generation-focused project, but lighter-weight and narrower than `manimator`.
   - The presence of `scene_decomposer/` and TTS provider registry suggests it converts lecture material into scenes and narration, but with less of the validation/repair pipeline complexity seen in `manimator`.

12. **`webapp`: interactive application**
   - `webapp/` is a separate FastHTML app with its own database (`khan.db`) and app entrypoint.
   - It is architecturally distinct from the video-generation pipeline: this is a user-facing interface and persistence layer, not the media generation engine.

13. **Root-level scripts and workflows**
   - Root files like `test_agents.py`, `test_codegen.py`, `test_planner.py`, and `set_video_config.py` act as operational harnesses around the pipeline.
   - `Makefile`, `DEVELOPMENT.md`, and `AGENT_TESTING.md` define the repo’s workflow conventions and test entrypoints.
   - These scripts are important to diagram as “control surfaces” for exercising the pipeline without going through each package’s internal entrypoint.

14. **External/runtime dependencies that materially shape architecture**
   - Manim is the central rendering engine for `manimator`.
   - LLM calls are an architectural dependency across the agent layers.
   - TTS is optional but first-class in the media pipeline, and the repo explicitly supports provider-based narration.

15. **How to draw the main data flow**
   - For `manimator`, the clearest flow is: user query → intent/scene analysis → structured scene plan/IR → code generation → safety/validation/critique → repair loop if needed → render scenes → optional narration → mux/delivery → saved outputs.
   - The key boundaries are: contract/IR serialization, code safety checks, render execution, and audio/video finalization.

Main entry points: [`manimator/agents`](https://github.com/nabin2004/openclassrooms/tree/main/manimator/agents) (Agents), [`manimator/pipeline/graph.py`](https://github.com/nabin2004/openclassrooms/blob/main/manimator/pipeline/graph.py) (Pipeline graph), [`manimator/video/delivery.py`](https://github.com/nabin2004/openclassrooms/blob/main/manimator/video/delivery.py) (Delivery), [`amoeba/src/amoeba/core`](https://github.com/nabin2004/openclassrooms/tree/main/amoeba/src/amoeba/core) (Core)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_root["Root"]
  node_openclassrooms_pkg["openclassrooms<br/>metapackage<br/>[__init__.py]"]
  node_root_cli["Root CLI<br/>repo entrypoint<br/>[main.py]"]
  node_root_scripts["Test harnesses<br/>workflow scripts"]
  node_repo_docs["Repo docs<br/>guides<br/>[DEVELOPMENT.md]"]
end

subgraph group_manimator["Manimator"]
  node_manimator_entry["Pipeline entry<br/>app entrypoint<br/>[main.py]"]
  node_manimator_pipeline{{"Pipeline graph<br/>workflow<br/>[graph.py]"}}
  node_manimator_state["Pipeline state<br/>state model<br/>[state.py]"]
  node_manimator_agents["Agents<br/>multi-agent layer"]
  node_manimator_contracts["Contracts<br/>typed IR"]
  node_manimator_ir["IR<br/>intermediate representation<br/>[ir.py]"]
  node_manimator_prompts["Prompts<br/>prompt registry"]
  node_manimator_safety{{"Code safety<br/>validation boundary<br/>[ast_check.py]"}}
  node_manimator_audio["Audio path<br/>narration pipeline"]
  node_manimator_delivery["Delivery<br/>finalization<br/>[delivery.py]"]
  node_manimator_outputs[("Run outputs<br/>artifacts<br/>[final.mp4]")]
end

subgraph group_amoeba["Amoeba"]
  node_amoeba_core["Core<br/>agent runtime"]
  node_amoeba_graph{{"Graph runtime<br/>pipeline engine<br/>[pipeline.py]"}}
  node_amoeba_envs["Envs<br/>simulation layer"]
end

subgraph group_autolecture["Autolecture"]
  node_autolecture_scene{{"Scene decomposer<br/>lecture pipeline<br/>[agent.py]"}}
  node_autolecture_tts["TTS registry<br/>audio providers<br/>[registry.py]"]
end

subgraph group_webapp["Webapp"]
  node_webapp_main["Web app<br/>fastahtml app<br/>[main.py]"]
end

node_root_cli -->|"runs pipeline"| node_manimator_entry
node_root_scripts -->|"exercises"| node_manimator_agents
node_root_scripts -->|"drives"| node_manimator_pipeline
node_repo_docs -.->|"documents"| node_manimator_pipeline
node_manimator_entry -->|"orchestrates"| node_manimator_pipeline
node_manimator_pipeline -->|"threads state"| node_manimator_state
node_manimator_pipeline -->|"invokes"| node_manimator_agents
node_manimator_agents -->|"emit"| node_manimator_contracts
node_manimator_contracts -->|"stabilize"| node_manimator_ir
node_manimator_agents -->|"uses"| node_manimator_prompts
node_manimator_agents -->|"guards"| node_manimator_safety
node_manimator_agents -->|"optionally narrate"| node_manimator_audio
node_manimator_pipeline -->|"finalizes"| node_manimator_delivery
node_manimator_audio -->|"muxes into"| node_manimator_delivery
node_manimator_delivery -->|"persists"| node_manimator_outputs
node_amoeba_core -->|"supports"| node_amoeba_graph
node_amoeba_graph -->|"executes in"| node_amoeba_envs
node_amoeba_core -.->|"underlies"| node_manimator_agents
node_autolecture_scene -->|"uses"| node_autolecture_tts
node_webapp_main -.->|"serves artifacts"| node_manimator_outputs

click node_openclassrooms_pkg "https://github.com/nabin2004/openclassrooms/blob/main/openclassrooms/__init__.py"
click node_root_cli "https://github.com/nabin2004/openclassrooms/blob/main/main.py"
click node_repo_docs "https://github.com/nabin2004/openclassrooms/blob/main/DEVELOPMENT.md"
click node_manimator_entry "https://github.com/nabin2004/openclassrooms/blob/main/manimator/main.py"
click node_manimator_pipeline "https://github.com/nabin2004/openclassrooms/blob/main/manimator/pipeline/graph.py"
click node_manimator_state "https://github.com/nabin2004/openclassrooms/blob/main/manimator/pipeline/state.py"
click node_manimator_agents "https://github.com/nabin2004/openclassrooms/tree/main/manimator/agents"
click node_manimator_contracts "https://github.com/nabin2004/openclassrooms/tree/main/manimator/contracts"
click node_manimator_ir "https://github.com/nabin2004/openclassrooms/blob/main/manimator/ir.py"
click node_manimator_prompts "https://github.com/nabin2004/openclassrooms/tree/main/manimator/prompts"
click node_manimator_safety "https://github.com/nabin2004/openclassrooms/blob/main/manimator/manim_utils/ast_check.py"
click node_manimator_audio "https://github.com/nabin2004/openclassrooms/tree/main/manimator/audio"
click node_manimator_delivery "https://github.com/nabin2004/openclassrooms/blob/main/manimator/video/delivery.py"
click node_manimator_outputs "https://github.com/nabin2004/openclassrooms/blob/main/outputs/delivery/20260403T142331Z/final.mp4"
click node_amoeba_core "https://github.com/nabin2004/openclassrooms/tree/main/amoeba/src/amoeba/core"
click node_amoeba_graph "https://github.com/nabin2004/openclassrooms/blob/main/amoeba/src/amoeba/graph/pipeline.py"
click node_amoeba_envs "https://github.com/nabin2004/openclassrooms/tree/main/amoeba/src/amoeba/envs"
click node_autolecture_scene "https://github.com/nabin2004/openclassrooms/blob/main/autolecture/scene_decomposer/agent.py"
click node_autolecture_tts "https://github.com/nabin2004/openclassrooms/blob/main/autolecture/scene_decomposer/tts/registry.py"
click node_webapp_main "https://github.com/nabin2004/openclassrooms/blob/main/webapp/main.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_openclassrooms_pkg,node_root_cli,node_root_scripts,node_repo_docs toneBlue
class node_manimator_entry,node_manimator_pipeline,node_manimator_state,node_manimator_agents,node_manimator_contracts,node_manimator_ir,node_manimator_prompts,node_manimator_safety,node_manimator_audio,node_manimator_delivery,node_manimator_outputs toneAmber
class node_amoeba_core,node_amoeba_graph,node_amoeba_envs toneMint
class node_autolecture_scene,node_autolecture_tts toneRose
class node_webapp_main toneIndigo
```

## Components

### Root

Repo-level metapackage, scripts, docs, and workflow entrypoints.

- [openclassrooms](https://github.com/nabin2004/openclassrooms/blob/main/openclassrooms/__init__.py): metapackage · Lightweight repo package wrapper. · `openclassrooms/__init__.py`
- [Root CLI](https://github.com/nabin2004/openclassrooms/blob/main/main.py): repo entrypoint · Repository-level command entrypoint. · `main.py`
- **Test harnesses**: workflow scripts · Operational scripts for exercising agents and pipeline stages.
- [Repo docs](https://github.com/nabin2004/openclassrooms/blob/main/DEVELOPMENT.md): guides · Shared development, testing, and roadmap documentation. · `DEVELOPMENT.md`

### Manimator

Primary end-to-end teaching video generation pipeline.

- [Pipeline entry](https://github.com/nabin2004/openclassrooms/blob/main/manimator/main.py): app entrypoint · Main application entrypoint. · `manimator/main.py`
- [Pipeline graph](https://github.com/nabin2004/openclassrooms/blob/main/manimator/pipeline/graph.py): workflow · Stateful graph-driven orchestration boundary. · `manimator/pipeline/graph.py`
- [Pipeline state](https://github.com/nabin2004/openclassrooms/blob/main/manimator/pipeline/state.py): state model · Shared mutable run state passed across stages. · `manimator/pipeline/state.py`
- [Agents](https://github.com/nabin2004/openclassrooms/tree/main/manimator/agents): multi-agent layer · Intent, decomposition, planning, generation, critique, validation, and repair roles. · `manimator/agents`
- [Contracts](https://github.com/nabin2004/openclassrooms/tree/main/manimator/contracts): typed IR · Structured outputs exchanged between stages. · `manimator/contracts`
- [IR](https://github.com/nabin2004/openclassrooms/blob/main/manimator/ir.py): intermediate representation · Internal representation stabilizing LLM reasoning before execution. · `manimator/ir.py`
- [Prompts](https://github.com/nabin2004/openclassrooms/tree/main/manimator/prompts): prompt registry · Versioned prompt templates and prompt selection logic. · `manimator/prompts`
- [Code safety](https://github.com/nabin2004/openclassrooms/blob/main/manimator/manim_utils/ast_check.py): validation boundary · AST checks and class whitelisting before generated code executes. · `manimator/manim_utils/ast_check.py`
- [Audio path](https://github.com/nabin2004/openclassrooms/tree/main/manimator/audio): narration pipeline · TTS, narration generation, and muxing back into video. · `manimator/audio`
- [Delivery](https://github.com/nabin2004/openclassrooms/blob/main/manimator/video/delivery.py): finalization · Packages rendered scenes into final deliverables. · `manimator/video/delivery.py`
- [Run outputs](https://github.com/nabin2004/openclassrooms/blob/main/outputs/delivery/20260403T142331Z/final.mp4): artifacts · Persisted scene renders, narration tracks, transcripts, and delivery bundles. · `outputs/delivery/20260403T142331Z/final.mp4`

### Amoeba

Reusable agent framework and runtime layer.

- [Core](https://github.com/nabin2004/openclassrooms/tree/main/amoeba/src/amoeba/core): agent runtime · LLM, memory, tool, retry, and response primitives. · `amoeba/src/amoeba/core`
- [Graph runtime](https://github.com/nabin2004/openclassrooms/blob/main/amoeba/src/amoeba/graph/pipeline.py): pipeline engine · Node and pipeline abstraction for agent execution. · `amoeba/src/amoeba/graph/pipeline.py`
- [Envs](https://github.com/nabin2004/openclassrooms/tree/main/amoeba/src/amoeba/envs): simulation layer · Real and simulated execution environments for agents. · `amoeba/src/amoeba/envs`

### Autolecture

Smaller lecture-generation experiment.

- [Scene decomposer](https://github.com/nabin2004/openclassrooms/blob/main/autolecture/scene_decomposer/agent.py): lecture pipeline · Breaks lecture material into scenes and narration flow. · `autolecture/scene_decomposer/agent.py`
- [TTS registry](https://github.com/nabin2004/openclassrooms/blob/main/autolecture/scene_decomposer/tts/registry.py): audio providers · Provider registry and engine for narration generation. · `autolecture/scene_decomposer/tts/registry.py`

### Webapp

User-facing application and persistence layer.

- [Web app](https://github.com/nabin2004/openclassrooms/blob/main/webapp/main.py): fastahtml app · Interactive application entrypoint with its own database. · `webapp/main.py`

## Connections

- Root CLI → Pipeline entry: runs pipeline · Repo entrypoint can invoke the main video pipeline.
- Test harnesses → Agents: exercises · Standalone scripts target individual agent stages.
- Test harnesses → Pipeline graph: drives · Scripts are used to run and inspect the pipeline graph.
- Repo docs → Pipeline graph: documents · Repo guidance explains workflow and testing conventions.
- Pipeline entry → Pipeline graph: orchestrates · Main entrypoint hands off to graph-driven execution.
- Pipeline graph → Pipeline state: threads state · Pipeline stages share a structured run state.
- Pipeline graph → Agents: invokes · Workflow dispatches into specialized agent roles.
- Agents → Contracts: emit · Agents produce typed outputs consumed downstream.
- Contracts → IR: stabilize · Contracts and IR form the structured seam for execution.
- Agents → Prompts: uses · Agents are parameterized by prompt templates.
- Agents → Code safety: guards · Generated code is checked before execution.
- Agents → Audio path: optionally narrate · Narration and voiceover happen after scene generation.
- Pipeline graph → Delivery: finalizes · Pipeline packages rendered assets for delivery.
- Audio path → Delivery: muxes into · Audio is combined with rendered video for final output.
- Delivery → Run outputs: persists · Final bundles and transcripts are stored as run artifacts.
- Core → Graph runtime: supports · Core primitives underpin graph execution.
- Graph runtime → Envs: executes in · Graph runtime can target real or simulated environments.
- Core → Agents: underlies · Manimator’s orchestration builds on agent/runtime primitives.
- Scene decomposer → TTS registry: uses · Lecture scene generation can attach narration providers.
- Web app → Run outputs: serves artifacts · Web application can present or manage generated media outputs.
