Alavida Platform Architecture
13 knowledge files · 22 platform decisions · 23 mesh decisions · 6 quantums
The Platform domain is the engineering backbone of Alavida. It decides how software gets built, maintains architecture standards, provides skill authoring guides, and owns the external repos where code ships. Two parallel tracks converge on shared infrastructure: a GTM workflow registry (5 phases, consumer-facing) and an agentic mesh (4 phases, internal-only).
Three runtimes serve different purposes, connected by the Inngest event bus. Railway hosts compute, n8n bridges the external world, and Inngest provides durable event-driven execution with step-level fault tolerance.
public (platform), buying_signals, x_scraper, identity. No cross-schema foreign keys. Application-level referential integrity.
Six quantums across two domains. Each satisfies the quantum contract: /run, /health, /data endpoints, Inngest events, and a consumer skill published to the registry. Identity deploys first (deterministic, no LLM), proving the pattern for everything that follows.
| Quantum | Type | Domain | Runtime | Phase | Status |
|---|---|---|---|---|---|
| identity | deterministic | Platform | Railway | 1 | Deployed |
| buying-signals | agentic | Prospect-discovery | Railway + Langfuse | 1 | Pending refactor |
| icp-discovery | agentic | Prospect-discovery | Railway + Langfuse | 2 | Pending refactor |
| lead-discovery | agentic | Prospect-discovery | Railway + Langfuse | 2 | Pending refactor |
| meeting-sync | connector | Operations | n8n (Mode 2) | 3 | Not started |
| meeting-analysis | agentic | Operations | Railway + Langfuse | 3 | Not started |
Quantum Contract (required endpoints)
POST /run/{action}— async job acceptance, returnsjob_id+trace_idGET /health— standard health check with quantum name, version, timestampGET /data/{entity}— REST endpoints scoped to polyseme UUIDsEvents via Inngest— cross-quantum events following{domain}/{entity}.{action}Consumer skill— data contract published to the registry
Events flow across quantums through Inngest, carrying trace_id and polyseme UUIDs. The prospect scoring pipeline cascades through three quantums. Phase 3 adds cross-domain flow from operations into prospect-discovery.
graph LR
subgraph OPS["Operations Domain"]
MS["meeting-sync
(n8n)"]
MA["meeting-analysis"]
end
subgraph PD["Prospect-Discovery Domain"]
ICP["icp-discovery"]
LD["lead-discovery"]
BS["buying-signals"]
end
subgraph PLAT["Platform Domain"]
ID["identity"]
end
MS -->|"meeting/transcript.added"| MA
MA -->|"meeting/company.mentioned"| ICP
ICP -->|"icp/company.qualified"| LD
LD -->|"lead/company.completed"| BS
BS -->|"signal/company.scored"| OUT["Future consumers"]
ICP -.->|"resolve-company"| ID
LD -.->|"resolve-person"| ID
MA -.->|"resolve entities"| ID
icp/company.qualified events. Inngest invokes lead-discovery 30 times with concurrency limits. Each completed company triggers buying-signals independently. No central orchestrator — Observer + Listener pattern.
Single Neon PostgreSQL with schema-per-component isolation. The platform owns public (users, teams, credits, jobs, registry). Components own their schemas with no cross-schema FK constraints. Polysemes (company, person) are resolved through the identity quantum.
erDiagram
USERS ||--o{ TEAM_MEMBERS : belongs
TEAMS ||--o{ TEAM_MEMBERS : has
TEAMS ||--|| CREDIT_ACCOUNTS : "1:1 billing"
TEAMS ||--o{ JOBS : creates
TEAMS ||--o{ API_KEYS : owns
USERS ||--o{ JOBS : submits
JOBS ||--o| CREDIT_USAGE : charges
TEAMS ||--o{ CREDIT_PURCHASES : buys
USERS {
uuid id PK
text email
text name
}
TEAMS {
uuid id PK
text name
text stripe_customer_id
}
JOBS {
uuid id PK
text component_slug
text status
jsonb result_payload
jsonb usage_metrics
}
CREDIT_ACCOUNTS {
uuid team_id PK
int balance
int lifetime_used
}
polyseme_company_id and polyseme_person_id columns (nullable UUID) in every quantum's schema. Forward-only migration — new records get UUIDs, old stay NULL.
preview/pr-{n}). Point-in-time restore for rollback. Each component owns its own migrations independently.
Four phases, each proving a specific capability. Strict dependency ordering — each phase validates the pattern before the next adds complexity. 23 architecture decisions total. 12 features explicitly deferred.
6 decisions
5 decisions
7 decisions
5 decisions
Registry Platform Phases (parallel track, 5 phases)
A GTM workflow registry inspired by shadcn-ui — npx alavida add buying-signals. Components are living services, not static code. The platform manages execution, billing, API keys, updates, and data persistence. Three interfaces to the same backend: CLI, MCP, and Dashboard.
reads SKILL.md
job create, route
Agent SDK pipelines
Credit deduction
alavida auth, add, jobs, credits. Commander.js, native fetch. Published as @alavida/cli.search_registry, install_component.
Four observability concerns, each with its own tooling. The critical requirement: LLM tracing tool's trace_id MUST equal the event trace_id for seamless cross-system navigation.
trace_id is generated at flow entry (Platform generates job_id = trace_id, or n8n generates UUID). Each quantum creates its own span_id. Fan-out shares trace_id across all parallel branches.
Workbenches are persona-scoped environments (skills, hooks, settings) that give different roles the right surface area. The dev workbench implements compound engineering: Plan → Work → Review → Compound. Two skill templates: CLI/API (13 sections) and knowledge processing (8 sections).
/platform:compound— workspace-aware engineering loopagent-sdk-automations— 10 Agent SDK patternsinngest-workflow— durable workflow patternsrailway-deployment— deployment patterns
- Marketplace —
.claude-plugin/marketplace.jsonlists all available workbenches - Activation —
.claude/settings.jsoncontrols which are enabled - Implementation —
domains/*/workbenches/{type}/{name}/packages
All 13 knowledge files in domains/platform/knowledge/ and when to consult each one.
| File | Covers | Confidence | Go here when |
|---|---|---|---|
registry-platform-architecture |
22 decisions, system topology, API routes | medium | Making infrastructure choices, reviewing design |
v4-release-plan |
4 phases, 6 quantums, 23 decisions | high | Understanding mesh roadmap, in/out of scope |
quantum-catalog |
Per-quantum specs, endpoints, events | high | Understanding what a quantum does |
quantum-event-map |
Event chains, fan-out, naming migration | high | Designing event subscriptions, tracing flows |
infrastructure-topology |
3 runtimes, n8n modes, quantum template | high | Deploying a new quantum |
component-patterns |
Contract, taxonomy, pipeline arch | medium | Building or modifying a component |
database-design |
Schemas, migration strategy, Neon branching | medium | Designing schema changes |
observability-architecture |
LLM tracing, dashboards, structlog | medium | Instrumenting a quantum |
implementation-phases |
5-phase registry build plan, 113 stories | medium | Planning platform work, checking progress |
existing-systems |
Monorepo + prospect-engine architecture | medium | Working with legacy, planning extraction |
workbench-architecture |
Folder structure, discovery model, plugins | high | Building a workbench, plugin discovery |
skill-authoring-guide |
SKILL.md structure, config patterns, CLI | medium | Creating a new skill |
user-workflows |
3 personas, 25 stories, 9 functional areas | medium | Understanding user needs, validating scope |
domains/platform/CLAUDE.md before accessing knowledge files. The domain CLAUDE.md is the interface — it defines boundaries, dependencies, and freshness policies. Never jump directly to knowledge files.