Architecture Overview
Dictumal is a root-level Next.js app that combines constitution authoring, AI drafting, deployment, and stream verification.
Tech Stack
| Layer | Technology |
|---|---|
| Framework | Next.js App Router |
| Language | TypeScript |
| UI | Tailwind CSS + shadcn/ui |
| Database | PostgreSQL via Prisma |
| Auth | NextAuth.js with Google OAuth |
| AI | OpenRouter-backed drafting and research |
| Deploy | DigitalOcean droplets + Vercel app hosting |
Directory Structure
repo root/
prisma/
schema.prisma
migrations/
src/
app/
api/
auth/
beta/
chat/
chat-sessions/
clauses/
constitutions/
cron/
deployments/
export/
groups/
internal/
proposals/
research/
stream/
templates/
versions/
constitution/
dashboard/
docs/
login/
components/
constitution/
docs/
ui/
lib/
auth.ts
db.ts
require-auth.ts
ai/
deploy/
export/
internal/
ir/
research/
templates/Key Design Decisions
Root-Level App
The app no longer lives in a nested dictumal/ directory. Run app, test, and ops commands from the repo root unless a doc says otherwise.
Server Components First
Pages fetch data on the server when possible. Client components are reserved for interactive UI like chat, deployment dialogs, and nav.
Shared Data Access
Prisma access flows through src/lib/db.ts. Auth configuration lives in src/lib/auth.ts, and protected route checks use src/lib/require-auth.ts.
Deployment Path
Deployment is a server-driven state machine:PROVISIONING -> CONFIGURING -> ACTIVE. Browser launch is handled by src/app/api/deployments/[id]/launch/route.ts, with stream-gateway handoff in src/app/api/stream/connect/route.tsand token helpers under src/lib/deploy/.