Enterprise Context Intelligence Platform — retrieve, organize, filter, secure, and assemble organizational knowledge before it is provided to AI systems. Domain-agnostic: healthcare, finance, legal, education, manufacturing, software and government use the same architecture — the hospital assessment ships purely as seed data.
| Layer | Technology |
|---|---|
| Web | Next.js 15 (App Router) · TypeScript · Tailwind · shadcn/ui |
| Backend | NestJS (modular monolith) · TypeScript |
| Database | PostgreSQL · Prisma |
| Validation | Zod |
| Auth | JWT + Passport (web signs in via Clerk) |
| Cache / Queue | Redis · BullMQ (ready; memory binding by default) |
| API docs | Swagger (/docs) |
| Logging | Pino (structured) |
| Observability | Health checks, request/correlation ids, OpenTelemetry-ready |
| Testing | Vitest · Supertest |
apps/
web/ Next.js frontend (dashboard, marketing, Clerk auth)
api/ NestJS backend — see docs/backend-nestjs.md
packages/
types/ @contextgraph/types domain contracts, enums, primitives
shared/ @contextgraph/shared Result<T>, pagination, API envelopes, constants
config/ @contextgraph/config validated environment schema (Zod)
ui/ @contextgraph/ui design system (placeholder)
docs/ architecture, database, application, graph-engine, backend
Prerequisites: Node 20+, PostgreSQL (local or Supabase).
# 1. Dependencies (root workspace: packages + API)
npm install
# 2. Environment files (never commit real secrets)
cp apps/api/.env.example apps/api/.env # fill DATABASE_URL, JWT secrets
cp apps/web/.env.example apps/web/.env # fill Clerk keys (web)
# 3. Database (point DATABASE_URL at your local PostgreSQL or Supabase)
npm run db:migrate # apply migrations
npm run db:seed # idempotent seed (healthcare + finance tenants)
# 4. Run
npm run dev:api # NestJS on http://localhost:3001 (swagger at /docs)
npm run dev:web # Next.js on http://localhost:3000npm run build # packages → api → web
npm run typecheck # api + web
npm run lint # api + web
npm test # api + web unit tests
npm run test:e2e # api e2e (supertest)
npm run db:migrate # prisma migrate dev (api workspace)
npm run db:seed # prisma db seed- Versioned REST under
/api/v1(Swagger UI at/docs). - Uniform envelopes:
{ success, data, requestId, timestamp }/{ success: false, error: { code, message, details }, requestId, timestamp }. - Stable error codes (
ERR_*) from@contextgraph/shared. - Guards run in order: throttle → JWT → roles → permissions → tenant isolation.
- Everything is dependency-injected; repositories are the only Prisma boundary.
- Foundation — enterprise monorepo shell, error architecture, dashboard UI
- Data layer — Prisma schema, migrations, idempotent multi-tenant seed
- Application layer — service contracts, pipeline contracts, DI, events
- Graph engine — BFS traversal, cycle detection, metrics (69 unit tests)
- Auth — Clerk on the web, JWT + Passport contract on the API
- NestJS backend — modular monolith, 14 feature modules — this phase
- Rule engine + permission compiler (plug into the existing contracts)
- Server-side BFS binding to
IGraphService, BullMQ workers, Redis cache - React Flow visualization (web) consuming the Graph API
- Node versioning, event sourcing, realtime updates, multi-tenant hardening
docs/architecture.md— overall architecturedocs/database.md— schema, indexes, scalingdocs/application-architecture.md— application contractsdocs/graph-engine.md— traversal enginedocs/backend-nestjs.md— NestJS backend