# aaron-howard/training-certify architecture

> Architecture diagram of the GitHub repository aaron-howard/training-certify, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aaron-howard/training-certify
- Repository: https://github.com/aaron-howard/training-certify

## Overview

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: [`src/routes/api.certifications.ts`](https://github.com/aaron-howard/training-certify/blob/main/src/routes/api.certifications.ts) (API routes), [`src/router.tsx`](https://github.com/aaron-howard/training-certify/blob/main/src/router.tsx) (Router), [`src/db/schema.ts`](https://github.com/aaron-howard/training-certify/blob/main/src/db/schema.ts) (Schema), [`src/api/certifications.server.ts`](https://github.com/aaron-howard/training-certify/blob/main/src/api/certifications.server.ts) (Domain APIs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime app"]
  node_bootstrap["Bootstrap<br/>start/routing<br/>[entry-client.tsx]"]
  node_router["Router<br/>route wiring<br/>[router.tsx]"]
  node_shell["App shell<br/>ui shell<br/>[AppShell.tsx]"]
  node_catalog["Catalog<br/>feature route<br/>[catalog.tsx]"]
  node_cert_mgmt["Cert mgmt<br/>feature route"]
  node_team_mgmt["Team mgmt<br/>feature route"]
  node_compliance["Compliance<br/>feature route"]
  node_notifications["Notifications<br/>feature route<br/>[notifications.tsx]"]
  node_auth_routes["Auth pages<br/>route pages<br/>[sign-in.tsx]"]
  node_api_routes["API routes<br/>http endpoints"]
end

subgraph group_platform["Server platform"]
  node_api_domain["Domain APIs<br/>server modules"]
  node_api_helpers["API helpers<br/>request wrapper"]
  node_controls["Controls<br/>policy layer<br/>[auth.server.ts]"]
end

subgraph group_data["Data layer"]
  node_db_schema[("Schema<br/>[schema.ts]")]
  node_db_migrations["Migrations"]
  node_ingestion["Ingestion<br/>sync pipeline"]
  node_db_seed["Seed data<br/>bootstrap data<br/>[seed.ts]"]
end

subgraph group_ops["Operations"]
  node_ops_obs["Observability<br/>logging/monitoring<br/>[logging.server.ts]"]
  node_ops_health["Health ops<br/>ops routes<br/>[health.ts]"]
end

subgraph group_docs["Docs and plans"]
  node_docs_plan["Docs & plan<br/>docs/artifacts<br/>[openapi.yaml]"]
end

node_bootstrap -->|"boots"| node_router
node_router -->|"renders"| node_shell
node_router -->|"maps"| node_catalog
node_router -->|"maps"| node_cert_mgmt
node_router -->|"maps"| node_team_mgmt
node_router -->|"maps"| node_compliance
node_router -->|"maps"| node_notifications
node_router -->|"maps"| node_auth_routes
node_catalog -->|"calls"| node_api_routes
node_cert_mgmt -->|"calls"| node_api_routes
node_team_mgmt -->|"calls"| node_api_routes
node_compliance -->|"calls"| node_api_routes
node_notifications -->|"calls"| node_api_routes
node_api_routes -->|"wraps"| node_api_helpers
node_api_routes -->|"enforces"| node_controls
node_api_routes -->|"delegates"| node_api_domain
node_api_domain -->|"queries"| node_db_schema
node_api_domain -->|"guards"| node_controls
node_db_schema -->|"evolved by"| node_db_migrations
node_db_seed -->|"loads"| node_db_schema
node_ingestion -->|"feeds"| node_db_schema
node_ops_obs -->|"watches"| node_api_routes
node_ops_health -->|"mirrors"| node_api_routes
node_docs_plan -.->|"documents"| node_api_routes
node_docs_plan -.->|"documents"| node_router

click node_bootstrap "https://github.com/aaron-howard/training-certify/blob/main/src/entry-client.tsx"
click node_router "https://github.com/aaron-howard/training-certify/blob/main/src/router.tsx"
click node_shell "https://github.com/aaron-howard/training-certify/blob/main/src/components/shell/AppShell.tsx"
click node_catalog "https://github.com/aaron-howard/training-certify/blob/main/src/routes/catalog.tsx"
click node_cert_mgmt "https://github.com/aaron-howard/training-certify/blob/main/src/routes/certification-management.tsx"
click node_team_mgmt "https://github.com/aaron-howard/training-certify/blob/main/src/routes/team-management.tsx"
click node_compliance "https://github.com/aaron-howard/training-certify/blob/main/src/routes/compliance-audit.tsx"
click node_notifications "https://github.com/aaron-howard/training-certify/blob/main/src/routes/notifications.tsx"
click node_auth_routes "https://github.com/aaron-howard/training-certify/blob/main/src/routes/sign-in.tsx"
click node_api_routes "https://github.com/aaron-howard/training-certify/blob/main/src/routes/api.certifications.ts"
click node_api_domain "https://github.com/aaron-howard/training-certify/blob/main/src/api/certifications.server.ts"
click node_api_helpers "https://github.com/aaron-howard/training-certify/blob/main/src/lib/api-helpers.server.ts"
click node_controls "https://github.com/aaron-howard/training-certify/blob/main/src/lib/auth.server.ts"
click node_db_schema "https://github.com/aaron-howard/training-certify/blob/main/src/db/schema.ts"
click node_db_migrations "https://github.com/aaron-howard/training-certify/blob/main/src/db/migrations/0000_cuddly_hammerhead.sql"
click node_ingestion "https://github.com/aaron-howard/training-certify/blob/main/src/lib/ingestion.server.ts"
click node_db_seed "https://github.com/aaron-howard/training-certify/blob/main/src/db/seed.ts"
click node_ops_obs "https://github.com/aaron-howard/training-certify/blob/main/src/lib/logging.server.ts"
click node_ops_health "https://github.com/aaron-howard/training-certify/blob/main/src/routes/health.ts"
click node_docs_plan "https://github.com/aaron-howard/training-certify/blob/main/docs/api/openapi.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_bootstrap,node_router,node_shell,node_catalog,node_cert_mgmt,node_team_mgmt,node_compliance,node_notifications,node_auth_routes,node_api_routes toneBlue
class node_api_domain,node_api_helpers,node_controls toneAmber
class node_db_schema,node_db_migrations,node_ingestion,node_db_seed toneMint
class node_ops_obs,node_ops_health toneRose
class node_docs_plan toneIndigo
```

## Components

### Runtime app

TanStack Start app, routes, UI, and server/API execution path

- [Bootstrap](https://github.com/aaron-howard/training-certify/blob/main/src/entry-client.tsx): start/routing · Client/server entrypoints and TanStack route tree bootstrap · `src/entry-client.tsx`
- [Router](https://github.com/aaron-howard/training-certify/blob/main/src/router.tsx): route wiring · Route setup and generated route tree integration · `src/router.tsx`
- [App shell](https://github.com/aaron-howard/training-certify/blob/main/src/components/shell/AppShell.tsx): ui shell · Shared navigation, shell chrome, and page layout · `src/components/shell/AppShell.tsx`
- [Catalog](https://github.com/aaron-howard/training-certify/blob/main/src/routes/catalog.tsx): feature route · Certification catalog browsing and assignment workflows · `src/routes/catalog.tsx`
- [Cert mgmt](https://github.com/aaron-howard/training-certify/blob/main/src/routes/certification-management.tsx): feature route · Certification management screens and actions · `src/routes/certification-management.tsx`
- [Team mgmt](https://github.com/aaron-howard/training-certify/blob/main/src/routes/team-management.tsx): feature route · Team and workforce management screens · `src/routes/team-management.tsx`
- [Compliance](https://github.com/aaron-howard/training-certify/blob/main/src/routes/compliance-audit.tsx): feature route · Compliance and audit reporting screens · `src/routes/compliance-audit.tsx`
- [Notifications](https://github.com/aaron-howard/training-certify/blob/main/src/routes/notifications.tsx): feature route · Notifications and alerting screens · `src/routes/notifications.tsx`
- [Auth pages](https://github.com/aaron-howard/training-certify/blob/main/src/routes/sign-in.tsx): route pages · Sign-in, sign-up, and profile-facing routes · `src/routes/sign-in.tsx`
- [API routes](https://github.com/aaron-howard/training-certify/blob/main/src/routes/api.certifications.ts): http endpoints · 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](https://github.com/aaron-howard/training-certify/blob/main/src/api/certifications.server.ts): server modules · Server-only orchestration for catalog, teams, users, compliance, and notifications · `src/api/certifications.server.ts`
- [API helpers](https://github.com/aaron-howard/training-certify/blob/main/src/lib/api-helpers.server.ts): request wrapper · Standard read/mutation handlers, error wrapping, and response shaping · `src/lib/api-helpers.server.ts`
- [Controls](https://github.com/aaron-howard/training-certify/blob/main/src/lib/auth.server.ts): policy layer · 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](https://github.com/aaron-howard/training-certify/blob/main/src/db/schema.ts): drizzle schema · Canonical database tables and enums for users, teams, certifications, vendors, notifications, and logs · `src/db/schema.ts`
- [Migrations](https://github.com/aaron-howard/training-certify/blob/main/src/db/migrations/0000_cuddly_hammerhead.sql): db migrations · Versioned SQL migrations for schema evolution · `src/db/migrations/0000_cuddly_hammerhead.sql`
- [Ingestion](https://github.com/aaron-howard/training-certify/blob/main/src/lib/ingestion.server.ts): sync pipeline · Catalog fetch, sync, dedupe, and cleanup pipeline for vendor/exam data · `src/lib/ingestion.server.ts`
- [Seed data](https://github.com/aaron-howard/training-certify/blob/main/src/db/seed.ts): bootstrap data · Initial data loading for development and catalog setup · `src/db/seed.ts`

### Operations

Health, metrics, observability, and deployment support

- [Observability](https://github.com/aaron-howard/training-certify/blob/main/src/lib/logging.server.ts): logging/monitoring · Structured logging, monitoring hooks, and Sentry integration · `src/lib/logging.server.ts`
- [Health ops](https://github.com/aaron-howard/training-certify/blob/main/src/routes/health.ts): ops routes · Health, readiness, DB-health, and metrics endpoints · `src/routes/health.ts`

### Docs and plans

Generated docs and planning artifacts outside the runtime

- [Docs & plan](https://github.com/aaron-howard/training-certify/blob/main/docs/api/openapi.yaml): docs/artifacts · OpenAPI docs, generated API docs, and product planning artifacts · `docs/api/openapi.yaml`

## Connections

- 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
