How hritxxxk/koda works
1. What this repository is
- Koda is a local practice tool for DSA and SQL problems.
- It is not a server-based application; the architecture is centered on a CLI/TUI workflow running on the user’s machine.
2. Primary entrypoint
- The user starts the app with koda start or python -m src.ai_dsa.cli start.
- src/ai_dsa/cli.py is the main command surface and likely coordinates startup, mode selection, and the handoff into the interactive UI.
3. Interactive experience layer
- src/ai_dsa/tui.py is the user-facing interface for solving problems.
- This layer is the boundary where the user submits answers, views prompts, receives feedback, and navigates between problem states.
4. Problem content as local data
- The repository stores practice content in data/.
- data/problems/*.toml contains DSA problem definitions like two-sum and merge-sort.
- data/sql/*.toml contains SQL exercises like find-customers-with-recent-orders.
- These files are the app’s content source, so problem delivery is file-based rather than remote API-driven.
5. Core domain model
- src/ai_dsa/models.py likely defines the problem, solution, and session entities shared across the app.
- This is the main internal contract between the content loader, UI, sandbox, recommendation logic, and persistence/telemetry.
6. Encoding and parsing boundary
- src/ai_dsa/codec.py likely handles conversion between TOML/content formats and Python objects.
- This module is the ingestion boundary for the problem files under data/, and probably also handles any serialization of notes or session artifacts.
7. Execution and validation subsystems
- src/ai_dsa/sandbox.py and src/ai_dsa/sql_sandbox.py separate execution for code-style DSA answers and SQL answers.
- This split is important architecturally: DSA solutions and SQL queries have different runtime rules, inputs, and validation paths.
- These sandboxes are the place where user-submitted work is safely tested against expected behavior.
8. Quality-checking and feedback
- src/ai_dsa/linter.py and src/ai_dsa/profiler.py suggest static and performance-oriented feedback.
- The linter likely checks style or structural issues, while the profiler focuses on runtime characteristics or complexity signals.
- Together they provide feedback beyond simple pass/fail validation.
9. AI integration boundary
- src/ai_dsa/providers.py abstracts external AI provider access.
- The README says the default provider is Ollama and can be configured via .env, so the app is designed to work with multiple AI backends.
- src/ai_dsa/recommender.py likely uses the provider abstraction to generate hints, recommendations, or next-step guidance.
10. Persistence and user memory
- src/ai_dsa/database.py, src/ai_dsa/notes.py, and src/ai_dsa/telemetry.py form the app’s state and history layer.
- database.py suggests local storage for sessions, progress, or metadata.
- notes.py likely stores user annotations tied to problems.
- telemetry.py likely records usage or outcome events for diagnostics or product insight.
11. Typical data flow
- A user starts the CLI.
- The app loads problem definitions from data/ through the codec/models layer.
- The UI presents a selected exercise.
- The user submits a solution or query.
- The sandbox validates it; the linter/profiler may enrich feedback.
- The recommender may consult an AI provider for hints.
- Notes, results, and telemetry are persisted locally.
12. Operational shape
- This is a single-package Python application with editable installation via pyproject.toml and requirements.txt.
- There is no evidence of separate backend/frontend services, queues, or remote databases in the repository tree.
- The main architectural boundaries are therefore: content files, interactive UI, execution sandboxes, AI provider adapter, and local persistence/telemetry.
Main entry points: tui.py TUI · codec.py Codec · sandbox.py DSA sandbox · recommender.py Recommender
Components 15
CLI + UI
User entrypoint and interactive problem-solving interface.
Local content
Problem definitions and format conversion boundary.
Validation
Execution, linting, profiling, and feedback generation.
- DSA sandbox · Runs and validates code-style submissions against expected behavior.
src/ai_dsa/sandbox.py - SQL sandbox · Executes and checks SQL submissions separately from code problems.
src/ai_dsa/sql_sandbox.py - Linter · Provides structural or style-oriented feedback on submissions.
src/ai_dsa/linter.py - Profiler · Adds runtime or complexity-oriented feedback.
src/ai_dsa/profiler.py
AI guidance
Provider abstraction and recommendation logic.
- Providers · Abstracts external AI backends such as Ollama.
src/ai_dsa/providers.py - Recommender · Generates hints, guidance, or next-step suggestions.
src/ai_dsa/recommender.py
Connections 19
- CLI → TUI: launches · CLI starts the interactive experience.
- CLI → Codec: loads content · Startup uses the codec boundary to ingest local practice files.
- TUI → Models: uses · UI renders and updates shared domain entities.
- Codec → Models: produces · Parsed content becomes domain objects.
- Codec → DSA data: reads · DSA problems are sourced from local TOML files.
- Codec → SQL data: reads · SQL exercises are sourced from local TOML files.
- TUI → DSA sandbox: validates · Interactive DSA submissions are executed and checked.
- TUI → SQL sandbox: validates · Interactive SQL submissions use the SQL execution path.
- DSA sandbox → Linter: enriches · Code validation can include lint-style feedback.
- DSA sandbox → Profiler: enriches · Code validation can include performance feedback.
- SQL sandbox → Linter: enriches · SQL validation can include feedback checks.
- Recommender → Providers: queries · Recommendations are generated through provider abstraction.
- TUI → Recommender: requests help · UI can ask for hints or guidance during solving.
- Recommender → Models: consults · Recommendations are grounded in the current problem/session model.
- TUI → Database: persists · UI stores progress and session state locally.
- Notes → Database: stores · Notes are saved in the local persistence layer.
- Telemetry → Database: stores · Telemetry events are recorded locally.
- TUI → Notes: uses · Users can attach notes while solving.
- TUI → Telemetry: emits · Interactive actions produce telemetry events.