clifford chance
CC FirstDraft — System Architecture : Scaletech Solutions
Production | Azure · NestJS · Express · PostgreSQL · Docker Deployment | 8 Layers · 35+ Services
View:
Overview
Client
Backend
Agent
Data
AI & LLM
Legend:
Primary flow
Async / background
External integration
🗺️
Overview: Complete CC FirstDraft architecture — React SPA → Azure Entra (MSAL) → NestJS Middle Tier → Express Agent Gateway (BullMQ) → Agent Factory with 8 Specialized Agents → Vercel AI SDK → Azure AI Foundry. Click any tab to focus on a specific layer.
Data Layer
PostgreSQL
Cases & Documents
Users & Threads
Chat Messages
Generated Documents
Case Variables
⚡ PGVector
Embeddings & RAG
Semantic search
Document chunks
🔴 Redis
BullMQ Queues
OAuth Tokens
Session cache
Document Storage
Azure Blob Storage
Term Sheets
Facility Agreements
Executed PDFs
Notes & Artifacts
Agent Chat Stream
Streaming SSE Stream + Socket.IO
Agent Chat (SSE)
Real-time events
↔ Express API
Layer 1 · Users
⚖️
Lawyer
🏛️
File Partners
💼
Lead Associates
HTTPS / OAuth 2.0 (MSAL)
Layer 2 · Authentication
Azure Entra ID (MSAL)Auth
MSAL / OIDCJWT TokensMFA Enforcement RBAC PoliciesConditional AccessService Principal
JWT Auth Token
Layer 3 · Web App — CC FirstDraft/apps/frontend
React + Vite SPATypeScript
Dashboard Visualization Case Management Agent Chat — SSE Document Generation DOCX Download
3rd Party Libraries: docx (Markdown→DOCX) · docx-preview (DOCX in browser) · @markdoc/markdoc (Markdown parsing)
REST API (JWT Auth)
Layer 4 · Middle Tier — CC FirstDraft/apps/backend
🏗️NestJS APIMiddle Tier
Auth Module Case Module User Module Dashboard Module File Upload and Stream
Connects to: PostgreSQL (cases, users, documents) · Azure Blob Storage · Agent layer (Express)
Internal HTTP Dispatch
Layer 5 · Agent Gateway — CC FirstDraft/apps/agent
Express API + Socket.IOGateway
SSE Streaming Agent Controller Queue Jobs OAuth Tokens + Caching
Fetch PDFs · Document Status · Queue Processing · Store/Delete Chunks · Job Queue · ← SSE Stream (Agent Chat)
BullMQ Worker
Document Processing
Fetch PDFs
Queue Processing
Document Status
Store/Delete Chunks
Job Queue → Redis
→ PostgreSQL
→ PGVector
→ Azure Blob Storage
→ Azure AI Foundry
Agent Factory Init
Layer 6 · Agentic AI Layer
🤖Agent FactoryOrchestration
Specialized Agents
Fee Letter
DP Table Generator
Officers Certificate
Process Agent
Know-How GPT
Outlook Assistant
Email Composer
Document Summary
Agent Tools & Skills
Markdown Canvas
Fee Letter Tools
Search Skills
Pre and Post Processors
3rd Party Libs
pandoc (DOCX→Markdown)
pdf-lib (PDF manipulation)
diff (Version comparison)
Chunking + Embeddings / Tool Calls
Layer 7 · Orchestration & LLM Integration
Vercel Vercel AI SDKSDK
streamText() generateObject() Tool definitions useChat() hook Multi-step calls Stream resumption
path21 Microsoft Azure AI Foundry
OpenAI GPT-4/5
Legal reasoning
Document analysis
Function calling
128k context
text-embedding-3-large
Embeddings gen.
RAG pipeline
Semantic search
Vector storage
Layer 8 · External Integrations
Microsoft Outlook
OAuth and Graph API
Azure AD / MSAL
SSO · Token refresh
path21
Azure AI Foundry
GPT + Embeddings API
3rd Party — Frontend
📦 Frontend Libraries
docx
Markdown to DOCX
docx-preview
DOCX rendering in browser
@markdoc/markdoc
Markdown parsing
3rd Party — Agent
Agent Libraries
pandoc
DOCX to Markdown
pdf-lib
PDF manipulation
diff
Version comparison
External Integration
Microsoft Outlook
OAuth and Graph API
Email · Calendar · Tasks
→ Outlook Assistant
→ Email Composer Agents
Observability
📊 Monitoring
Azure App Insights
Sentry (error tracking)
Winston logging
BullMQ dashboard