How aaron-howard/training-certify works
1. System shape
Training Certify is a full-stack TanStack Start application: one codebase contains the browser UI, server-rendered routes, API endpoints, and server-only utilities. The runtime boundary is the TanStack Start route layer, which handles both page navigation and JSON/API requests.
2. Primary user-facing modules
The app is organized around certification operations:
- certification management
- certification catalog browsing
- team/workforce management
- compliance/audit reporting
- notifications and alerting
- admin/user management
These correspond to route modules in src/routes and reusable UI in src/components.
3. Client entry and routing
src/entry-client.tsx, src/entry-server.tsx, src/router.tsx, and the generated src/routeTree.gen.ts form the TanStack Start bootstrap. File-based routes under src/routes map to screens like catalog, certification management, compliance audit, team management, notifications, sign-in/sign-up, health, metrics, and API docs.
4. Server/API boundary
API behavior is split into route handlers and server modules:
- src/routes/api.*.ts exposes HTTP endpoints
- src/api/*.server.ts holds domain operations and data access orchestration
- src/lib/api-helpers.server.ts standardizes read/mutation handlers, error wrapping, and response shaping
This keeps request handling thin and pushes business logic into server-only modules.
5. Domain data flow
Most requests follow the same path: browser or SSR route → auth/CSRF/rate-limit checks → domain handler in src/api → Drizzle database access → typed response back to UI.
Mutations are protected by server-side validation, CSRF checks, and role checks before they reach PostgreSQL.
6. Persistence layer
src/db/schema.ts defines the canonical data model, with Drizzle migrations in src/db/migrations. The database contains the core entities behind the product: users, teams, user-team links, certifications, user certifications, team requirements, vendors, notifications, audit logs, and rate-limit logs. Seed data lives in src/db/seed.ts, and there are scripts for catalog/vendor synchronization and cleanup.
7. Cross-cutting server controls
src/lib contains the enforcement and platform concerns that sit between routes and the database:
- authentication and role authorization via Clerk
- CSRF token generation/validation
- rate limiting
- security headers and HTTPS enforcement
- env validation
- graceful shutdown
- caching
- pagination
- error classes and validation schemas
These are central to the architecture because they wrap nearly every state-changing or sensitive endpoint.
8. Observability and operational support
The app includes structured logging, monitoring hooks, and Sentry integration in src/lib/logging.*, src/lib/monitoring.server.ts, and src/lib/sentry.*. There are dedicated health, readiness, metrics, and DB-health routes, which indicates the service is designed to be operated as a production backend, not just a static UI.
9. Catalog ingestion and sync
The catalog is not purely manual; src/lib/ingestion.server.ts and scripts under scripts/ support fetching vendor/exam data, syncing catalog content, deduping vendors, and removing retired items. This creates a separate ingestion pipeline feeding the certification catalog data model.
10. Generated docs and contract surface
The repo contains generated API documentation under docs/api-jsdoc plus an OpenAPI spec in docs/api/openapi.yaml. That suggests the API is treated as a documented contract, with route and server modules reflected in public docs.
11. Testing and quality gates
Unit and API tests live under src/**/__tests__, while Playwright E2E coverage is under e2e/. GitHub Actions workflows cover CI, deployment, and dependency hygiene. In an architecture diagram, these belong as supporting quality/ops systems around the main app, not inside the runtime path.
12. Non-runtime planning artifacts
The product/ and product-plan/ trees are design/specification inputs: they describe the intended domain model, section breakdowns, UI shell, and design tokens. They are useful as source-of-truth artifacts for the product and UI architecture, but they are not part of the runtime application.
Main entry points: api.certifications.ts API routes · router.tsx Router · schema.ts Schema · certifications.server.ts Domain APIs
Components 20
Runtime app
TanStack Start app, routes, UI, and server/API execution path
- Bootstrap · Client/server entrypoints and TanStack route tree bootstrap
src/entry-client.tsx - Router · Route setup and generated route tree integration
src/router.tsx - App shell · Shared navigation, shell chrome, and page layout
src/components/shell/AppShell.tsx - Catalog · Certification catalog browsing and assignment workflows
src/routes/catalog.tsx - Cert mgmt · Certification management screens and actions
src/routes/certification-management.tsx - Team mgmt · Team and workforce management screens
src/routes/team-management.tsx - Compliance · Compliance and audit reporting screens
src/routes/compliance-audit.tsx - Notifications · Notifications and alerting screens
src/routes/notifications.tsx - Auth pages · Sign-in, sign-up, and profile-facing routes
src/routes/sign-in.tsx - API routes · HTTP route handlers for domain operations and JSON responses
src/routes/api.certifications.ts
Server platform
Cross-cutting auth, security, logging, validation, and request helpers
- Domain APIs · Server-only orchestration for catalog, teams, users, compliance, and notifications
src/api/certifications.server.ts - API helpers · Standard read/mutation handlers, error wrapping, and response shaping
src/lib/api-helpers.server.ts - Controls · Auth, CSRF, rate limiting, roles, validation, and security headers
src/lib/auth.server.ts
Data layer
Schema, migrations, seed data, and ingestion/sync pipeline
- Schema · Canonical database tables and enums for users, teams, certifications, vendors, notifications, and logs
src/db/schema.ts - Migrations · Versioned SQL migrations for schema evolution
src/db/migrations/0000_cuddly_hammerhead.sql - Ingestion · Catalog fetch, sync, dedupe, and cleanup pipeline for vendor/exam data
src/lib/ingestion.server.ts - Seed data · Initial data loading for development and catalog setup
src/db/seed.ts
Operations
Health, metrics, observability, and deployment support
- Observability · Structured logging, monitoring hooks, and Sentry integration
src/lib/logging.server.ts - Health ops · Health, readiness, DB-health, and metrics endpoints
src/routes/health.ts
Docs and plans
Generated docs and planning artifacts outside the runtime
- Docs & plan · OpenAPI docs, generated API docs, and product planning artifacts
docs/api/openapi.yaml
Connections 25
- Bootstrap → Router: boots · Client/server entrypoints initialize the TanStack routing layer
- Router → App shell: renders · The root route mounts the shared application shell
- Router → Catalog: maps · File-based routes expose the catalog screen
- Router → Cert mgmt: maps · File-based routes expose certification management
- Router → Team mgmt: maps · File-based routes expose team management
- Router → Compliance: maps · File-based routes expose compliance/audit reporting
- Router → Notifications: maps · File-based routes expose notifications
- Router → Auth pages: maps · File-based routes expose auth and profile pages
- Catalog → API routes: calls · Catalog UI issues JSON/API requests through route handlers
- Cert mgmt → API routes: calls · Certification management uses route-backed API actions
- Team mgmt → API routes: calls · Team management uses route-backed API actions
- Compliance → API routes: calls · Compliance screens read from route-backed API endpoints
- Notifications → API routes: calls · Notification screens read and mutate through route endpoints
- API routes → API helpers: wraps · Route handlers use standardized read/mutation helpers
- API routes → Controls: enforces · Endpoints apply auth, CSRF, rate-limit, and role checks
- API routes → Domain APIs: delegates · Thin route handlers delegate business logic to server modules
- Domain APIs → Schema: queries · Domain modules read and mutate the Drizzle model
- Domain APIs → Controls: guards · Server modules rely on shared authorization and validation controls
- Schema → Migrations: evolved by · Migrations materialize the canonical schema over time
- Seed data → Schema: loads · Seed data populates the schema for local and demo setups
- Ingestion → Schema: feeds · Sync pipeline updates catalog/vendor data in the database
- Observability → API routes: watches · Logging and monitoring instrument request handling
- Health ops → API routes: mirrors · Operational routes expose service status alongside the API surface
- Docs & plan → API routes: documents · Generated API docs reflect endpoint contracts
- Docs & plan → Router: documents · Docs also describe route modules and app structure