ArchFlow is a full-stack, real-time collaborative workspace for system design β describe a system in plain English, let an AI agent draft it as a live architecture diagram, refine it together with your team, and export the final graph as a technical specification.
- Overview
- Tech Stack
- Key Features
- How the AI Pipeline Works
- Architecture Highlights
- Project Structure
- Getting Started
- Environment Variables
- Future Improvements
ArchFlow turns a blank canvas into a shared architecture whiteboard with an AI co-designer sitting inside it. Instead of dragging boxes and arrows one by one, a user can describe a system β "an event-driven order pipeline with a queue and three consumers" β and the AI agent writes real nodes and edges directly into a shared, live canvas that every collaborator sees update in real time.
Two AI-driven capabilities sit at the core of the app:
- Design Generation β turn a natural-language prompt (plus the current canvas state) into structured architecture nodes and edges, written live into the shared room
- Spec Generation β turn the finished canvas graph into a persisted Markdown technical specification, ready to review or download
Everything else β auth, project ownership, collaborator access, a curated starter-template library, and live multiplayer presence β exists to support that core loop: describe it, watch it get drawn, refine it together, export it.
Built with Next.js (App Router) and backed by Clerk (auth), Prisma + PostgreSQL (metadata), Liveblocks + React Flow (real-time canvas), Trigger.dev (durable AI background jobs), Vercel Blob (generated artifacts), and Google Gemini through the Vercel AI SDK for all generation.
| Layer | Technology | Purpose |
|---|---|---|
| Framework | Next.js 16 (App Router) | SSR, routing, API route handlers |
| Language | TypeScript | End-to-end type safety |
| Auth | Clerk | User identity, sign-in/sign-up, route protection |
| Database | Prisma + PostgreSQL | Project metadata, collaborators, spec records, task runs |
| Real-Time Canvas | Liveblocks + React Flow (@xyflow/react) |
Shared canvas state, live cursors, presence, node/edge sync |
| Background Jobs | Trigger.dev | Durable, long-running AI generation tasks |
| Artifact Storage | Vercel Blob | Canvas snapshots and generated Markdown specs |
| AI | Google Gemini (via Vercel AI SDK) | Architecture generation and spec generation |
| Styling | Tailwind CSS + shadcn/ui + Base UI | Utility-first styles + accessible component primitives |
| Deployment | Vercel | Hosting for the app and API routes |
- Clerk Authentication β Full sign-in/sign-up flow with protected routes
- Project Ownership β Every project belongs to a single owner, with additional collaborators invited by email
- Access-Controlled Rooms β Liveblocks room tokens are only issued after verifying project membership; non-members hit an access-denied state
- Project Sidebar & Share Dialog β Manage collaborators and project settings without leaving the workspace
- Shared Canvas β Built on Liveblocks + React Flow; every node, edge, and edit syncs live across all connected collaborators
- Live Presence β Real-time cursors and collaborator avatars show who's editing and where
- Rich Node Editing β Shape panel, color toolbar, inline label editing, and configurable node/edge behavior
- Canvas Autosave β Canvas state is snapshotted and persisted automatically as it changes
- Starter Template Library β Prebuilt system-design templates (monolith, microservices, event-driven, CI/CD pipeline, serverless, and more) that can be imported into the canvas at any point, following the same node/edge schema as user-created content
- Prompt-to-Diagram β Describe a system in plain English; the AI agent generates structured nodes and edges and writes them directly into the shared room
- Context-Aware β Generation takes the current canvas state and project context into account, so the AI extends existing designs rather than overwriting them
- AI Sidebar β A dedicated chat-style panel for prompting the design agent and reviewing its running feed of actions
- Durable Execution β Generation runs as a background task via Trigger.dev, so it survives page navigation and doesn't block API requests
- Graph-to-Markdown β Converts the current canvas graph and chat history into a structured Markdown technical specification
- Persisted Artifacts β Specs are saved to Vercel Blob and linked to the project via a database record, with full history per project
- Review & Download β Users can view generated specs in-app or download them directly
User enters a prompt in the AI sidebar
β
βΌ
POST /api/ai/design β ownership/auth check β Trigger.dev task queued
β
βΌ
design-agent.ts (Trigger.dev background task)
β
ββ Reads current canvas state (nodes, edges) + project context
ββ Calls Google Gemini via the Vercel AI SDK
ββ Produces structured node/edge updates
β
βΌ
Updates written directly into the shared Liveblocks room
β
βΌ
All connected collaborators see the diagram update live β no refresh
βββββββββββββββββββββββββββββββββββββββββββββ
User triggers "Generate Spec"
β
βΌ
POST /api/projects/[projectId]/specs β Trigger.dev task queued
β
βΌ
generate-spec.ts (Trigger.dev background task)
β
ββ Builds context from canvas nodes, edges, and AI chat history
ββ Calls Google Gemini to draft a Markdown technical spec
ββ Uploads the result to Vercel Blob (specs/{projectId}/{specId}.md)
β
βΌ
ProjectSpec record saved to PostgreSQL, linked to the project
β
βΌ
User views or downloads the spec from the workspace
All AI generation runs as Trigger.dev background tasks, not inline in request handlers β API routes only validate, authorize, and queue work, keeping long-running model calls off the request/response cycle.
- Request Handlers vs. Background Tasks β
app/apihandles auth, validation, and task triggering only; all long-running AI work lives intrigger/, kept off the request/response cycle - Two-Layer Storage Model β Relational metadata (projects, collaborators, spec records, task runs) lives in PostgreSQL via Prisma; large generated artifacts (canvas snapshots, Markdown specs) live in Vercel Blob, referenced from the database by URL
- Ownership Enforced at Every Mutation β Every project has a single owner, with collaborator access checked before any Liveblocks room token is issued or any resource is mutated
- Schema-Consistent Templates β Starter system-design templates are static canvas snapshots that follow the exact same node/edge schema as user-created content, so they can be imported without a separate database record
- Protected Foundation Components β
components/ui/*(shadcn/ui primitives) remain untouched defaults; feature and layout logic lives in app-level components instead
ArchFlow/
β
βββ app/
β βββ api/
β β βββ ai/
β β β βββ design/route.ts + token/route.ts # Trigger AI design generation
β β β βββ spec/route.ts + token/route.ts # Trigger AI spec generation
β β βββ projects/
β β β βββ route.ts # Project list/create
β β β βββ [projectId]/
β β β βββ route.ts # Project detail/update/delete
β β β βββ canvas/route.ts # Canvas snapshot persistence
β β β βββ collaborators/route.ts # Collaborator management
β β β βββ specs/ # Spec list, detail, download
β β βββ liveblocks-auth/route.ts # Room token issuance
β β
β βββ editor/
β β βββ page.tsx # Project home
β β βββ [roomId]/page.tsx # Collaborative canvas workspace
β β
β βββ sign-in/[[...sign-in]]/page.tsx
β βββ sign-up/[[...sign-up]]/page.tsx
β βββ globals.css
β βββ layout.tsx
β
βββ components/
β βββ editor/
β β βββ canvas/
β β β βββ canvas-editor.tsx # Canvas root
β β β βββ canvas-room.tsx # Liveblocks room provider
β β β βββ canvas-node.tsx / canvas-edge.tsx
β β β βββ canvas-controls.tsx / shape-panel.tsx
β β β βββ presence-cursors.tsx / collaborator-avatars.tsx
β β βββ ai-sidebar.tsx # AI prompt + chat feed
β β βββ editor-workspace-client.tsx / editor-navbar.tsx
β β βββ editor-home-client.tsx / project-sidebar.tsx
β β βββ project-dialogs.tsx / project-share-dialog.tsx
β β βββ starter-templates.ts / starter-templates-modal.tsx
β β βββ access-denied.tsx
β βββ ui/ # shadcn/ui primitives
β
βββ trigger/
β βββ design-agent.ts # AI architecture generation task
β βββ generate-spec.ts # AI Markdown spec generation task
β
βββ lib/
β βββ prisma.ts # Prisma client
β βββ liveblocks.ts # Liveblocks server client
β βββ projects.ts / project-access.ts / project-collaborators.ts
β βββ utils.ts
β
βββ prisma/
β βββ schema.prisma
β βββ models/project.prisma # Project, ProjectSpec, ProjectCollaborator, TaskRun
β βββ migrations/
β
βββ hooks/
β βββ use-canvas-autosave.ts
β βββ use-project-actions.ts / use-project-dialogs.ts / use-project-share.ts
β βββ useKeyboardShortcuts.ts
β
βββ types/
β βββ canvas.ts
β βββ tasks.ts
β
βββ liveblocks.config.ts
βββ trigger.config.ts
βββ prisma.config.ts
- Node.js v18+
- Git
- A Clerk account (free tier)
- A PostgreSQL database (or run
npx create-dbfor a free hosted instance) - A Liveblocks account
- A Trigger.dev account
- A Vercel Blob store
- A Google AI Studio Gemini API key
git clone https://github.com/<your-username>/ArchFlow.git
cd ArchFlownpm installpostinstall runs prisma generate automatically.
Create .env in the project root (see Environment Variables below).
npx prisma migrate deploynpm run devOpen http://localhost:3000.
To run AI background tasks locally, also start the Trigger.dev dev server:
npx trigger.dev@latest dev| Variable | Description |
|---|---|
DATABASE_URL |
PostgreSQL connection string |
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY |
Clerk publishable key |
CLERK_SECRET_KEY |
Clerk secret key |
LIVEBLOCKS_SECRET_KEY |
Liveblocks server secret key |
TRIGGER_SECRET_KEY |
Trigger.dev project secret key |
BLOB_READ_WRITE_TOKEN |
Vercel Blob read/write token |
GOOGLE_GENERATIVE_AI_API_KEY |
Gemini API key for AI generation |
Exact variable names may differ slightly by provider version β check
lib/prisma.ts,lib/liveblocks.ts, and thetrigger/tasks for the values actually read at runtime if you're wiring up a fresh environment.
- Versioned spec history with diffing between generations
- Role-based collaborator permissions (view-only vs. edit)
- Richer AI-sidebar chat feed with inline diff previews before writing to canvas
- Migrating starter templates to database-backed, user-editable template library
- Export formats beyond Markdown (PDF, diagrams-as-code)