How forge-town/ordine works
1. High-level shape
- Ordine is a Bun-based monorepo split into a user-facing app, an API server, and a set of shared domain packages.
- The core architectural boundary is: UI → API layer → services → persistence/engine packages.
2. Main product surface: apps/app
- apps/app is the primary web UI. It uses Vite/React with TanStack Router, TanStack Query, Refine, Storybook, and Playwright/Vitest for testing.
- The UI is organized by feature pages: projects, pipelines, operations, jobs, rules, skills, recipes, settings, runtimes, distillations, and the pipeline canvas.
- Many pages have a local store slice under _store, which keeps page-specific state separate from server data.
3. API boundary: apps/server
- apps/server exposes the backend API. It has both tRPC routes and REST routes.
- Route files map closely to domain areas: best practices, checklist items, code snippets, distillations, filesystem, jobs, operations, pipelines, recipes, rules, and skills.
- This server is the main integration point for the UI, CLI, and any external client.
4. Service layer: packages/services
- Business logic is concentrated in packages/services, with one service module per domain and a dedicated pipelineRunnerService.
- This layer orchestrates validation, state transitions, and cross-domain workflows; it is the main place where domain rules are applied before touching the database or engine.
- Services are what both the app server and other entry points rely on, rather than embedding business logic in route handlers.
5. Persistence layer: packages/db-schema, packages/db, packages/models
- packages/db-schema defines the relational schema and Drizzle table definitions.
- packages/db provides the database connection/runtime integration.
- packages/models implements DAO-style accessors per aggregate, such as jobs, pipelines, operations, best practices, distillations, runtimes, and auth-related entities.
- The generated migrations under apps/app/drizzle show the app owns schema evolution from the application side.
6. Execution engine: packages/pipeline-engine
- The pipeline engine is the core runtime for DAG execution. It defines nodes, edges, scheduling, graph validation, and node-type schemas.
- Built-in node types include operations, folders, GitHub projects, code files, and output nodes.
- This package is the structural basis for the canvas editor and for actual pipeline execution semantics.
7. Agent and automation runtime: packages/agent, packages/agent-engine, packages/plugins
- packages/agent abstracts different AI executors/providers, including Claude and Codex-style runners, plus scan utilities.
- packages/agent-engine provides a higher-level agent execution abstraction.
- packages/plugins and packages/plugin define extension points for custom node/object behavior; the built-in GitHub project plugin is a concrete example.
- This is where “agent-first” execution is realized: operations can be driven by an AI agent, not only scripts.
8. Pipeline runner orchestration
- packages/services/src/pipelineRunnerService is the glue between the pipeline graph, agents, and execution outcomes.
- It contains prompt execution, skill execution, loop evaluation, structured output handling, and cwd resolution.
- This layer is responsible for turning a pipeline definition into a running job with traced steps and results.
9. Jobs, traces, and observability
- Job execution is a first-class entity across the app, server, and database.
- The repo also has observability packages (packages/obs, packages/logger) and tables for agent spans, job traces, pipeline runs, and refinement runs.
- The resulting data flow is: execution produces traces/spans → persisted through model/DAO layers → surfaced in job/detail dashboards and console panels.
10. Auth, user sessions, and environment config
- Authentication is handled through better-auth integrations in the app, with backend auth routes in apps/app/src/routes/api/auth.$.ts.
- Auth-related tables include users, accounts, sessions, and verifications.
- Environment parsing is standardized across packages via per-package env schemas, which keeps runtime configuration explicit and typed.
11. Canvas and editor-style workflow authoring
- The CanvasPage is a notable subsystem: it is a node/edge editor for composing pipelines visually.
- It has its own store, context menus, node palettes, layout utilities, and schema types for node data.
- Data flow here is UI canvas state → serialized pipeline definition → backend services/engine.
12. Content and knowledge layer
- apps/docs is the public documentation site, including API docs and “skills” guides.
- The skills/ and apps/scripts/src/best-practices/ directories contain executable/content artifacts for the product’s built-in workflows and examples.
- This content is part of the product model, not just documentation: it feeds best-practice, recipe, rule, and skill features in the app.
13. CLI and automation entry points
- apps/cli provides a command-line surface for interacting with the system, likely aimed at local automation or daemon-style use.
- apps/scripts contains seed and migration scripts for populating domain data such as best practices, rules, recipes, and pipelines.
- These are secondary entry points that support bootstrapping and operational workflows.
14. Key end-to-end flow to diagram
- Typical flow: user acts in apps/app → client calls tRPC/REST in apps/server → server delegates to packages/services → services read/write via packages/models and packages/db → pipeline/job execution may invoke packages/pipeline-engine and packages/agent → results/traces persist back to DB and are rendered in the UI.
- A separate authoring flow exists for the canvas: edit graph in UI → save pipeline definition → execute through the same service/engine path.
15. Repo-level tooling that matters architecturally
- The monorepo uses Turbo for orchestration, Changesets for package releases, Vitest for unit tests, Playwright for E2E, Storybook for component isolation, Drizzle for migrations, and Bun as the runtime/package manager.
- These choices reinforce a strongly modular architecture with many independently testable packages and feature-focused app modules.
Main entry points: app App UI · services Services · server API Server · schemas Schemas
Components 17
Apps
User-facing and operational entry points.
Backend
API, services, and execution runtime.
- API Server · Backend API exposing tRPC and REST routes for domain operations and external clients.
apps/server - Services · Business logic layer coordinating validation, workflows, and orchestration before persistence or execution.
packages/services
Data
Schema, DB access, and persistence models.
- DB Schema · Relational table definitions and relations for domain entities and execution records.
packages/db-schema - DB Runtime · Database connection and environment integration used by persistence code.
packages/db - Models · Aggregate-specific data access objects for jobs, pipelines, operations, best practices, rules, skills, and related entities.
packages/models
Engine
Pipeline and agent execution layers.
- Pipeline Runner · Glue that turns pipeline definitions into executions via prompt handling, skill execution, loop evaluation, and structured output.
packages/services/src/pipelineRunnerService - Pipeline Engine · Core graph engine for pipeline validation, scheduling, node behavior, and execution semantics.
packages/pipeline-engine - Agent Runtime · Agent abstractions and provider runners for Claude, Codex, scanning, and higher-level agent execution.
packages/agent - Agent Engine · Higher-level abstraction for executing agent workflows.
packages/agent-engine - Plugins · Plugin interfaces and built-in extensions such as the GitHub project plugin.
packages/plugins
Content
Docs, skills, and bootstrapping artifacts.
Shared
Reusable UI, schemas, and utilities.
- Schemas · Common Zod schemas for jobs, pipelines, operations, rules, skills, settings, spans, and agent/runtime data.
packages/schemas - UI Kit · Reusable design system and component primitives shared by the app and other frontends.
packages/ui - Utils · Shared utility helpers, including filesystem support.
packages/utils
Connections 21
- App UI → API Server: UI calls · Client pages fetch and mutate through backend routes.
- API Server → Services: delegates · Route handlers forward domain work to services.
- Services → Models: reads/writes · Services persist and load aggregates through DAO accessors.
- Models → DB Runtime: uses · DAO implementations use the database runtime.
- DB Runtime → DB Schema: targets · Runtime operates against the relational schema definitions.
- Services → Pipeline Runner: orchestrates · Core services invoke the pipeline runner for execution workflows.
- Pipeline Runner → Pipeline Engine: executes · Runner translates pipeline definitions into engine execution.
- Pipeline Runner → Agent Runtime: invokes · Runner uses AI executors and provider abstractions during runs.
- Agent Runtime → Agent Engine: wraps · Agent runtime provides lower-level execution building blocks for the higher-level agent engine.
- Pipeline Engine → Plugins: dispatches · Engine resolves built-in and plugin-provided node behavior.
- Plugins → Pipeline Engine: extends · Plugins add node/object behavior to the pipeline system.
- App UI → Schemas: shares types · UI and client code rely on shared domain schemas.
- API Server → Schemas: validates · Server routes validate input/output using shared schemas.
- Services → Schemas: enforces · Service-layer rules operate on shared domain types.
- App UI → UI Kit: renders · Frontend pages compose the shared UI component library.
- App UI → Utils: uses · Application code reuses shared utility helpers.
- App UI → CLI: same domain · CLI shares the same backend and domain model surface as the app.
- CLI → API Server: connects to · Command-line workflows interact with the API server.
- Scripts → Models: seeds via · Scripts populate domain data through model access patterns.
- Scripts → DB Schema: migrates content · Scripts and migrations reflect the domain schema used by the app.
- Docs → Schemas: documents · Docs describe the same domain objects and workflows encoded in shared schemas.