How willchen96/mike works
Purpose and Entry Points
Mike is a legal-AI platform for document review, drafting, research, project workspaces, tabular reviews, and reusable workflows. The browser application is a Next.js App Router frontend rooted at frontend/src/app/layout.tsx and frontend/src/app/page.tsx. The API is an Express service bootstrapped by backend/src/index.ts and composed in backend/src/app.ts.
Client Application and Workspace Domains
The frontend organizes the product around assistant chats, projects, document library, tabular reviews, workflows, and account settings. Route pages establish workspace boundaries; feature components contain the interactive views.
• Assistant/chat: frontend/src/app/(pages)/assistant/chat/[id]/page.tsx, frontend/src/app/components/assistant/ChatView.tsx
• Projects: frontend/src/app/(pages)/projects/[id]/page.tsx, frontend/src/app/components/projects/ProjectWorkspace.tsx
• Tabular review: frontend/src/app/(pages)/tabular-reviews/[id]/page.tsx, frontend/src/app/components/tabular/TabularReviewView.tsx
• Workflows: frontend/src/app/(pages)/workflows/assistant/[id]/page.tsx, frontend/src/app/components/workflows/WorkflowDetailPage.tsx
Authentication and browser-side Supabase state cross the frontend/backend boundary through frontend/src/app/contexts/AuthContext.tsx, frontend/src/app/lib/supabase.ts, and API calls in frontend/src/app/lib/mikeApi.ts.
HTTP API, Identity, and Authorization
Express routes expose domain APIs for chats, project chats, documents, library, tabular reviews, workflows, models, user settings, downloads, and case law. Authentication middleware validates Supabase identity, while backend access logic should enforce ownership/sharing rules before data or storage operations.
• API boundaries: backend/src/routes/chat.ts, backend/src/routes/projects.ts, backend/src/routes/documents.ts
• Auth/access: backend/src/middleware/auth.ts, backend/src/lib/access.ts
• Supabase service access: backend/src/lib/supabase.ts
AI Assistant Execution
Chat requests are validated, assembled with document/project/workflow context, and streamed back to the client. The frontend consumes server-sent events through frontend/src/app/hooks/useAssistantChat.ts; assistant rendering displays streamed content, citations, and edit/tool events in frontend/src/app/components/assistant/AssistantMessage.tsx.
The backend model layer abstracts Anthropic, Gemini, OpenAI, and Ollama. Chat tool dispatch enables document operations and CourtListener research; citations are verified and persisted as chat-message metadata.
• Orchestration: backend/src/lib/chat/index.ts, backend/src/lib/chat/streaming.ts, backend/src/lib/chat/contextBuilders.ts
• Providers: backend/src/lib/llm/index.ts, backend/src/lib/llm/openai.ts, backend/src/lib/llm/ollama.ts
• Tools/research: backend/src/lib/chat/tools/toolDispatcher.ts, backend/src/lib/chat/tools/courtlistenerTools.ts, backend/src/lib/courtlistener.ts
Documents, Versions, and Exports
Documents are uploaded to S3-compatible storage and represented as versioned database records. Backend processing handles type detection, extraction/conversion, DOCX tracked changes, spreadsheets, and controlled downloads. The client offers document tables and specialized PDF, DOCX, and spreadsheet views.
• API/storage/version boundary: backend/src/routes/documents.ts, backend/src/lib/storage.ts, backend/src/lib/documentVersions.ts
• Content processing: backend/src/lib/convert.ts, backend/src/lib/docxTrackedChanges.ts, backend/src/lib/spreadsheet.ts
• Secure export/download primitives: backend/src/lib/downloadTokens.ts, backend/src/lib/manifestSigning.ts
Persistence, Sharing, and Workflows
Supabase Postgres is the system of record for users, chats/messages/citations, projects and sharing, documents/versions, tabular reviews, workflow definitions, API keys, and MCP connectors. Fresh deployment schema is in backend/schema.sql; incremental production evolution is in backend/migrations/. Workflow metadata and system workflow support are centralized in backend/src/routes/workflows.ts and backend/src/lib/systemWorkflows.ts.
Infrastructure and External Services
docker-compose.yml runs the local full stack: frontend/backend, Supabase Postgres/Auth/data gateway, RustFS object storage, and Mailpit. Production substitutes managed Supabase and R2/another S3-compatible store. Supported external AI services are Anthropic, Gemini, OpenAI, OpenRouter, and optional local Ollama; provider credentials may be global or encrypted per-user (backend/src/lib/userApiKeys.ts). CourtListener supports live and optional local-bulk US case-law lookup. MCP integrations, including OAuth-capable connectors, are handled by backend/src/lib/mcp/client.ts and backend/src/lib/mcp/oauth.ts.
Main entry points: documents.ts Document API & versions · chat.ts Domain routes · index.ts Chat orchestration · schema.sql Supabase Postgres & Auth
Components 20
Browser app
Next.js workspace experience.
- Next.js App Router
frontend/src/app/layout.tsx - Workspace routes · Chats, projects, tabular reviews, and workflows establish workspace boundaries.
frontend/src/app/(pages)/assistant/chat/[id]/page.tsx - Workspace views · Interactive chat, project, tabular, and workflow views.
frontend/src/app/components/assistant/ChatView.tsx - Browser auth & API · Supabase session state and backend API calls.
frontend/src/app/contexts/AuthContext.tsx - Assistant stream client · Consumes SSE assistant events.
frontend/src/app/hooks/useAssistantChat.ts - Assistant rendering · Renders streamed content, citations, and tool events.
frontend/src/app/components/assistant/AssistantMessage.tsx
Backend API
Express domain and authorization boundary.
- Express API · Bootstrapped API service for product domains.
backend/src/app.ts - Domain routes · Chats, projects, documents, library, reviews, workflows, and settings.
backend/src/routes/chat.ts - Identity & access · Validates Supabase identity and enforces ownership and sharing.
backend/src/middleware/auth.ts
AI execution
Streaming assistant orchestration and integrations.
- Chat orchestration · Builds context, validates requests, and streams responses.
backend/src/lib/chat/index.ts - LLM gateway · Selects and invokes configured model providers.
backend/src/lib/llm/index.ts - Tool & research dispatch · Runs document actions and case-law research tools.
backend/src/lib/chat/tools/toolDispatcher.ts - MCP connectors · Supports MCP and OAuth-capable connectors.
backend/src/lib/mcp/client.ts
Document services
Versioned files, processing, and export controls.
- Document API & versions · Manages versioned document records and storage operations.
backend/src/routes/documents.ts - Content processing · Extraction, conversion, tracked changes, and spreadsheet handling.
backend/src/lib/convert.ts - Secure downloads · Issues controlled download tokens and signed manifests.
backend/src/lib/downloadTokens.ts
Data and external services
System-of-record and connected providers.
- Supabase Postgres & Auth · Stores identities, workspaces, chats, documents, workflows, and integration metadata.
backend/schema.sql - S3-compatible storage · Stores uploaded document objects and exports.
backend/src/lib/storage.ts - AI model providers · Anthropic, Gemini, OpenAI, OpenRouter, and optional Ollama.
backend/src/lib/llm/openai.ts - CourtListener · Live or local-bulk US case-law research.
backend/src/lib/courtlistener.ts
Connections 23
- Next.js App Router → Workspace routes: renders
- Workspace routes → Workspace views: mounts
- Workspace views → Assistant stream client: submits chat
- Assistant stream client → Assistant rendering: streams events
- Browser auth & API → Express API: authenticated API calls
- Assistant stream client → Domain routes: SSE chat request
- Express API → Domain routes: composes
- Domain routes → Identity & access: authorizes
- Identity & access → Supabase Postgres & Auth: validates identity and access
- Domain routes → Chat orchestration: chat requests
- Chat orchestration → LLM gateway: model generation
- Chat orchestration → Tool & research dispatch: tool calls
- Tool & research dispatch → CourtListener: legal research
- Tool & research dispatch → MCP connectors: external tools
- LLM gateway → AI model providers: provider requests
- Chat orchestration → Supabase Postgres & Auth: messages and citations
- Domain routes → Document API & versions: document operations
- Document API & versions → Content processing: processes content
- Document API & versions → S3-compatible storage: reads and writes objects
- Document API & versions → Supabase Postgres & Auth: versions and metadata
- Document API & versions → Secure downloads: controlled exports
- Secure downloads → S3-compatible storage: serves signed files
- MCP connectors → Supabase Postgres & Auth: connector metadata