How tom-hoinacki/longevity-intelligence works
Purpose and Shape
Longevity Intelligence is a structured, source-backed longevity evidence platform: asset → claim → scientific source → evidence → score/verdict. It is a .NET backend with a separate TypeScript web shell, using Supabase-hosted PostgreSQL as the schema source of truth. Core solution: Longevity.sln, src/Longevity.Api/Program.cs, supabase/migrations/.
Entry Points and Runtime Composition
The ASP.NET Core API bootstraps dependency injection, HTTP endpoints, diagnostics, persistence, model providers, and a workflow background service in src/Longevity.Api/Program.cs and src/Longevity.Api/DependencyInjection/ServiceCollectionExtensions.cs. It exposes public evidence and human-review API surfaces through src/Longevity.Api/PublicEvidence/PublicEvidenceEndpoints.cs and src/Longevity.Api/HumanReview/HumanReviewEndpoints.cs. The frontend is a Vite/React TypeScript application entered at src/Longevity.Web/src/main.tsx; its current role appears to be a basic UI shell.
Layered Backend Boundary
The code follows a Domain / Application / Infrastructure / API separation. Workflow state and identifiers are domain-owned in src/Longevity.Domain/Workflow/WorkflowState.cs and src/Longevity.Domain/Workflow/WorkflowIdentifiers.cs. Application code defines contracts and use cases, isolating business flows from transport and provider implementations: src/Longevity.Application/Contracts/IWorkflowRunProcessor.cs, src/Longevity.Application/Contracts/IClaimExtractionModel.cs, and src/Longevity.Application/Contracts/IWorkflowRunRepository.cs. Infrastructure supplies PostgreSQL and OpenRouter implementations.
Workflow Orchestration
A hosted worker polls/processes workflow runs via src/Longevity.Api/Workflow/WorkflowOrchestratorBackgroundService.cs, delegating lifecycle coordination to src/Longevity.Application/Orchestration/WorkflowRunProcessor.cs. Phases are explicit: extraction in src/Longevity.Application/Orchestration/ExtractingWorkflowRunPhaseHandler.cs, deterministic validation in src/Longevity.Application/Orchestration/ValidatingWorkflowRunPhaseHandler.cs, and publication in src/Longevity.Application/Publishing/PublishingWorkflowRunPhaseHandler.cs. State transitions are controlled by domain workflow state, rather than endpoint request lifetimes.
AI Extraction and Source Processing
Claim extraction is provider-abstracted by application contracts and implemented through OpenRouter in src/Longevity.Infrastructure/ModelProviders/OpenRouter/OpenRouterClaimExtractionModel.cs. Extracted candidates are persisted under policies intended to preserve workflow semantics: src/Longevity.Infrastructure/Persistence/PostgresClaimExtractionPersistence.cs and src/Longevity.Infrastructure/Persistence/ClaimExtractionPersistencePolicy.cs. Scientific inputs are normalized before downstream use by src/Longevity.Application/SourceNormalization/ScientificSourceNormalization.cs.
Evidence, Review, and Publication
Evidence scoring is deterministic application logic, centered on src/Longevity.Application/EvidenceScoring/EvidenceScoringEngine.cs and src/Longevity.Application/EvidenceScoring/ClaimEvidenceAggregator.cs. Human decisions form a boundary before approval/publication, handled in src/Longevity.Application/HumanReview/HumanReviewService.cs with PostgreSQL persistence in src/Longevity.Infrastructure/Persistence/PostgresHumanReviewPersistence.cs. Published/public-facing reads use a catalog abstraction, backed by src/Longevity.Infrastructure/PublicEvidence/PostgresPublicEvidenceCatalog.cs (with a demo alternative).
Data and External Infrastructure
Supabase PostgreSQL holds the evidence registry and workflow schema, defined incrementally in supabase/migrations/20260711000000_claim_evidence_registry.sql and supabase/migrations/20260711140000_workflow_schema_v1.sql. Later migrations enforce workflow/source and human-decision integrity. API persistence is configured through src/Longevity.Infrastructure/Persistence/PostgresServiceCollectionExtensions.cs and src/Longevity.Infrastructure/Persistence/PostgresWorkflowRunRepository.cs. OpenRouter is the external LLM service; its configuration and registration live in src/Longevity.Infrastructure/ModelProviders/OpenRouter/OpenRouterClaimExtractionServiceCollectionExtensions.cs.
Main entry points: WorkflowRunProcessor.cs Workflow processor · Program.cs API bootstrap · 20260711140000_workflow_schema_v1.sql Supabase PostgreSQL · ExtractingWorkflowRunPhaseHandler.cs Extraction phase
Components 20
Web client
- React web shell · Basic UI shell.
src/Longevity.Web/src/main.tsx
API runtime
- API bootstrap · Registers endpoints, providers, persistence, diagnostics, and worker.
src/Longevity.Api/Program.cs - Service registration
src/Longevity.Api/DependencyInjection/ServiceCollectionExtensions.cs - Public evidence API
src/Longevity.Api/PublicEvidence/PublicEvidenceEndpoints.cs - Human review API
src/Longevity.Api/HumanReview/HumanReviewEndpoints.cs - Workflow worker · Polls and processes workflow runs outside request lifetimes.
src/Longevity.Api/Workflow/WorkflowOrchestratorBackgroundService.cs
Application core
- Workflow state · Owns workflow states and identifiers.
src/Longevity.Domain/Workflow/WorkflowState.cs - Workflow processor · Coordinates lifecycle phases through application contracts.
src/Longevity.Application/Orchestration/WorkflowRunProcessor.cs - Extraction phase
src/Longevity.Application/Orchestration/ExtractingWorkflowRunPhaseHandler.cs - Validation phase · Performs deterministic validation.
src/Longevity.Application/Orchestration/ValidatingWorkflowRunPhaseHandler.cs - Source normalization
src/Longevity.Application/SourceNormalization/ScientificSourceNormalization.cs - Evidence scoring
src/Longevity.Application/EvidenceScoring/EvidenceScoringEngine.cs - Human review service · Decision boundary before approval and publication.
src/Longevity.Application/HumanReview/HumanReviewService.cs - Publication phase
src/Longevity.Application/Publishing/PublishingWorkflowRunPhaseHandler.cs
Infrastructure
- OpenRouter extraction
src/Longevity.Infrastructure/ModelProviders/OpenRouter/OpenRouterClaimExtractionModel.cs - Claim extraction persistence · Persists candidates under workflow-preserving policies.
src/Longevity.Infrastructure/Persistence/PostgresClaimExtractionPersistence.cs - Workflow repository
src/Longevity.Infrastructure/Persistence/PostgresWorkflowRunRepository.cs - Human review persistence
src/Longevity.Infrastructure/Persistence/PostgresHumanReviewPersistence.cs - Public evidence catalog
src/Longevity.Infrastructure/PublicEvidence/PostgresPublicEvidenceCatalog.cs - Supabase PostgreSQL · Schema source of truth.
supabase/migrations/20260711140000_workflow_schema_v1.sql
Connections 25
- React web shell → API bootstrap: HTTP
- API bootstrap → Service registration: configures
- API bootstrap → Public evidence API: maps
- API bootstrap → Human review API: maps
- API bootstrap → Workflow worker: hosts
- Workflow worker → Workflow processor: processes runs
- Workflow processor → Workflow state: applies transitions
- Workflow processor → Workflow repository: loads and updates runs
- Workflow processor → Extraction phase: runs
- Workflow processor → Validation phase: runs
- Workflow processor → Publication phase: runs
- Extraction phase → OpenRouter extraction: extracts claims
- Extraction phase → Claim extraction persistence: persists candidates
- Validation phase → Source normalization: normalizes sources
- Validation phase → Evidence scoring: scores evidence
- Human review API → Human review service: submits decisions
- Human review service → Human review persistence: stores decisions
- Human review service → Publication phase: approves publication
- Publication phase → Public evidence catalog: publishes evidence
- Public evidence API → Public evidence catalog: reads catalog
- Workflow repository → Supabase PostgreSQL: workflow data
- Claim extraction persistence → Supabase PostgreSQL: claims and sources
- Human review persistence → Supabase PostgreSQL: decisions
- Public evidence catalog → Supabase PostgreSQL: published evidence
- OpenRouter extraction → Supabase PostgreSQL: no direct access