How duy-nguyen-2006/timetable works
1. Overall shape
Tack Timetable is a hybrid Next.js + React + TypeScript application with a browser-side AI orchestration layer, a server API layer for LLM/provider access, a Python execution/validation layer, and an optional Electron desktop shell for IPC-based local execution.
2. User-facing application
The main UI lives in src/app/page.tsx and src/features/timetable/TimetableApp.tsx, with settings in SettingsModal.tsx. This is where users enter timetable constraints, trigger generation, inspect results, and export the final timetable to Excel.
3. Domain boundary: timetable feature module
Most timetable-specific logic is isolated under src/features/timetable/. This includes quick import, constants, UI helpers, and the AI pipeline support code. That folder is the core domain boundary for the product.
4. Client-side AI orchestrator
src/features/timetable/ai/local-agent.ts runs the main generation loop in the browser. It coordinates planner/coder/reviewer/repair steps, applies bounded retries, and enforces reject/retry behavior rather than trusting a single model output.
5. Prompt and model-processing pipeline
The AI subsystem is split into focused stages: planning, translation, code generation, repair, skeleton injection, JSON parsing, input compression, and budget guarding. The prompt assets in prompts/ map to those roles, so the architecture is intentionally multi-stage rather than a single prompt call.
6. Validation and deterministic checks
Before or around execution, the system uses deterministic validators, constraint parsing, AST/syntax checks, and CP-SAT round-trip tests. These layers act as a guardrail so the model’s output is checked against timetable constraints, not just accepted as text.
7. LLM/provider boundary
The browser does not call model providers directly. It goes through server routes such as POST /api/ai/chat and POST /api/provider/test, which form the secure boundary for provider credentials and chat proxying. This keeps secrets out of the client.
8. Python execution boundary
Generated Python is executed through src/features/timetable/ai/python-bridge.ts, which expects an IPC-capable host and now fails explicitly if that bridge is unavailable. This is the key boundary between the TypeScript/React world and the Python solver/executor world.
9. Python runtime and sandboxing
The repository contains a dedicated Python layer in python/ plus a standalone sandbox in sandbox/ with Docker and bubblewrap support. That suggests the system can run generated code in a restricted environment, separate from the UI, to reduce risk and isolate execution.
10. Desktop shell / local host integration
The electron/ folder plus the Windows release workflow indicate a desktop packaging path. In architecture terms, Electron likely provides the local host that enables the Python bridge and IPC-based execution flow described above.
11. Data flow end-to-end
User inputs constraints in the UI → the browser orchestrator compresses and structures them → the app calls the server chat proxy for LLM responses → generated Python is validated and executed through the Python bridge/sandbox → results are rendered back into the timetable table and exported.
12. Testing and release pipeline
There is broad test coverage across route handlers, AI stages, Python executor behavior, sandbox strictness, and integration scripts. GitHub Actions plus the Windows release workflow show this is built as a packaged application with CI checks around both the web app and execution stack.
Main entry points: local-agent.ts Local agent · TimetableApp.tsx Timetable app · ci.yml CI workflow · python-bridge.ts Python bridge
Components 19
Next.js app
Browser UI and route handlers
- Main page · Application entry point and top-level screen
src/app/page.tsx - API routes · Chat proxy, provider test, and Python helper endpoints
src/app/api
Timetable feature
Domain-specific timetable UI and orchestration
- Timetable app · Primary timetable workspace and generation flow
src/features/timetable/TimetableApp.tsx - Settings modal · User settings and generation options
src/features/timetable/SettingsModal.tsx - Domain utils · Quick import, constants, and shared timetable helpers
src/features/timetable
AI pipeline
Client-side generation, validation, and repair stages
- Local agent · Browser-side loop coordinating planner, coder, reviewer, and repair
src/features/timetable/ai/local-agent.ts - Planner · Structures constraints and task decomposition
src/features/timetable/ai/planner.ts - Translator · Converts structured intent into code-oriented form
src/features/timetable/ai/translator.ts - Coder · Generates Python solver code from prompts and context
src/features/timetable/ai/coder.ts - Repair · Retries and repairs invalid model output
src/features/timetable/ai/repair.ts - Validation · Deterministic validator, parser, budget guard, and round-trip checks
src/features/timetable/ai - Chat client · Browser client for server-backed model requests
src/features/timetable/ai/chat-client.ts
Execution layer
Python execution and sandbox boundary
- Python bridge · Runs generated Python through an IPC-capable host
src/features/timetable/ai/python-bridge.ts - Python core · Execution and validation runtime for generated timetable code
python - Sandbox · Docker and bubblewrap based isolation layer
sandbox
Desktop shell
Electron host and IPC bridge
- Electron host · Local desktop runtime that enables IPC execution
electron/main.mjs - Preload · Exposes host capabilities to the renderer
electron/preload.ts
Automation
Tests and release workflows
- CI workflow · Continuous integration for app and execution stack
.github/workflows/ci.yml - Release workflow · Windows packaging and release pipeline
.github/workflows/release-windows.yml
Connections 22
- Main page → Timetable app: renders · The main page mounts the timetable experience
- Timetable app → Settings modal: opens · Workspace uses the settings modal for configuration
- Timetable app → Domain utils: uses · Timetable UI depends on domain helpers and constants
- Timetable app → Local agent: starts · User actions trigger the browser-side generation loop
- Local agent → Planner: plans · Initial constraint structuring and decomposition
- Local agent → Translator: translates · Intermediate representation is prepared for code generation
- Local agent → Coder: generates · Coder produces executable solver code
- Local agent → Repair: repairs · Invalid or rejected outputs are retried and fixed
- Local agent → Validation: checks · Deterministic validation gates each stage
- Local agent → Chat client: calls · Browser agent obtains LLM responses through the client
- Chat client → API routes: proxies · Model requests go through server routes rather than directly to providers
- Validation → API routes: verifies · Route-level checks cover chat and Python helper endpoints
- Coder → Python bridge: executes via · Generated code is handed to the Python bridge
- Python bridge → Electron host: requires · Bridge expects an IPC-capable desktop host
- Electron host → Preload: exposes · Preload script provides renderer access to host APIs
- Python bridge → Python core: runs on · Bridge targets the Python solver/runtime layer
- Python core → Sandbox: isolates · Sandbox constrains execution of generated code
- CI workflow → API routes: tests · CI validates the API boundary and server helpers
- CI workflow → Validation: tests · CI covers AI validation and parser guards
- CI workflow → Python core: tests · CI exercises the Python executor and validator stack
- Release workflow → Electron host: packages · Windows release workflow builds the desktop app
- Release workflow → Sandbox: bundles · Release path includes sandbox execution support