AI Workforce is a Next.js app for designing a multi-agent workflow graph and chatting with each agent using session-based conversations.
- A visual workforce editor using React Flow (
/workforce) - Custom agent nodes with:
- name
- description
- job description
- model
- skills
- avatar emoji
- Graph persistence to PostgreSQL with Prisma
- Chat per agent with task sessions:
New Taskcreates a fresh chat sessionPrevious taskslets you reopen older sessions- messages persist across refresh
- Next.js (App Router)
- React + TypeScript
- Tailwind CSS
- React Flow (
@xyflow/react) - Prisma + PostgreSQL
src/app/workforce/page.tsx: workforce pagesrc/components/workforce/workforce-graph-editor.tsx: graph editor + chat UIsrc/app/api/workforce-graphs/route.ts: create/read latest graphsrc/app/api/workforce-graphs/[id]/route.ts: read/update one graphsrc/app/api/workforce-graphs/[id]/chat/route.ts: chat messages APIsrc/app/api/workforce-graphs/[id]/chat/sessions/route.ts: chat sessions APIprisma/schema.prisma: data modelsdocker-compose.yml: local PostgreSQL service
WorkforceGraph: stores graph metadata and JSON graph payload (nodes,edges)WorkforceChatSession: stores task/session per graph + agentWorkforceChatMessage: stores messages inside a session
npm installdocker compose up -dCopy .env.example to .env and ensure DATABASE_URL is valid.
Example:
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/ai_workforce?schema=public"npm run prisma:generate
npm run prisma:pushnpm run devOpen http://localhost:3000, then go to /workforce.
npm run dev: start dev servernpm run build: create production buildnpm run start: start production servernpm run lint: run ESLintnpm run prisma:generate: generate Prisma clientnpm run prisma:push: push schema to database
- A chat task equals one
WorkforceChatSession. - New messages are written to the selected session.
- Session timestamps are updated on new messages.
- Legacy messages without a session are backfilled into an "Earlier conversation" session when sessions are loaded.
- If you see chat/session table errors:
- run
npm run prisma:push - restart dev server if needed
- run
- If
New Taskfails:- check API logs from
src/app/api/workforce-graphs/[id]/chat/sessions/route.ts - verify PostgreSQL is running and reachable via
DATABASE_URL
- check API logs from