Layer 1 · Users
Layer 2 · Authentication
Azure Entra ID (MSAL) Auth
MSAL / OIDC JWT Tokens MFA Enforcement
RBAC Policies Conditional Access Service Principal
Layer 3 · Web App — CC FirstDraft/apps/frontend
React + Vite SPA TypeScript
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)
Layer 4 · Middle Tier — CC FirstDraft/apps/backend
🏗️ NestJS API Middle 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)
Layer 5 · Agent Gateway — CC FirstDraft/apps/agent
Express API + Socket.IO Gateway
SSE Streaming
Agent Controller
Queue Jobs
OAuth Tokens + Caching
Fetch PDFs · Document Status · Queue Processing · Store/Delete Chunks · Job Queue · ← SSE Stream (Agent Chat)
Document Processing
Fetch PDFs
Queue Processing
Document Status
Store/Delete Chunks
Job Queue → Redis
→ PostgreSQL
→ PGVector
→ Azure Blob Storage
→ Azure AI Foundry
Layer 6 · Agentic AI Layer
🤖 Agent Factory Orchestration
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
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