How healers-second-look/athena works
Purpose and Entry Points
Athena/SecondLook is an evidence-grounded oncology decision-support engine: it stores evolving patient cases, retrieves cited cancer evidence, synthesizes answers, and exposes clinical-data views. Primary runtime entry points are the FastAPI service at src/secondlook/api/__main__.py, read-only MCP service at src/secondlook/mcp_server/__main__.py, and React client at web/src/main.jsx. The legacy structural-biology orchestrator is src/secondlook/pipeline.py.
Case Memory and Read Model
Append-only case events are the clinical system of record; findings and changes are derived by folding event history rather than mutating prior events. Persistence, state transitions, evidence state, invalidation diffs, and alerts are centered in src/secondlook/case/store.py, src/secondlook/case/state.py, and src/secondlook/case/evidence_diff.py. A dedicated query layer supplies case summaries, findings, queues, research, and trial-access views to transport adapters: src/secondlook/query/contracts.py, src/secondlook/query/case_summary.py, src/secondlook/query/evidence_search.py.
Evidence Graph Ingestion and Retrieval
Tier 1 loads CIViC, PubMed, ClinicalTrials.gov, guidelines, and regional access pathways into/queryable through FalkorDB. Graph shape and connection boundaries reside in src/secondlook/tier1/graph_schema.py and src/secondlook/tier1/graph_connection.py; source ingestion is represented by src/secondlook/tier1/civic_loader.py, src/secondlook/tier1/pubmed_loader.py, and src/secondlook/tier1/ctgov_loader.py. Retrieval combines exact/relaxed graph lookup and semantic search in src/secondlook/tier1/retrieval.py and src/secondlook/tier1/semantic_retrieval.py; cited-source eligibility is a key evidence boundary.
Signals, Trials, and Access
The target architecture is converging sources into typed signals rather than treating structural prediction solely as a fallback. Signal generators cover genomics, literature, pharmacology, trials, and matching in src/secondlook/signals/genomics.py, src/secondlook/signals/trial_matching.py, and src/secondlook/signals/registry.py. Access-pathway registry data is maintained under access_pathways/us.yaml and access_pathways/india.yaml, queried through src/secondlook/tier1/access_pathway_query.py.
Synthesis, Chat, and Intake
Chat retrieves evidence, separates it from plugin annotations, constructs prompts, and invokes interchangeable offline, hosted, or OpenAI-compatible model clients. This boundary is implemented by src/secondlook/chat/engine.py, src/secondlook/chat/knowledge.py, and src/secondlook/synthesis/llm_client.py; citation-gated generation is in src/secondlook/synthesis/citation_gate.py. Intake converts documents to human-confirmable case events via src/secondlook/intake/extraction.py.
Delivery Surfaces and Infrastructure
FastAPI routes expose cases, findings, chat, and timeline through src/secondlook/api/app.py, src/secondlook/api/routes/cases.py, and src/secondlook/api/routes/chat.py. The frontend’s principal workflows are case dashboard, research queue, chat, and timeline at web/src/routes/CaseDashboard.jsx, web/src/routes/ResearchQueue.jsx, and web/src/routes/ChatInterface.jsx. Docker Compose provisions the API, web client, FalkorDB graph, and case database via docker-compose.yml; SQLAlchemy/Alembic schema evolution begins at migrations/versions/0001_initial_case_schema.py. MCP exposes read-only case/evidence/trial/access tools from src/secondlook/mcp_server/tools.py.
Structural-Biology Path and Constraints
When used, the older Tier 2 path validates mutations, resolves structures, discovers drugs, and evaluates noncovalent binding candidates. Core stages are src/secondlook/mutation_validation.py, src/secondlook/structure.py, src/secondlook/candidates.py, and src/secondlook/binding.py; external sources include UniProt, RCSB, AlphaFold, ESM Atlas, AlphaMissense, DGIdb, Open Targets, ChEMBL, mCSM-lig, and Vina. This path is explicitly not validated as a clinical prediction claim and is being demoted/re-wired into the signal-graph direction.
Main entry points: registry.py Typed signal registry · app.py Case and chat routes · store.py Append-only case store · graph_connection.py FalkorDB
Components 20
Delivery surfaces
- React client
web/src/main.jsx - FastAPI service
src/secondlook/api/__main__.py - Read-only MCP service
src/secondlook/mcp_server/__main__.py - Case and chat routes
src/secondlook/api/app.py
Case memory
- Append-only case store · Persists events, evidence state, transitions, diffs, and alerts.
src/secondlook/case/store.py - Folded case state · Findings and changes are derived from event history.
src/secondlook/case/state.py - Case query layer · Serves summaries, findings, queues, research, and trial access.
src/secondlook/query/contracts.py - Case database · Schema evolution begins in Alembic.
migrations/versions/0001_initial_case_schema.py - Document intake · Converts documents into human-confirmable case events.
src/secondlook/intake/extraction.py
Evidence graph
- Evidence graph schema
src/secondlook/tier1/graph_schema.py - Tier 1 source ingestion · Loads CIViC, PubMed, and ClinicalTrials.gov evidence.
src/secondlook/tier1/civic_loader.py - FalkorDB
src/secondlook/tier1/graph_connection.py - Evidence retrieval · Combines exact, relaxed, and semantic lookup with cited-source eligibility.
src/secondlook/tier1/retrieval.py - Access pathway lookup · Queries regional access pathways.
src/secondlook/tier1/access_pathway_query.py
Signals and synthesis
- Typed signal registry · Converges genomic, literature, pharmacology, trial, and matching signals.
src/secondlook/signals/registry.py - Chat engine · Separates retrieved evidence from plugin annotations.
src/secondlook/chat/engine.py - Citation gate · Gates synthesized output on citations.
src/secondlook/synthesis/citation_gate.py - Interchangeable LLM clients · Supports offline, hosted, and OpenAI-compatible clients.
src/secondlook/synthesis/llm_client.py
Legacy Tier 2
Demoted structural-biology path.
- Structural-biology pipeline · Validates mutations, resolves structures, finds drugs, and evaluates binding candidates.
src/secondlook/pipeline.py - Structural data sources · Includes protein, structure, variant, drug, and docking sources.
Connections 23
- React client → FastAPI service: clinical workflows
- FastAPI service → Case and chat routes: routes requests
- Read-only MCP service → Case query layer: read-only tools
- Case and chat routes → Append-only case store: writes events
- Case and chat routes → Case query layer: reads views
- Case and chat routes → Chat engine: chat requests
- Document intake → Append-only case store: confirmable events
- Append-only case store → Case database: persists
- Append-only case store → Folded case state: folds history
- Folded case state → Case query layer: derived findings
- Tier 1 source ingestion → FalkorDB: loads evidence
- Evidence graph schema → FalkorDB: defines graph
- FalkorDB → Evidence retrieval: graph lookup
- Access pathway lookup → FalkorDB: access evidence
- Evidence retrieval → Typed signal registry: cited evidence
- Access pathway lookup → Typed signal registry: regional access
- Folded case state → Typed signal registry: case context
- Evidence retrieval → Chat engine: retrieved sources
- Typed signal registry → Chat engine: plugin annotations
- Chat engine → Citation gate: draft answer
- Citation gate → Interchangeable LLM clients: citation-gated prompt
- Structural data sources → Structural-biology pipeline: protein, drug, docking data
- Structural-biology pipeline → Typed signal registry: rewired as signals