StackForge turns a plain-English product idea into a structured full-stack project blueprint. A fixed sequence of LLM-backed stages produces it, and the stages stream their progress to the browser over Server-Sent Events (SSE).
Bun workspaces and Turborepo. turbo run build|test|typecheck builds upstream packages first (dependsOn: ["^build"]).
| Path | Role |
|---|---|
apps/api |
Express server. Validates requests, creates jobs, runs the pipeline, streams SSE, and serves ZIP download, GitHub push, and add-feature endpoints. |
apps/web |
Vite + React dashboard (deployed to Vercel). In dev it proxies /api to localhost:3001. Has a client-side demo mode that works with no API. |
packages/agents |
The pipeline: workflow definitions, WorkflowEngine, the AgentStepExecutor boundary, LLM providers (OpenRouter, NVIDIA, mock), the cache, and skills. |
packages/shared |
Zod schemas and TypeScript types shared by every package: requests, jobs, SSE events, and the blueprint. |
packages/ui |
Small React UI primitives used by apps/web. |
Dependency direction: apps/* → packages/agents → packages/shared. packages/shared depends on nothing internal.
POST /api/generate
→ GenerateRequestSchema (zod)
→ job.store.createJob() status: queued
→ runOrchestrator() status: running
selectWorkflow(prompt) fullstack-scaffold | feature-add
WorkflowEngine.run()
for each step: AgentStepExecutor.execute()
currentStage = step.agent
assembleBlueprintFromWorkflow() normalize + defaults
BlueprintSchema.safeParse() reject invalid output
→ job.store.updateJob() status: completed | failed
GET /api/stream/:jobId SSE replay + live events
packages/agents/src/workflow/router.ts defines two workflows.
| Workflow | Selected when | Stages |
|---|---|---|
fullstack-scaffold |
default | planner → schema → api → frontend → devops → reviewer → codegen |
feature-add |
prompt contains add/feature/update/modify | planner → schema → api → frontend → devops |
Setting execution.enableCodeGeneration: false removes codegen. Stages run strictly in order. Each stage gets the user goal plus a compressed summary of every earlier stage's output (WorkflowState), and its full structured output is kept for blueprint assembly.
interface AgentStepExecutor {
execute(request: StepExecutionRequest): Promise<StepExecutionResult>;
}
// request: { jobId, goal, workflow, step, state, emit }
// result: { rawOutput, compressedOutput, tokensUsed }The boundary splits responsibilities between two components:
WorkflowEngine(workflow/engine.ts) owns ordering and state. It walks the steps, calls the executor, storescompressedOutputin state andrawOutputfor assembly, and sums tokens. It has no knowledge of providers, prompts, or caching.ProviderStepExecutor(workflow/provider-step-executor.ts) is the default executor. For one stage it builds the prompt from the skill file, checks the cache, calls theLLMProviderwith token streaming, validates the output shape, makes one repair call when validation fails, compresses the output for the next stages, and emits the stage's SSE events (agent_started,agent_token,agent_complete,agent_completed,agent_failed).
You can pass runOrchestrator({ ..., executor }) to replace step execution, for example to use a deterministic mock in tests or to replay recorded outputs. If you omit executor, the default provider-backed path runs.
Failures: when an executor throws, WorkflowEngine rethrows the error as StepExecutionError, which carries stage, stepId, and the original message. apps/api stores this as job.failure and sends it in the job_failed SSE payload. A failure outside any stage, such as a token-budget check or blueprint validation, sets error but leaves failure unset.
| Where | Schema | Effect |
|---|---|---|
POST /api/generate |
GenerateRequestSchema |
422 when the trimmed prompt is outside 10 to 2000 characters, or the budget is invalid. |
| Each stage | validateStepOutput (shape check) |
One repair call, then the stage fails. |
| After assembly | BlueprintSchema |
The job fails with the first schema issues. |
POST /api/pipeline/add-feature |
BlueprintSchema on previousOutput |
Rejects a malformed input blueprint. |
apps/api/src/store/job.store.ts keeps jobs in a process-local Map:
- Statuses:
queued→running→completed|failed. - Each job holds
currentStage,agentsCompleted,error,failure,blueprint, and the full SSE event log, which is used to replay events to clients that reconnect. - Limits: at most 200 jobs, and completed or failed jobs are evicted 1 hour after their last update.
This is intentional for v1. Jobs are short-lived, and users download or push the result to GitHub. Because the store is in memory, jobs are lost on restart, one API instance cannot share jobs with another, and an interrupted run cannot be resumed. Anything that needs durable state should replace this module behind its existing functions (createJob, getJob, updateJob, appendEvent, listJobs).
The feat/loop-engine branch contains packages/loop-core, a SQLite-backed milestone, gate, and memory engine, and apps/mcp, an MCP server that exposes it. That work is a separate product for driving external coding agents. It is not merged into v1 and nothing on main depends on it. Phase 2 moves it into its own repository.