OpenMAIC
Audited from github.com/THU-MAIC/OpenMAIC
OpenMAIC (Open Multi-Agent Interactive Classroom), from Tsinghua's MAIC team, turns a topic or document into an interactive lesson. It generates slides, quizzes, whiteboard explanations and discussions in which several AI agents act as teacher and classmates.
- Language
- TypeScript
- Database
- PostgreSQL
- Hosting
- Docker
- License
- MIT
- Running for
- 6 months
- Team
- 6-20 people
Why this architecture
Built as a Next.js app around a set of npm-published packages (slide DSL, generation, renderer, editor, importer, storage). The multi-agent LangGraph pipeline, the slide format and persistence can each be reused or swapped, and heavy video rendering runs in a separate container.
Tech stack by layer
17 technologies · audited Sep 25, 2026- Next.jsNext.js 16 App Router app (app/classroom, app/workbench, app/api) serving UI and API routes
- ReactReact 19 UI for classroom stage, slide editor, whiteboard, roundtable discussion and chat
- Tailwind CSSStyling via Tailwind 4 PostCSS with shadcn-style components on Radix UI and Base UI
- ZustandClient state stores under lib/store, with Dexie for IndexedDB persistence in the browser
- ProseMirrorRich text editing inside slides, packaged in @openmaic/editor
- PostgreSQLOptional server persistence via pg in @openmaic/storage (documents, runtime, sessions, assets)
- S3Asset storage with presigned URLs through the AWS S3 client
- DockerMulti-stage Node 22 Alpine image plus docker-compose with an optional video-export profile
- VercelOne-click deploy target; vercel.json allows 300-second API functions for generation
- VitestLarge unit/integration suite under tests/, with separate eval runners in eval/
- PlaywrightEnd-to-end browser tests in e2e/
- Vercel AI SDKModel access for OpenAI, Anthropic, Google, Azure and Bedrock plus streaming chat UI hooks
- LangGraphOrchestration of the multi-agent classroom (teacher, classmates, discussion) under lib/orchestration
- Model Context ProtocolMCP SDK so external agents and tools can connect to classroom generation
OpenMAIC architecture diagram
Open SVGDiagram as text
- Classroom & workbench (Next.js · React) → App & API routes (Next.js App Router): generate · chat
- External agents (MCP) → App & API routes (Next.js App Router): MCP
- Classroom & workbench (Next.js · React) → Browser storage (Dexie (IndexedDB)): local state
- App & API routes (Next.js App Router) → Multi-agent classroom (LangGraph): classroom run
- Multi-agent classroom (LangGraph) → Model providers (Vercel AI SDK): prompts
- App & API routes (Next.js App Router) → PostgreSQL (optional persistence): sessions
- App & API routes (Next.js App Router) → Assets (S3 presigned URLs): assets
- App & API routes (Next.js App Router) → Render service (Hono · Puppeteer · FFmpeg): export MP4
Key architectural decisions
5 decisions- 01
A slide DSL package is the contract between generation, rendering and import
@openmaic/dsl is a dependency-free package of types, JSON Schema, validators and migration helpers; @openmaic/generation, renderer, editor, importer and storage all depend on it and are published to npm separately from the Next.js app.
- 02
Multi-agent classroom orchestrated with LangGraph
lib/orchestration, lib/agent and lib/agent-runtime coordinate teacher and classmate agents with @langchain/langgraph, while the Vercel AI SDK providers let the same flows run on OpenAI, Anthropic, Google, Azure or Bedrock models.
- 03
Pluggable persistence from browser-only to Postgres
@openmaic/storage exposes document, runtime, KV, asset, agent-session and skill primitives with browser and HTTP backends plus pg backends; the build arg NEXT_PUBLIC_PERSISTENCE selects the mode, and a storage-pg-contract workflow tests the Postgres backend.
- 04
Video export isolated in a separate render service
render-service/ is its own Node 22 + Chromium + FFmpeg container (Hono, puppeteer-core, Hyperframes producer); docker-compose only starts it under a video-export profile and the app probes /health, falling back to ZIP download when it is absent.
- 05
Evals live next to the code
eval/ contains runners for orchestration, outline language, whiteboard layout, PBL planning and zone of proximal development, executed with tsx through package.json scripts and a dedicated vitest.eval.config.ts.
How OpenMAIC is built
How OpenMAIC is structured
OpenMAIC is a pnpm workspace (pnpm-workspace.yaml) centered on a Next.js app at the repository root:
app/: App Router routes such asapp/classroom,app/workbench,app/workspace,app/generation-preview,app/evalandapp/api.components/: UI for the classroom stage, slide renderer, whiteboard, roundtable, chat, agent panels and settings.lib/: domain logic, split into about 50 folders (orchestration,agent-runtime,generation,pbl,quiz,rag,whiteboard,persistence,storage,video-export,web-search, …).packages/@openmaic/*: the published packagesdsl,generation,renderer,editor,importerandstorage.packages/pptxgenjsandpackages/mathml2omml: vendored forks used for Office export.packages/docs: a standalone docs app, excluded from the workspace.render-service/: a separate MP4 rendering container.eval/,tests/,e2e/: evaluations, unit tests and browser tests.
Frontend
The app runs on Next.js 16 with React 19. The UI uses Tailwind CSS 4, shadcn components on Radix UI and Base UI, motion for animation, @xyflow/react for node graphs, ECharts for charts and KaTeX/Temml for math. Chat output streams through streamdown with code and math plugins.
Client state lives in Zustand stores (lib/store). Browser-side persistence uses Dexie on IndexedDB. Rich text inside slides comes from ProseMirror in @openmaic/editor, and slides render through @openmaic/renderer, which reads the same JSON the generator emits. Internationalization uses i18next, and scripts/check-i18n-keys.mjs checks translation keys.
Backend & APIs
Server logic runs in Next.js API routes (app/api). vercel.json allows these functions up to 300 seconds, which covers long generation runs. The AI layer combines:
- the Vercel AI SDK with OpenAI, Anthropic, Google, Azure and Amazon Bedrock providers,
- LangGraph and LangChain core for multi-agent orchestration,
- CopilotKit runtime packages and
@earendil-works/pi-agent-corefor the agent chat surface, - the Model Context Protocol SDK.
Document ingestion uses unpdf, pdf-lib, Mozilla Readability, turndown and Alibaba Cloud DocMind for parsing PDFs and web pages (lib/media-parse, lib/document, lib/web-search). Exports use the vendored pptxgenjs and the docx package.
Data & persistence
@openmaic/storage defines document, runtime, KV, asset, agent-session, skill and material primitives with three kinds of backend: browser, HTTP and PostgreSQL (the pg driver). The persistence mode is set at build time with NEXT_PUBLIC_PERSISTENCE. Assets can go to S3-compatible storage through @aws-sdk/client-s3 with presigned URLs. Tests use @electric-sql/pglite as an in-process Postgres, and the storage-pg-contract.yml workflow runs the Postgres contract suites.
Build, test & deploy
postinstallbuilds the internal packages in dependency order, thenscripts/sync-maic-importer.mjssyncs the importer.next buildfirst checks the vendored importer.- Tests: Vitest (
vitest.config.ts, with a largetests/tree), Playwright (e2e/) and eval runners (vitest.eval.config.ts,eval/*). - GitHub Actions workflows:
ci.yml,docs-build.yml,publish-packages.yml,publish-openmaic-skill.yml,storage-pg-contract.ymlandissue-triage.yml. - Deploys use Docker (a multi-stage
node:22-alpineimage with native build tools forsharpand@napi-rs/canvas) or Vercel.
Self-hosting notes
Copy .env.example to .env.local, set at least one LLM provider key, and run docker compose up -d --build. NEXT_PUBLIC_* flags are compiled into the browser bundle, so feature toggles need a rebuild. The build args include flags for the editor, video export, PPTX import and Pi chat. Start the video-export compose profile to run the render service. comfyui-setup-instructions.md covers optional image generation.
What to copy (and what not to)
What to copy
- A dependency-free DSL package with JSON Schema as the single contract between the generator, renderer, editor and importer.
- Moving Chromium- and FFmpeg-based rendering into its own container behind a health check, with a degraded fallback when it is missing.
- Keeping model evaluations in the repository next to the prompts and pipelines they test.
What not to copy
- The root
package.jsonhas well over a hundred runtime dependencies, including a dozen font packages. Splitting the app into feature packages would make installs and upgrades easier to follow. - Building all internal packages in a
postinstallshell chain is fragile. A task runner with a dependency graph would be more reliable.
Sources & repo audit
- package.json (Next.js 16, AI SDK providers, LangGraph, storage and editor packages)
- packages/@openmaic/dsl/package.json (slide DSL contract)
- render-service/package.json (MP4 render service)
- docker-compose.yml
Independent analysis of repository at github.com/THU-MAIC/OpenMAIC. Spotted an inaccuracy? Use the claim form to request a correction.
Maintainer? Add the architecture badge to your README
[](https://stackitfast.com/project/openmaic) Scaffold it with your agent
Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with OpenMAIC's architecture.
- 1Copy the promptThe full markdown spec, with every layer and decision.
- 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
- 3Paste and scaffoldUse it as the first instruction; review before you ship.
# MISSION: Scaffold "OpenMAIC" Production Architecture
You are an expert Senior Staff Software Architect and Full-Stack Engineer. Your mission is to scaffold and implement a production-grade, highly reliable, and modular codebase following the proven architecture of **OpenMAIC**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: OpenMAIC
- **What It Does**: OpenMAIC (Open Multi-Agent Interactive Classroom), from Tsinghua's MAIC team, turns a topic or document into an interactive lesson. It generates slides, quizzes, whiteboard explanations and discussions in which several AI agents act as teacher and classmates.
- **Domain & Category**: Multi-Agent Interactive AI Classroom
- **Production Scale**: 6-20 people
- **Development Mode**: CLASSIC
- **Architectural Rationale**: Built as a Next.js app around a set of npm-published packages (slide DSL, generation, renderer, editor, importer, storage). The multi-agent LangGraph pipeline, the slide format and persistence can each be reused or swapped, and heavy video rendering runs in a separate container.
- **Live Website Reference**: https://open.maic.chat/
- **Source Repository**: https://github.com/THU-MAIC/OpenMAIC
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: TypeScript, Next.js, React, Tailwind CSS, Radix UI, Zustand, Vercel AI SDK, LangGraph, LangChain, Model Context Protocol, PostgreSQL, Hono, Puppeteer, Docker, Vercel, Vitest, Playwright
- **Primary Language(s)**: TypeScript, JavaScript, MDX, CSS
- **License of the reference repo**: MIT
- **Frontend**: Next.js — Next.js 16 App Router app (app/classroom, app/workbench, app/api) serving UI and API routes; React — React 19 UI for classroom stage, slide editor, whiteboard, roundtable discussion and chat; Tailwind CSS — Styling via Tailwind 4 PostCSS with shadcn-style components on Radix UI and Base UI; Zustand — Client state stores under lib/store, with Dexie for IndexedDB persistence in the browser; ProseMirror — Rich text editing inside slides, packaged in @openmaic/editor
- **Backend & APIs**: Hono — HTTP server of the isolated render-service that turns exported lessons into MP4; Puppeteer — Headless Chromium (puppeteer-core) with FFmpeg in render-service for video export
- **Data & persistence**: PostgreSQL — Optional server persistence via pg in @openmaic/storage (documents, runtime, sessions, assets); S3 — Asset storage with presigned URLs through the AWS S3 client
- **Infrastructure & deploy**: Docker — Multi-stage Node 22 Alpine image plus docker-compose with an optional video-export profile; Vercel — One-click deploy target; vercel.json allows 300-second API functions for generation; Vitest — Large unit/integration suite under tests/, with separate eval runners in eval/; Playwright — End-to-end browser tests in e2e/
- **Tooling, testing & ops**: Vercel AI SDK — Model access for OpenAI, Anthropic, Google, Azure and Bedrock plus streaming chat UI hooks; LangGraph — Orchestration of the multi-agent classroom (teacher, classmates, discussion) under lib/orchestration; Model Context Protocol — MCP SDK so external agents and tools can connect to classroom generation
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/THU-MAIC/OpenMAIC @ 21d83ec)
1. **A slide DSL package is the contract between generation, rendering and import**: @openmaic/dsl is a dependency-free package of types, JSON Schema, validators and migration helpers; @openmaic/generation, renderer, editor, importer and storage all depend on it and are published to npm separately from the Next.js app.
2. **Multi-agent classroom orchestrated with LangGraph**: lib/orchestration, lib/agent and lib/agent-runtime coordinate teacher and classmate agents with @langchain/langgraph, while the Vercel AI SDK providers let the same flows run on OpenAI, Anthropic, Google, Azure or Bedrock models.
3. **Pluggable persistence from browser-only to Postgres**: @openmaic/storage exposes document, runtime, KV, asset, agent-session and skill primitives with browser and HTTP backends plus pg backends; the build arg NEXT_PUBLIC_PERSISTENCE selects the mode, and a storage-pg-contract workflow tests the Postgres backend.
4. **Video export isolated in a separate render service**: render-service/ is its own Node 22 + Chromium + FFmpeg container (Hono, puppeteer-core, Hyperframes producer); docker-compose only starts it under a video-export profile and the app probes /health, falling back to ZIP download when it is absent.
5. **Evals live next to the code**: eval/ contains runners for orchestration, outline language, whiteboard layout, PBL planning and zone of proximal development, executed with tsx through package.json scripts and a dedicated vitest.eval.config.ts.
---
## 4. NON-NEGOTIABLE ARCHITECTURAL GUARDRAILS
1. **Monorepo & Modular Separation**:
- Structure as a Turborepo monorepo with strict package boundaries:
- `apps/web`: Application UI, routing, layouts, and server endpoints.
- `packages/ui`: Shared design tokens, CSS variables, and Radix UI primitive components.
- `packages/db`: Database schemas, client singleton, declarative migrations, and seed scripts.
- `packages/config`: Shared TypeScript, ESLint, and build configurations.
2. **Strict Type Safety & Zero `any` Policy**:
- Enable `strict: true`, `noImplicitAny: true`, and `strictNullChecks: true`.
- Validate ALL external inputs, API request bodies, and query parameters with **Zod** schemas before execution.
3. **Frontend & Rendering Guidelines**:
- Utilize Next.js 15 App Router: default to React Server Components (RSC) for data fetching. Handle mutations through Server Actions with Zod validation. Keep 'use client' directives restricted strictly to interactive leaf components.
4. **Design System & Aesthetics**:
- Keep every color, radius, shadow and font in a single token file (CSS variables) and consume tokens everywhere; never hardcode hex values in components.
- Prefer crisp 1px borders and one subtle shadow scale over blurry default shadows. Pair one sans-serif for body/headings with one monospace for tags, badges, metrics, and code.
5. **Data Layer & Reliability**:
- Write declarative schema definitions with foreign keys, composite indexes on queried filters, and automated timestamp triggers.
- Use connection pooling and prepared statements for serverless database execution.
---
## 5. STEP-BY-STEP SCAFFOLDING ROADMAP
- **Phase 1: Workspace & Root Config**: Initialize package manager, monorepo configuration (`turbo.json`, `tsconfig.base.json`, `package.json`).
- **Phase 2: Database Schema & Client**: Set up the data layer (PostgreSQL, S3): client, connection pool, models, and migration scripts.
- **Phase 3: Design Tokens & UI Primitives**: Build accessible `Button`, `Input`, `Card`, `Badge`, and layout wrappers inside `packages/ui`.
- **Phase 4: Core Application Routes & Handlers**: Implement primary authentication, user session handling, and application routes.
- **Phase 5: Quality Assurance & Build Verification**: Run `tsc --noEmit`, ESLint, Prettier, and smoke test suites to ensure zero compilation or runtime errors.
---
## 6. EXECUTION INSTRUCTIONS
1. Review all specifications, architectural guardrails, and stack choices above.
2. Present the full monorepo directory tree structure.
3. Systematically generate the complete, production-ready codebase according to the 5-phase roadmap above — starting with the root workspace setup, followed by the database schema, UI design system package, and full-stack application routes until the repository is fully scaffolded and ready to run.Frequently asked about OpenMAIC
What is OpenMAIC built with?
OpenMAIC is a Next.js 16 and React 19 TypeScript app styled with Tailwind CSS 4. It orchestrates multiple LLM agents with LangGraph and the Vercel AI SDK, and stores data in the browser or in PostgreSQL through its own @openmaic/storage package.
Which AI models does OpenMAIC support?
Through Vercel AI SDK providers it supports OpenAI, Anthropic, Google, Azure OpenAI and Amazon Bedrock. The README also documents local options such as Lemonade for local LLMs and FunASR for speech recognition.
Can I self-host OpenMAIC?
Yes. The repository ships a Dockerfile and docker-compose.yml for self-hosting and a Deploy to Vercel button. At least one LLM provider key is required. MP4 export needs the optional render-service container.
How does OpenMAIC export lessons?
Lessons can be exported as PowerPoint (via a vendored pptxgenjs), Word documents (docx) or, with the separate render-service, as MP4 video rendered in headless Chromium with FFmpeg.
One email a month: new deep dives and stack trends
New source-audited architectures, head-to-head comparisons and the monthly stack report. No spam, unsubscribe anytime.
Similar architectures
- LangfuseAI-agentLLM Observability · 6-20 peopleShares TypeScript · Next.js · React
- VoiceStudioHybridLocal AI Voice Cloning & Speech Studio · 2-5 peopleShares Model Context Protocol · TypeScript · React
- Dify.aiAI-agentLLM App Builder · 20+ peopleShares Next.js · TypeScript · PostgreSQL
- Mem0AI-agentAI Memory & Context Engine · 2-5 peopleShares TypeScript · PostgreSQL · Next.js
- shadcn/uiHybridCopy-Paste UI Component Architecture · 1M+ MAUShares React · Tailwind CSS · Radix UI
- Supabase StudioClassicDeveloper Tool · 20+ peopleShares Next.js · React · TypeScript