The Problem
Large codebases that mix a web UI, service layer, and analysis engine quickly accumulate hidden architectural debt: circular imports, “god” modules, and duplicated scaffolding. Those issues make small changes ripple across many files, increase build times, and raise the risk of runtime failures that ordinary linters miss.
What This Does
truecourse ships three self‑contained projects:
- apps/server – a TypeScript/Node API (see
apps/server/src/index.ts) that exposes analysis results, runs LLM providers, and persists data via Prisma. - apps/web – a React UI built with Vite (
apps/web/vite.config.ts) that visualises dependency graphs, code violations, and database ER diagrams. - tools/cli – a command‑line front‑end for automation (e.g.
tools/cli/src/commands/service/platform.ts).
Shared utilities live in packages/ (e.g. packages/analyzer, packages/shared). The Docker compose file (docker-compose.yml) wires the API, UI, and a PostgreSQL instance together, so the whole platform can be started with a single container orchestrator command.
How It Is Wired
Execution begins in apps/server/src/index.ts (the main entry point). It creates the Express app, mounts routes (apps/server/src/routes/*.ts), and starts the HTTP server.
- Routes → Services – each route handler delegates to a service module (e.g.
apps/server/src/services/analysis-pipeline.service.ts). - Services → Analyzer – the pipeline calls
packages/analyzer/src/index(33 outgoing imports, instability 1) to run the static‑analysis rules. - LLM Provider –
apps/server/src/services/llm/provider.tssupplies the model used by the analyzer; it is also part of a reported import cycle withtools/cli/src/commands/service/platform.tsandapps/server/src/services/llm/prompts.ts. - Database –
apps/server/src/config/database.ts(imported by 18 modules) creates a Prisma client used by many services (apps/server/src/services/*.service.ts). - Web UI –
apps/web/src/App.tsxbootstraps the React app; API calls go throughapps/web/src/lib/api.ts(fetchApi,getRepos, etc.), a hub called from nine other files.
The internal call graph shows a few high‑blast‑radius functions: cn (36 callers), fetchApi (33 callers), and eq (23 callers). The most connected module, packages/analyzer/src/index, imports 33 other internal modules but is not itself imported, indicating a one‑way “utility” layer that can become a bottleneck for change.
Circular dependencies (nine members) involve the LLM provider stack, increasing build‑time fragility. Oversized files (>800 LOC) such as apps/server/src/services/graph.service.ts and apps/server/src/routes/analysis.ts concentrate many responsibilities, making local edits risky.
How To Use It
# 1. Clone the repo
git clone https://github.com/moses-y/truecourse
cd truecourse
# 2. Install Node dependencies (pnpm is used in CI)
pnpm install # falls back to npm if pnpm not available
# 3. Create a runtime env file from the example
cp .env.example .env # edit .env with your DB credentials, AI keys, etc.
# 4. Start the full stack (API, UI, Postgres) via Docker
docker compose up --build # runs apps/server, apps/web, and the DB
# 5. API is reachable at http://localhost:3000
# UI at http://localhost:5173
If you prefer a local Node run, build the server with pnpm run build (defined in apps/server/package.json) and start it via node apps/server/dist/index.js after setting .env.
The CLI can be invoked directly:
pnpm exec truecourse analyze <path-to-repo>
(Exact command name is defined in tools/cli/package.json.)
Real‑World Use
A CI pipeline can run truecourse as a pre‑merge gate: the CLI analyses the PR’s changed files, emits JSON‑encoded violations, and the pipeline aborts on any high severity finding. The same analysis engine powers the UI, letting developers explore the dependency graph and drill into offending code directly from the browser.
Code Health & Issues
- HIGH – Pin GitHub Action versions to commit SHAs (
.github/workflows/*). - HIGH – Replace
cors()wildcard with an explicit allow list (apps/server/src/index.ts). - MEDIUM – Declare least‑privilege
GITHUB_TOKENpermissions (.github/workflows/test.yml). - MEDIUM – Enable Dependabot / Renovate for automated updates.
- MEDIUM – Add a dependency‑vulnerability scan step in CI.
- MEDIUM – Move large binary assets (
assets/demo.gif,demo.mp4) to Git LFS or external storage. - MEDIUM – Set
persist-credentials: falseon checkout (.github/workflows/publish.yml). - LOW – Add
timeout-minutesto workflow jobs. - LOW – Provide repository convention files (
.editorconfig,.gitattributes, formatter config).
Measured static‑analysis findings (deterministic):
- Import cycles – 9 modules (e.g.,
provider.ts,platform.ts,prompts.ts). - Oversized files – 8 files > 800 LOC, high change impact.
- High branching density – 26 files with > 70 branch points (e.g.,
dependency-graph.ts). - Hub modules –
database.ts,schema.ts,language-config.tseach imported by 18 modules. - Duplicated code blocks – 692 repeated 6‑line fragments across 89 files.
- Deep nesting – 9 files with indentation depth 8 (e.g.,
SchemaPanel.tsx). - Empty catch blocks – found in test files.
- TODO/FIXME markers – 8 occurrences in analyzer rules.
No critical or blocker findings were detected beyond the above.
The Bottom Line
truecourse delivers a functional analysis engine, a usable React UI, and a CLI that together expose architectural flaws most linters miss. The codebase is modular but suffers from a few large, highly coupled modules and several import cycles that raise maintenance risk. With the listed health‑audit fixes and a refactor of the oversized services, the platform is ready for production use, especially in environments that need automated architecture validation in CI pipelines.