High-level architecture of the Shep AI CLI platform.
flowchart LR
subgraph Users[" "]
User(["User"])
end
subgraph UI["Presentation"]
direction TB
CLI[CLI]
WebUI[Web UI]
TUI[TUI]
end
subgraph Core["Shep AI Core"]
direction TB
App["<b>Application</b><br/>Use Cases and Ports"]
Dom["<b>Domain</b><br/>Feature, Task, Artifact"]
Infra["<b>Infrastructure</b><br/>Repos, Agents, FS"]
end
subgraph Ext["External"]
direction TB
FS[("~/.shep/")]
DB[("SQLite")]
AI[("AI Agents")]
end
User --> UI
UI --> App
App --> Dom
Dom --> Infra
Infra --> Ext
style User fill:#f8fafc,stroke:#64748b,color:#1e293b
style CLI fill:#dbeafe,stroke:#3b82f6,color:#1e3a5f
style WebUI fill:#dbeafe,stroke:#3b82f6,color:#1e3a5f
style TUI fill:#dbeafe,stroke:#3b82f6,color:#1e3a5f
style UI fill:#dbeafe,stroke:#3b82f6,color:#1e3a5f
style App fill:#fef3c7,stroke:#f59e0b,color:#78350f
style Dom fill:#d1fae5,stroke:#10b981,color:#064e3b
style Infra fill:#ede9fe,stroke:#8b5cf6,color:#4c1d95
style Core fill:#f8fafc,stroke:#94a3b8,color:#1e293b
style FS fill:#f1f5f9,stroke:#64748b,color:#374151
style DB fill:#f1f5f9,stroke:#64748b,color:#374151
style AI fill:#f1f5f9,stroke:#64748b,color:#374151
style Ext fill:#f1f5f9,stroke:#64748b,color:#1e293b
Entry points for user interaction:
| Component | Technology | Purpose |
|---|---|---|
| CLI | Commander | Command-line interface (shep commands) |
| TUI | @inquirer/prompts | Interactive terminal prompts for wizards (select, confirm, input, password) |
| Web UI | Next.js + shadcn/ui | Browser-based interface at localhost:4050 |
All presentation components use the Application layer - they never directly access Domain or Infrastructure.
Orchestrates business operations through Use Cases and defines output port interfaces:
Repositories (in packages/core/src/application/ports/output/repositories/):
IFeatureRepository – Feature CRUD with slug lookup, prefix search, parent/child hierarchyISettingsRepository – Singleton settings persistence (initialize, load, update)IRepositoryRepository – Repository entity management with soft deleteAgent Ports (in packages/core/src/application/ports/output/agents/):
IAgentExecutor – Execute prompts against AI coding agentsIAgentExecutorFactory – Create executors for agent typesIAgentExecutorProvider – Resolve current executor from settingsIAgentRegistry – Register and discover agent definitionsIAgentRunner – Run agent workflows with lifecycle managementIAgentRunRepository – Persist agent run recordsIAgentValidator – Validate agent tool availabilityIFeatureAgentProcessService – Manage background agent processesIStructuredAgentCaller – Make typed calls to agentsIPhaseTimingRepository – Track SDLC phase durationsIAgentSessionRepository – Manage agent sessionsService Ports (in packages/core/src/application/ports/output/services/):
IDaemonService, IDeploymentService, IGitPrService, IIdeLauncherServiceINotificationService, ISpecInitializer, IToolInstallerServiceIVersionService, IWebServerService, IWorktreeServiceIExternalIssueFetcherPure business logic with no external dependencies. Domain types are generated from TypeSpec definitions:
tsp/ directory (TypeSpec files)packages/core/src/domain/generated/output.tsExternal concerns implementation:
sqlite-feature.repository.ts, sqlite-settings.repository.ts, sqlite-repository.repository.ts, agent-run.repository.ts, sqlite-phase-timing.repository.ts)Started --> Analyze --> Requirements --> Research --> Planning --> Implementation --> Review --> Maintain
|
(Blocked possible
from any phase)
~/.shep/
+-- data # SQLite database (global settings)
+-- repos/
+-- <base64-encoded-repo-path>/
+-- data # SQLite database file (features, agent_runs, etc.)
+-- docs/ # Repository analysis documents
+-- artifacts/ # Generated feature artifacts
| Table | Purpose |
|---|---|
settings |
Singleton global settings (model config, user profile, agent config, notifications, workflow, feature flags) |
features |
Feature entities with full lifecycle tracking, PR data, approval gates, worktree paths |
agent_runs |
Agent execution records with status, timing, approval gates |
phase_timings |
SDLC phase duration tracking per agent run |
repositories |
Tracked code repositories with soft delete support |
| Concern | Choice | Rationale |
|---|---|---|
| Language | TypeScript | Type safety, ecosystem, developer experience |
| Package Manager | pnpm | Fast, disk efficient, strict by default |
| CLI Framework | Commander | Mature, well-documented, standard |
| TUI Framework | @inquirer/prompts | Interactive prompts (select, confirm, input, password), TypeScript-native, ESM |
| Web Framework | Next.js 16+ | App Router, Server Components, built-in optimizations |
| UI Components | shadcn/ui | Radix primitives + Tailwind, accessible, customizable |
| Design System | Storybook | Component documentation, visual testing, design tokens |
| Build Tool | tsc + tsc-alias | Standard TypeScript compilation with path alias resolution |
| Database | SQLite | Zero setup, portable, sufficient for local use (via better-sqlite3) |
| Agent Pattern | LangGraph | State-based workflow orchestration with typed graphs |
| Unit Testing | Vitest | Fast, ESM-native, Vite-compatible |
| E2E Testing | Playwright | Cross-browser, reliable, great DX |
| Methodology | TDD | Red-Green-Refactor, confidence, design quality |
| DI Container | tsyringe | Lightweight IoC container with decorator support |
| Domain Models | TypeSpec | Single source of truth, generates TypeScript types |
Update when:
Keep current: