# forge-town/ordine architecture

> Architecture diagram of the GitHub repository forge-town/ordine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/forge-town/ordine
- Repository: https://github.com/forge-town/ordine

## Overview

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: [`apps/app`](https://github.com/forge-town/ordine/tree/main/apps/app) (App UI), [`packages/services`](https://github.com/forge-town/ordine/tree/main/packages/services) (Services), [`apps/server`](https://github.com/forge-town/ordine/tree/main/apps/server) (API Server), [`packages/schemas`](https://github.com/forge-town/ordine/tree/main/packages/schemas) (Schemas)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_apps["Apps"]
  node_apps_app["App UI<br/>React app"]
  node_cli["CLI<br/>command line"]
end

subgraph group_backend["Backend"]
  node_apps_server["API Server<br/>Bun API"]
  node_packages_services["Services"]
end

subgraph group_data["Data"]
  node_db_schema["DB Schema<br/>Drizzle schema"]
  node_db_runtime["DB Runtime<br/>database runtime"]
  node_models["Models<br/>DAOs"]
end

subgraph group_engine["Engine"]
  node_pipeline_runner["Pipeline Runner<br/>orchestration"]
  node_pipeline_engine["Pipeline Engine<br/>DAG runtime"]
  node_agent_runtime["Agent Runtime<br/>AI execution"]
  node_agent_engine["Agent Engine<br/>agent orchestration"]
  node_plugins["Plugins<br/>extension layer"]
end

subgraph group_content["Content"]
  node_docs["Docs<br/>VitePress site"]
  node_scripts["Scripts<br/>seed tools"]
end

subgraph group_shared["Shared"]
  node_schemas["Schemas<br/>shared validation"]
  node_ui["UI Kit<br/>component library"]
  node_utils["Utils<br/>helpers"]
end

node_apps_app -->|"UI calls"| node_apps_server
node_apps_server -->|"delegates"| node_packages_services
node_packages_services -->|"reads/writes"| node_models
node_models -->|"uses"| node_db_runtime
node_db_runtime -->|"targets"| node_db_schema
node_packages_services -->|"orchestrates"| node_pipeline_runner
node_pipeline_runner -->|"executes"| node_pipeline_engine
node_pipeline_runner -->|"invokes"| node_agent_runtime
node_agent_runtime -->|"wraps"| node_agent_engine
node_pipeline_engine -->|"dispatches"| node_plugins
node_plugins -->|"extends"| node_pipeline_engine
node_apps_app -->|"shares types"| node_schemas
node_apps_server -->|"validates"| node_schemas
node_packages_services -->|"enforces"| node_schemas
node_apps_app -->|"renders"| node_ui
node_apps_app -->|"uses"| node_utils
node_apps_app -.->|"same domain"| node_cli
node_cli -->|"connects to"| node_apps_server
node_scripts -->|"seeds via"| node_models
node_scripts -.->|"migrates content"| node_db_schema
node_docs -.->|"documents"| node_schemas

click node_apps_app "https://github.com/forge-town/ordine/tree/main/apps/app"
click node_apps_server "https://github.com/forge-town/ordine/tree/main/apps/server"
click node_packages_services "https://github.com/forge-town/ordine/tree/main/packages/services"
click node_pipeline_runner "https://github.com/forge-town/ordine/tree/main/packages/services/src/pipelineRunnerService"
click node_pipeline_engine "https://github.com/forge-town/ordine/tree/main/packages/pipeline-engine"
click node_agent_runtime "https://github.com/forge-town/ordine/tree/main/packages/agent"
click node_agent_engine "https://github.com/forge-town/ordine/tree/main/packages/agent-engine"
click node_plugins "https://github.com/forge-town/ordine/tree/main/packages/plugins"
click node_db_schema "https://github.com/forge-town/ordine/tree/main/packages/db-schema"
click node_db_runtime "https://github.com/forge-town/ordine/tree/main/packages/db"
click node_models "https://github.com/forge-town/ordine/tree/main/packages/models"
click node_schemas "https://github.com/forge-town/ordine/tree/main/packages/schemas"
click node_ui "https://github.com/forge-town/ordine/tree/main/packages/ui"
click node_utils "https://github.com/forge-town/ordine/tree/main/packages/utils"
click node_docs "https://github.com/forge-town/ordine/tree/main/apps/docs"
click node_scripts "https://github.com/forge-town/ordine/tree/main/apps/scripts"
click node_cli "https://github.com/forge-town/ordine/tree/main/apps/cli"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_apps_app,node_cli toneBlue
class node_apps_server,node_packages_services toneAmber
class node_db_schema,node_db_runtime,node_models toneMint
class node_pipeline_runner,node_pipeline_engine,node_agent_runtime,node_agent_engine,node_plugins toneRose
class node_docs,node_scripts toneIndigo
class node_schemas,node_ui,node_utils toneTeal
```

## Components

### Apps

User-facing and operational entry points.

- [App UI](https://github.com/forge-town/ordine/tree/main/apps/app): React app · Primary user-facing application with feature pages, canvas authoring, and client-side data fetching. · `apps/app`
- [CLI](https://github.com/forge-town/ordine/tree/main/apps/cli): command line · Command-line entry point for local automation and daemon-style interaction. · `apps/cli`

### Backend

API, services, and execution runtime.

- [API Server](https://github.com/forge-town/ordine/tree/main/apps/server): Bun API · Backend API exposing tRPC and REST routes for domain operations and external clients. · `apps/server`
- [Services](https://github.com/forge-town/ordine/tree/main/packages/services): domain services · Business logic layer coordinating validation, workflows, and orchestration before persistence or execution. · `packages/services`

### Data

Schema, DB access, and persistence models.

- [DB Schema](https://github.com/forge-town/ordine/tree/main/packages/db-schema): Drizzle schema · Relational table definitions and relations for domain entities and execution records. · `packages/db-schema`
- [DB Runtime](https://github.com/forge-town/ordine/tree/main/packages/db): database runtime · Database connection and environment integration used by persistence code. · `packages/db`
- [Models](https://github.com/forge-town/ordine/tree/main/packages/models): DAOs · 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](https://github.com/forge-town/ordine/tree/main/packages/services/src/pipelineRunnerService): orchestration · Glue that turns pipeline definitions into executions via prompt handling, skill execution, loop evaluation, and structured output. · `packages/services/src/pipelineRunnerService`
- [Pipeline Engine](https://github.com/forge-town/ordine/tree/main/packages/pipeline-engine): DAG runtime · Core graph engine for pipeline validation, scheduling, node behavior, and execution semantics. · `packages/pipeline-engine`
- [Agent Runtime](https://github.com/forge-town/ordine/tree/main/packages/agent): AI execution · Agent abstractions and provider runners for Claude, Codex, scanning, and higher-level agent execution. · `packages/agent`
- [Agent Engine](https://github.com/forge-town/ordine/tree/main/packages/agent-engine): agent orchestration · Higher-level abstraction for executing agent workflows. · `packages/agent-engine`
- [Plugins](https://github.com/forge-town/ordine/tree/main/packages/plugins): extension layer · Plugin interfaces and built-in extensions such as the GitHub project plugin. · `packages/plugins`

### Content

Docs, skills, and bootstrapping artifacts.

- [Docs](https://github.com/forge-town/ordine/tree/main/apps/docs): VitePress site · Public documentation and guides for APIs, skills, and product concepts. · `apps/docs`
- [Scripts](https://github.com/forge-town/ordine/tree/main/apps/scripts): seed tools · Content generation, migration, and seeding scripts for product domain data. · `apps/scripts`

### Shared

Reusable UI, schemas, and utilities.

- [Schemas](https://github.com/forge-town/ordine/tree/main/packages/schemas): shared validation · Common Zod schemas for jobs, pipelines, operations, rules, skills, settings, spans, and agent/runtime data. · `packages/schemas`
- [UI Kit](https://github.com/forge-town/ordine/tree/main/packages/ui): component library · Reusable design system and component primitives shared by the app and other frontends. · `packages/ui`
- [Utils](https://github.com/forge-town/ordine/tree/main/packages/utils): helpers · Shared utility helpers, including filesystem support. · `packages/utils`

## Connections

- 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.
