A production-oriented starter repository for a multi-agent collaboration platform where users sign in with GitHub, run structured AI workflows, and can later layer GitHub Copilot on top of the same identity model.
This revision makes the starter more coherent in two places:
- Web-first auth: GitHub OAuth now belongs to the Next.js app. The raw GitHub provider token is no longer surfaced in the browser session.
- Deterministic swarm execution: the FastAPI backend now runs a real manager-controlled loop with orchestrator, builder, critic, optional repair, optional marketing, and validator stages.
This repository is a monorepo starter for a real product, not just a demo script.
It includes:
apps/web: a Next.js web app for sign-in, dashboard, task submission, and future Copilot session wiring.apps/api: a FastAPI backend for swarm orchestration, run state, and internal platform-session exchange.docs/: architecture and integration notes.
Users log in with GitHub, submit a task, and the platform runs a controlled specialist workflow through an execution console that keeps review state visible:
- Orchestrator
- Builder
- Critic
- Optional repair pass
- Optional marketer
- Validator
The platform stores run state, limits loops, keeps the control plane deterministic, and surfaces approvals, confidence, risk, and follow-up actions from explicit run state.
GitHub OAuth lives in the Next.js layer. The browser gets a normal signed-in session, but the starter does not push the raw GitHub access token into the client-visible session object.
Server-side routes that need GitHub access use the helper in apps/web/lib/auth.ts to read the token from the encrypted Auth.js JWT instead of from the browser session payload.
When the web app needs a backend platform token, it can call the API's internal exchange endpoint:
POST /auth/session/exchange- protected by
x-platform-internal-key - accepts a minimal identity payload from the signed-in web session
- returns a platform JWT for backend use
This keeps provider auth separate from platform auth.
The intended architecture is:
- GitHub sign-in handled by the web app
- GitHub-backed Copilot calls handled server-side
- platform JWTs used for your own backend APIs
That means GitHub identity can power both your product session model and later Copilot-based features without treating Copilot as a standalone identity provider.
Diagnostic routes such as /api/session-debug and /api/copilot-smoke are not part of the default dashboard flow and should only be reachable in development or when an internal request supplies x-platform-internal-key.
apps/
api/ -> FastAPI swarm backend
web/ -> Next.js product UI
docs/
architecture.md
github-copilot.md
The backend now runs a real bounded flow in apps/api/app/services/swarm.py:
- create a run record
- orchestrator builds plan + success criteria
- builder creates the initial artifact
- critic evaluates blockers / major issues / minor issues
- one bounded repair pass runs if needed
- optional marketing artifact is added
- validator returns
passed,failed, orneeds_approval
require_repo_context=truecurrently fails because repo retrieval is not wired into the run path yet.production_readymoves the run toneeds_approvalif infrastructure risks remain.- otherwise the run can pass with explicit artifacts for every stage.
- critic and validator artifacts now record additive risk and confidence fields grounded in blockers, major issues, repair attempts, and approval state
- runs also record product metric events for activation, success, approval-required, approval-completed, rerun-created, and compare-ready when those states are explicitly present
- the dashboard surfaces an approval inbox and suggested next actions from stored run state instead of opaque generated copy
For local development, use:
- Homepage URL:
http://localhost:3001 - Authorization callback URL:
http://localhost:3001/api/auth/callback/github
Copy the templates and keep the values aligned across the repo:
cp .env.example .env
cp apps/api/.env.example apps/api/.env
cp apps/web/.env.example apps/web/.env.localSet at minimum:
GITHUB_IDGITHUB_SECRETNEXTAUTH_SECRETJWT_SECRETPLATFORM_INTERNAL_API_KEYOPENAI_API_KEYwhen you replace the deterministic starter logic with model-backed agent calls
docker compose up --buildThe canonical run path in this starter is:
browser/dashboard form
-> apps/web route handlers at /api/swarm/runs
-> apps/api /swarm/runs
-> JSON run persistence in the API runs directory
The web app no longer maintains a separate authoritative run store.
- Web:
http://localhost:3001 - API docs:
http://localhost:8000/docs
apps/web/lib/auth.tsapps/api/app/routers/auth.pyapps/api/app/services/swarm.py.env.example
- Add protected Next.js route handlers that use
exchangePlatformSession()for server-to-server API calls. - Move swarm API routes behind platform JWT auth.
- Replace deterministic builder / critic logic with typed model-backed agents.
- Add persistent storage beyond JSON files.
- Add GitHub App installation flow for repository import and finer-grained org access.
This repo still starts with GitHub OAuth App for the MVP sign-in flow.
Recommended upgrade path:
- keep OAuth App for initial sign-in
- add a GitHub App for repo installs, org access, and production-grade GitHub permissions
- layer Copilot SDK into server routes that run on behalf of the signed-in GitHub user