How hssling/cbme-agent works
1. What this repository is
- This is a monorepo for a CBME (competency-based medical education) platform centered on curriculum planning, GMER-aligned scheduling, competency catalogues, analytics, and teaching-material generation.
- The runtime architecture is split across a shared Python core, a FastAPI backend, and multiple client surfaces.
2. Core domain engine: packages/cbme_core
- The shared Python package is the main business-logic boundary.
- It contains curriculum models and planners (curriculum.py, planner.py), schemas, literature/reference helpers, data templates, exporters, and AI-oriented materials support.
- Both the API service and the Streamlit app consume this package, so the curriculum/schedule logic is centralized rather than duplicated.
3. Primary backend: services/api
- The FastAPI service is the system’s integration layer and API gateway for clients.
- It exposes routers for auth, institutions, batches, catalogue, schedule, materials, analytics, admin, and health.
- This is the main boundary where external clients talk to the platform over REST.
4. Data layer and persistence
- The backend uses SQLAlchemy models plus Alembic migrations, which indicates a relational persistence layer behind the API.
- Config and dependency modules isolate database setup and request-scoped access.
- The migrations show the core persisted entities are institution/catalogue and the platform’s operational records around scheduling and access.
5. Asynchronous work / task processing
- services/api/app/task_queue.py and the materials endpoints imply some jobs are queued rather than handled synchronously.
- The client-side “materials” flow in the web app polls job status, so generation tasks are treated as background work with status retrieval.
6. Web application: apps/web
- The Next.js app is the institutional dashboard and operational UI.
- It uses an auth context, a protected-route hook, and a shared API client to communicate with the FastAPI backend.
- Pages cover login, dashboard, catalogue, coverage, materials, onboarding, and schedule workflows, so it is the main administrator/faculty front end.
7. Mobile application: apps/mobile
- The React Native app provides a separate faculty/student client surface.
- It uses Redux slices for auth and curriculum state plus navigation and screen modules for login, curriculum browsing, and dashboard-style views.
- Architecturally, this is a thin client over the same backend concepts, optimized for mobile access rather than direct computation.
8. Prototype / analytical UI: apps/streamlit
- The Streamlit app is a lightweight Python UI that consumes the shared core package directly.
- It is useful as a rapid demonstration layer for curriculum briefs, schedules, integration summaries, and teaching resources without going through the full web stack.
- This makes it a second consumer of the domain engine, but not the primary production UI.
9. Extension and auxiliary tools
- apps/vscode-codex is a VS Code extension, likely for authoring or assisting with curriculum content.
- The many top-level Python scripts generate reports, Excel workbooks, PDFs, proposals, assessments, and roadmaps; these are offline tooling rather than core runtime services.
- They feed the documentation/output pipeline rather than the request/response application path.
10. Documentation and regulatory inputs
- docs/nmc-gmer holds the GMER and related medical education reference PDFs.
- These documents are part of the architecture because they inform the scheduling and competency alignment logic in the core package and exported reports.
- The repo also contains large proposal/report artifacts, showing a strong documentation and compliance workflow around the software.
11. Build, CI/CD, and deployment boundaries
- GitHub Actions covers Python CI, security scanning, docs, and deployment.
- docker-compose.yml and the API Dockerfile indicate containerized deployment of the backend stack.
- The repo is organized so backend, web, mobile, and auxiliary tools can be developed and deployed independently.
12. End-to-end data flow
- Reference standards and imported catalogue data feed the shared core curriculum logic.
- The API persists institutional data and exposes schedule, analytics, and materials endpoints.
- Web/mobile clients call the API for operational workflows, while Streamlit can directly render core outputs for demos and internal analysis.
- Exporters in the core package and the standalone scripts turn computed plans into CSV, Excel, PDF, and document artifacts for institutional use.
Main entry points: main.py API app · routers Routers · cbme_core CBME core · workflows CI / deploy
Components 19
Shared core
Central CBME domain engine used by multiple runtimes.
- CBME core · Shared domain package for curriculum planning, schemas, literature, exporting, and AI materials support.
packages/cbme_core/cbme_core - Curriculum · Curriculum structures and competency-oriented data models.
packages/cbme_core/cbme_core/curriculum.py - Planner · Core planning logic that turns curriculum and reference inputs into schedules and plans.
packages/cbme_core/cbme_core/planner.py - Exporters · Transforms core plans into CSV, Excel, PDF, and document artifacts.
packages/cbme_core/cbme_core/exporters.py - Materials AI · AI-oriented teaching-material generation and related helpers.
packages/cbme_core/cbme_core/ai_materials.py
Backend API
FastAPI service, persistence, and background work.
- API app · Backend entrypoint and integration boundary for external clients.
services/api/app/main.py - Routers · REST surface for auth, institutions, batches, catalogue, schedule, materials, analytics, admin, and health.
services/api/app/routers - Models · SQLAlchemy persistence models for institutional and operational records.
services/api/app/models.py - DB layer · Database configuration and session wiring for request-scoped access.
services/api/app/database.py - Task queue · Background job processing used by asynchronous materials workflows.
services/api/app/task_queue.py
Client apps
Web, mobile, and prototype user surfaces.
- Web app · Institutional admin and faculty UI for operational workflows.
apps/web/src/pages - Auth UI · Auth context and protected-route handling for the web client.
apps/web/src/context/AuthContext.tsx - API client · Shared web client for talking to the backend API.
apps/web/src/lib/api.ts - Mobile app · Mobile faculty/student client for curriculum and dashboard views.
apps/mobile/src/App.tsx - Mobile state · Auth and curriculum slices that coordinate the mobile experience.
apps/mobile/src/store - Streamlit UI · Lightweight analytical and demo UI that consumes the shared core directly.
apps/streamlit/app.py
Docs & tooling
Offline generators, reference material, and repo-level delivery tooling.
- GMER docs · Medical education standards and curriculum PDFs used as domain inputs.
docs/nmc-gmer - Offline scripts · Standalone report, workbook, proposal, and assessment generation scripts.
- CI / deploy · GitHub Actions, Docker, and repo deployment boundaries.
.github/workflows
Connections 21
- GMER docs → CBME core: standards feed · Reference PDFs inform curriculum alignment and scheduling logic.
- Curriculum → Planner: input · Planner consumes curriculum structures and competencies.
- GMER docs → Planner: aligns · Planner uses GMER-aligned reference material.
- Planner → Exporters: produces · Planned schedules and plans are exported into deliverable formats.
- CBME core → Streamlit UI: direct consume · Streamlit renders the shared core outputs without the API layer.
- CBME core → API app: shared logic · Backend relies on the shared domain engine for core CBME behavior.
- API app → Routers: mounts · The FastAPI app wires the route surface.
- Routers → Models: persists · Routers operate on ORM-backed institutional and operational data.
- Models → DB layer: uses · Models are backed by the database/session configuration.
- Routers → Task queue: dispatches · Materials and similar workflows can offload work to background jobs.
- Routers → CBME core: calls · Schedule, catalogue, and materials endpoints reuse core planning logic.
- Web app → Auth UI: wraps · The web UI uses an auth context and protected routes.
- Web app → API client: calls · Pages use the shared client to talk to the backend.
- API client → API app: REST · Web requests target the FastAPI service.
- Mobile app → Mobile state: uses · Screens depend on Redux state for auth and curriculum.
- Mobile state → API app: syncs · Mobile state is populated through backend API calls.
- Offline scripts → Exporters: reuses · Offline generators reuse the same document and workbook outputs.
- Offline scripts → Models: operates on · Some scripts seed or inspect persisted platform data.
- CI / deploy → API app: builds · Deployment workflows package and ship the backend service.
- CI / deploy → Web app: builds · Frontend workflows validate and deploy the web client.
- CI / deploy → Mobile app: supports · Repository automation supports the mobile runtime as a separate surface.