Architecture & Principles
Monorepo structure, shared services, and the design decisions that let seven products share infrastructure without coupling.
Design Principles
Single ownership, shared reads
Each entity is written by one product but can be read by many. Project is owned by Blueprint but read by Relay, Retro, and Proof. This prevents write conflicts and makes the ownership model clear.
Nullable foreign keys as bridges
Cross-product references are always nullable. A Project can exist without a Decision (no Compass). A Document can exist without a Project. Each product works standalone.
JSONB for evolving schemas
Fields like scores, phase_adjustments, and preferences use JSONB. Each product can extend the shape without migrations. The shared layer stays stable while product-specific data evolves.
Conversation as universal intake
Every product uses the same Conversation entity with a different schema_target. One codebase fills any entity through guided AI interaction.
Retro → EstimationModel feedback loop
PhasePerformance data from completed projects feeds into EstimationModel coefficients. Over time, Blueprint's estimates self-correct using real project data.
Document as universal output
SOWs, proposals, case studies, and decision briefs are all the same entity with a type enum. One doc-gen pipeline, many templates.
Repository Structure
Technology Decisions
Monorepo Tool
Simpler config than Nx with sufficient caching. pnpm workspace protocol handles internal package linking cleanly. Vercel deploys natively with Turborepo.
Framework
Best Vercel integration, RSC for data-heavy pages, established patterns for API routes that serve as the backend layer. Each product is its own Next.js app in the monorepo.
Database
JSONB support critical for evolving schemas. Prisma gives type-safe queries and migration management. Row-level security by org_id for multi-tenancy. Can layer Supabase on top later for realtime.
AI Integration
Function calling for the conversational intake engine. Tool definitions per product — same orchestration code, different tool sets. Can abstract to multi-provider later if needed.
Auth
Fastest to production with org/team support built in. Handles the multi-tenancy pattern (user → org membership) natively. Easy migration to custom auth later if scale demands it.
Document Generation
Full control over template design. docxtemplater for Word/DOCX, pdf-lib for PDF manipulation. Templates live in each product's /templates directory. Shared doc-gen service renders them.
Deployment
Native Turborepo support means each product deploys independently from the monorepo. Preview deployments per PR. Edge functions for API routes. Zero-config from git push to production.
Styling
Shared design tokens via tailwind.config.js across all products. No runtime CSS-in-JS overhead. Consistent utility classes in the shared UI primitives package.
Shared Service Architecture
Multi-Tenancy Model
org_id is the partition key on every entity. All queries are scoped by org. Prisma middleware enforces this — no query can execute without an org context.
Row-level security in Postgres as a second layer. Even if the application layer has a bug, the database won't return cross-tenant data.
Clerk organizations map 1:1 to the Organization entity. User → Org membership with roles (owner, admin, member) handled by Clerk, mirrored in our User entity.