Architecture Overview
The Shokunin Platform is a Next.js 15 monorepo backed by Firebase/Firestore and Google Cloud Platform. It is built around a hierarchy of four core concepts: projects → workshops → agents → workflows. This page explains what those concepts are, how they relate, and which parts of the system exist today versus what is planned.Core Concepts
Project
A project is the top-level organizational unit. Every team starts by creating a project, which scopes all work: workshops, agents, task tracking (Beads), and infrastructure configuration. Status: Implemented- Firestore collection:
tenants/{tenantId}/projects/{projectId} - Managed by
domains/dashboard/(project list, creation, member management) DashboardProjectentity carries workshop count, agent count, Beads connection settings, and member list- UI:
/projectslist and/projects/[projectId]detail routes
infrastructure/beads-api or direct host config). This allows a project to track its own issue graph.
Workshop
A workshop is a managed workspace within a project where AI agents collaborate on tasks. Think of it as a room in which a team of AI agents work together, with shared context, a workflow canvas, and a knowledge base. Status: Implemented (schema, repositories, UI routes)- Firestore collection:
tenants/{tenantId}/projects/{projectId}/workshops/{workshopId} - Managed by
domains/workshop/(repositories, hooks, types) - Core entities:
Workshop,Agent,WorkflowNode,WorkflowEdge - UI:
/workshops,/workshops/[workshopId]/overview,/workshops/[workshopId]/agents,/workshops/[workshopId]/workflow,/workshops/[workshopId]/settings - Domain hooks:
useWorkshop,useAgents,useWorkflow(indomains/workshop/hooks/)
Agent
An agent is an AI participant in a workshop. Agents have specializations (e.g., Architect, Developer, DBA, QA), a model assignment, a system prompt, and a status (idle | working | error | active | disabled).
Status: Implemented (schema, repository, agent management UI)
- Firestore collection:
.../workshops/{workshopId}/agents/{agentId} - Repository:
domains/workshop/repositories/agent-repository.ts - Agents are created through the workshop’s agent management UI
- Specializations: Architect, Developer, DBA, DevOps, QA, Security, Tech Lead, Product Owner
- Plan limits enforced in UI (disabled button + upgrade banner when at limit)
Shokunin Agent (Autonomous Service)
The Shokunin Agent (infrastructure/shokunin-agent — Planned) is an autonomous TypeScript service that runs inside a Workshop Container. It manages the full agent lifecycle: polling Beads for ready tasks, creating isolated git worktrees per task, spawning OpenCode sessions, and persisting state to Firestore.
- Replaces the current
agent-loop.shbash script - Built on Fastify with structured logging (pino)
- Talks to OpenCode via
@opencode-ai/sdk(SSE events for completion) - Exposes a control REST API (
POST /loop/start,POST /loop/stop,GET /status) - Can be scoped to a specific Beads epic (
epicId) to work on a subset of tasks
tasks/prd-shokunin-agent-service.md for full specification.
Forge Agent
A Forge Agent is an agent specialized in code review and merge operations — designed to validate and integrate agent-produced changes into the main branch via a dedicated workflow. Forge agents operate on git worktrees produced by other sessions. Status: Planned — Referenced in Shokunin Agent Service PRD as future integration point.Workflow
A workflow is a directed graph of steps that agents execute inside a workshop. Workflows are built visually using a React Flow canvas and persisted in Firestore. Status: Implemented (schema, repositories, canvas UI)- Firestore collections:
.../workflowNodes/{nodeId}and.../workflowEdges/{edgeId} - Repositories:
domains/workshop/repositories/workflow-node-repository.ts,workflow-edge-repository.ts - Node types (from
packages/shokunin-flow):StartNode,StepNode,ConditionNode,LoopNode,ParallelNode,EndNode - Edge types:
FlowEdge,ConditionalEdge,LoopbackEdge - Each
StepNodecan have an assigned agent from the workshop’s agent pool - Mock data: SDLC workflow (Plan → Design → Implement → Review → Test → Deploy) seeded on creation
System Architecture
The diagram below shows the full system: the platform UI running in the browser backed by Firebase, and the planned Workshop Container where autonomous agents execute tasks using OpenCode and Beads.
Domain Model
The platform organizes Firestore data into four domain modules:| Domain | Location | Status |
|---|---|---|
| Dashboard (Projects) | domains/dashboard/ | Implemented |
| Workshop, Agents, Workflow | domains/workshop/ | Implemented |
| Beads (Task Tracking) | domains/beads/ | Implemented |
| (Shokunin Agent Runtime) | infrastructure/shokunin-agent/ | Planned |
Firestore Collection Hierarchy
schemaVersion, createdAt, updatedAt, tenantId) and support on-read lazy migrations via a shared migrations framework.
Package Architecture
Internal packages underpackages/ provide shared primitives:
| Package | Purpose | Status |
|---|---|---|
shokunin-types | Shared TypeScript types | Implemented |
shokunin-ui | Shared UI component library | Implemented |
shokunin-flow | React Flow workflow canvas nodes/edges | Implemented |
shokunin-feature-flags | Static feature flag provider | Implemented |
shokunin-auth | Auth provider and hooks | Implemented |
shokunin-ai | AI provider interface (stub) | Implemented (stub) |
shokunin-collaboration | Collaboration/presence adapter (stub) | Implemented (stub) |
shokunin-cms | CMS adapter | Implemented |
Infrastructure
| Component | Technology | Status |
|---|---|---|
| Web App | Next.js 15, Vercel | Implemented |
| Database | Google Firestore | Implemented |
| Auth | Firebase Authentication | Implemented |
| Task Tracking API | infrastructure/beads-api (Fastify + MySQL) | Implemented |
| OpenCode Web | infrastructure/opencode-web (Docker) | Implemented (scaffold) |
| Workshop Container | Docker (shokunin-agent + opencode) | Planned |
| IaC | Terraform on GCP | Implemented |
Data Flow: From Task to Code
This describes the intended end-to-end flow once the Shokunin Agent Service is implemented.
- User creates a project, creates a workshop, configures agents and a workflow in the platform UI.
- Beads tracks the task graph for the project.
- Shokunin Agent (container) polls Beads for ready tasks (
bd ready). - For each ready task, the agent creates an isolated git worktree (
agent/task-<id>). - The agent spawns an OpenCode session in that worktree and sends the task prompt.
- OpenCode works autonomously; the agent listens for
session.updatedSSE events. - On completion, the agent runs
bd syncto push Beads state, then cleans up the worktree. - A Forge Agent (planned) reviews the produced branch and merges it.
- The platform UI reflects the updated task status in real time.
Key Design Decisions
Repository Pattern
Data access is encapsulated in repository classes underdomains/<domain>/repositories/. Business logic never touches Firestore directly.
Domain Hooks
Custom React hooks (useWorkshop, useAgents, useWorkflow) consume repositories and expose reactive state. Context (tenantId, projectId) is injected explicitly, not read from global state.
Server vs Client Components
Server Components are used by default.'use client' is added only when interactivity (state, events) is strictly required.