Context/Architecture-Overview.md
Archived 2026-04-14 — This document describes the v1 architecture (ModuleInterface pattern) which has been fully removed. The current architecture is documented in Architecture/unified-module-architecture.md.
created: 2026-04-08 updated: 2026-04-08 type: context project: PRISM tags: [prism, architecture, context]
PRISM Architecture Overview
Quick-reference architecture context for Claude Code sessions working on PRISM.
What PRISM Is
PRISM (Prospect Intelligence Platform) is an AI-powered system that takes a single domain name and produces consulting-grade competitive intelligence for Algolia sales. It is the SaaS evolution of the Algolia Search Audit skills.
One domain in. 20 modules execute. Scored audit, sales plays, campaign templates, and a factchecked report come out.
Technology Stack
| Layer | Technology |
|---|---|
| Backend | Python 3.12+, FastAPI, async SQLAlchemy |
| Orchestration | Temporal.io (Python SDK) |
| Database | PostgreSQL 16 (asyncpg driver) |
| Cache | Redis 7 (SSE pub/sub + response cache) |
| LLM | Multi-provider: Anthropic Claude, Google Gemini, OpenAI, OpenRouter |
| LLM Structuring | Instructor library (Pydantic auto-validation + retry) |
| Frontend | Next.js 15, React 19, Tailwind CSS v4, shadcn/ui, Zustand, Vercel AI SDK |
| Auth | Clerk.js |
6-Wave Execution Model
Wave 1: Intelligence Collection (13 modules, parallel, ~15 min)
Gate: intel-company must succeed or audit aborts
Wave 2: Browser Testing (1 module, Playwright, ~10 min, non-fatal)
Wave 3: Factcheck (1 module, child workflow, GAN-inspired)
Wave 4: Insights (1 module, fire-and-forget, benchmarking)
Wave 5: Synthesis (3 modules, parallel, ~15 min)
Wave 6: Final Report (1 module, ~20 min)
Audit modes: full, quick, bulk_triage, refresh.
Module Architecture
Every module implements ModuleInterface with 3 methods:
- execute(context) -> ModuleResult
- validate(result) -> ValidationResult
- health_check() -> bool
Every module follows the file structure:
modules/{module_name}/
schemas.py -- Pydantic input/output models
collector.py -- External API data collection
enricher.py -- LLM structuring (or parser.py if deterministic)
validator.py -- 8-10 quality checks
module.py -- ModuleInterface implementation + registration
Database Schema (10 tables)
Core: accounts, audits, module_executions, deliverables, vertical_benchmarks Evidence: algolia_customers (2,013), algolia_case_studies (154), algolia_quotes (352), algolia_proofpoints (81), algolia_advocates (268)
API Endpoints
| Route | Purpose |
|---|---|
| POST /api/v1/audits/ | Start new audit (triggers Temporal workflow) |
| GET /api/v1/audits/{id} | Get audit status + results |
| GET /api/v1/audits/{id}/stream | SSE real-time progress |
| GET /api/v1/accounts/ | List all accounts |
| GET /api/v1/accounts/{domain}/freshness | Check module staleness |
| POST /api/v1/modules/{name}/execute | Execute single module |
| GET /api/v1/evidence/* | Query Algolia customer evidence DB |
| GET /health | Liveness check |
External APIs
| API | Used By | Cost |
|---|---|---|
| Perplexity (sonar/sonar-pro) | 8 intel modules | $0.25-3/M tokens |
| BuiltWith | intel-techstack | API key tier |
| SimilarWeb | intel-traffic | API key tier |
| Yahoo Finance (yfinance) | intel-financial-public | Free |
| SEC EDGAR | intel-financial-public, intel-investor | Free |
| Apify | intel-hiring, intel-social | Credits |
| Crossbeam | intel-partner | Deferred (Perplexity fallback) |
Compliance Status (vs Vault Standards)
As of 2026-04-08. See Compliance-Assessment for details.
- CodingSOPs: Mostly compliant. Gap: no adapter pattern (DI), function length.
- TestingSOPs: Partial. Gap: no TDD, no adapter-based mocks, flat test structure.
- FolderStructure: Non-compliant (expected debt, predates standard).
- Manifesto: Core spirit compliant. Gap: no shared-py, no persist(), dict output.
Related
- Compliance-Assessment
- Module-Catalog
- Patterns-For-Skills
- Manifesto
- Module-Spec-Template