# sonyresearch/hakkenoss architecture

> Architecture diagram of the GitHub repository sonyresearch/hakkenoss, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sonyresearch/hakkenoss
- Repository: https://github.com/sonyresearch/hakkenoss

## Overview

HakkenOSS is a scientific knowledge-graph platform: biomedical data is processed into a graph, models support reasoning and candidate generation, and users query and explore results through a web interface. The README documents contextualisation and document/entity-resolution agents as additional capabilities. The graph preserves those branches, but most implementation links are documented at platform level; sampled excerpts provide more specific evidence for explanation requests and agent vector-storage operations.

Main entry points: [`ui/frontend/src/features/CandidateDashboard/types.ts`](https://github.com/sonyresearch/hakkenoss/blob/main/ui/frontend/src/features/CandidateDashboard/types.ts) (Candidate results), [`services/query-interface/service.py`](https://github.com/sonyresearch/hakkenoss/blob/main/services/query-interface/service.py) (Query service), [`models/packages/hakken-agents/hakken_agents`](https://github.com/sonyresearch/hakkenoss/tree/main/models/packages/hakken-agents/hakken_agents) (Document and entity agents), [`ui/frontend/src/pages/ResultsPage/index.tsx`](https://github.com/sonyresearch/hakkenoss/blob/main/ui/frontend/src/pages/ResultsPage/index.tsx) (Interactive web UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Data pipeline"]
  node_preprocessing["Dataset processing<br/>[preprocessing.py]"]
  node_temporal_kg["Temporal KG engine<br/>[base.py]"]
end

subgraph group_reasoning["Models and reasoning"]
  node_kge["Knowledge graph embeddings"]
  node_explainer["Hypothesis explanations<br/>[engine.py]"]
end

subgraph group_query["Query and results"]
  node_query_api["Query service<br/>[service.py]"]
  node_complex_query["Complex query<br/>[query.py]"]
  node_query_router["Query REST router<br/>[router.py]"]
  node_candidate_results["Candidate results<br/>[types.ts]"]
  node_gateway["API gateway<br/>[query.py]"]
end

subgraph group_context["Context and agents"]
  node_contextualization["Publication contextualisation<br/>[service.py]"]
  node_publication_store[("Publication vector database")]
  node_agents["Document and entity agents"]
  node_agent_vector[("Agent vector search<br/>[engine.py]")]
  node_document_parser["Document parser<br/>[engine.py]"]
end

subgraph group_experience["Web experience"]
  node_web_ui["Interactive web UI<br/>[index.tsx]"]
  node_query_form["Query form state"]
  node_explanation_context["Explanation requests<br/>[index.tsx]"]
end

node_researcher(("Researcher"))
node_source_data["Biomedical sources"]
node_neo4j[("Neo4j graph")]
node_postgres[("PostgreSQL")]
node_publication_sources["Scientific publications"]

node_source_data -->|"ingests"| node_preprocessing
node_preprocessing -->|"processes graph data"| node_temporal_kg
node_temporal_kg -->|"constructs graph"| node_neo4j
node_neo4j -->|"trains embeddings"| node_kge
node_kge -->|"supports reasoning"| node_explainer
node_researcher -->|"uses"| node_web_ui
node_web_ui -.->|"sets query"| node_query_form
node_query_form -.->|"submits query"| node_query_api
node_query_api -->|"routes complex queries"| node_query_router
node_query_router -->|"dispatches"| node_complex_query
node_complex_query -->|"searches graph"| node_neo4j
node_query_api -->|"returns candidates"| node_candidate_results
node_web_ui -->|"displays results"| node_candidate_results
node_candidate_results -->|"requests explanations"| node_explanation_context
node_explanation_context -->|"sends requests"| node_gateway
node_gateway -.->|"routes explanation"| node_explainer
node_candidate_results -.->|"fetches context"| node_contextualization
node_contextualization -->|"retrieves publications"| node_publication_store
node_publication_sources -.->|"indexes publications"| node_publication_store
node_researcher -->|"submits documents"| node_agents
node_agents -->|"parses documents"| node_document_parser
node_agents -->|"uses vector search"| node_agent_vector
node_agent_vector -->|"queries storage"| node_postgres

click node_preprocessing "https://github.com/sonyresearch/hakkenoss/blob/main/services/data-loader/src/preprocessing.py"
click node_temporal_kg "https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/data_processing/data_processing/temporal_kg_engine/base.py"
click node_kge "https://github.com/sonyresearch/hakkenoss/tree/main/models/packages/hakken-models"
click node_explainer "https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/simple_xkgc/hakken_explainer/explainers/engine.py"
click node_query_api "https://github.com/sonyresearch/hakkenoss/blob/main/services/query-interface/service.py"
click node_complex_query "https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/complex-query/complex_query/core/actions/query.py"
click node_query_router "https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/complex-query/complex_query/delivery/rest/router.py"
click node_candidate_results "https://github.com/sonyresearch/hakkenoss/blob/main/ui/frontend/src/features/CandidateDashboard/types.ts"
click node_contextualization "https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/contextualization/contextualization/api/service.py"
click node_publication_store "https://github.com/sonyresearch/hakkenoss/tree/main/models/packages/contextualization/contextualization/impl/publication_vector_database"
click node_agents "https://github.com/sonyresearch/hakkenoss/tree/main/models/packages/hakken-agents/hakken_agents"
click node_agent_vector "https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/hakken-agents/hakken_agents/vector_db/engine.py"
click node_gateway "https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/hakken_api_gateway/hakken_api_gateway/handlers/query.py"
click node_web_ui "https://github.com/sonyresearch/hakkenoss/blob/main/ui/frontend/src/pages/ResultsPage/index.tsx"
click node_query_form "https://github.com/sonyresearch/hakkenoss/blob/main/ui/frontend/src/contexts/QueryFormContext/queryFormReducer.ts"
click node_explanation_context "https://github.com/sonyresearch/hakkenoss/blob/main/ui/frontend/src/contexts/ExplanationContext/index.tsx"
click node_document_parser "https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/hakken-agents/hakken_agents/tools/document_parser/engine.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_preprocessing,node_temporal_kg toneBlue
class node_kge,node_explainer,node_neo4j,node_postgres toneAmber
class node_query_api,node_complex_query,node_query_router,node_candidate_results,node_gateway toneMint
class node_contextualization,node_publication_store,node_agents,node_agent_vector,node_document_parser toneRose
class node_web_ui,node_query_form,node_explanation_context,node_researcher,node_source_data,node_publication_sources toneIndigo
```

## Components

### Data pipeline

- [Dataset processing](https://github.com/sonyresearch/hakkenoss/blob/main/services/data-loader/src/preprocessing.py): `services/data-loader/src/preprocessing.py`
- [Temporal KG engine](https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/data_processing/data_processing/temporal_kg_engine/base.py): `models/packages/data_processing/data_processing/temporal_kg_engine/base.py`

### Models and reasoning

- [Knowledge graph embeddings](https://github.com/sonyresearch/hakkenoss/tree/main/models/packages/hakken-models): `models/packages/hakken-models`
- [Hypothesis explanations](https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/simple_xkgc/hakken_explainer/explainers/engine.py): `models/packages/simple_xkgc/hakken_explainer/explainers/engine.py`

### Query and results

- [Query service](https://github.com/sonyresearch/hakkenoss/blob/main/services/query-interface/service.py): `services/query-interface/service.py`
- [Complex query](https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/complex-query/complex_query/core/actions/query.py): `models/packages/complex-query/complex_query/core/actions/query.py`
- [Query REST router](https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/complex-query/complex_query/delivery/rest/router.py): `models/packages/complex-query/complex_query/delivery/rest/router.py`
- [Candidate results](https://github.com/sonyresearch/hakkenoss/blob/main/ui/frontend/src/features/CandidateDashboard/types.ts): `ui/frontend/src/features/CandidateDashboard/types.ts`
- [API gateway](https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/hakken_api_gateway/hakken_api_gateway/handlers/query.py): `models/packages/hakken_api_gateway/hakken_api_gateway/handlers/query.py`

### Context and agents

- [Publication contextualisation](https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/contextualization/contextualization/api/service.py): `models/packages/contextualization/contextualization/api/service.py`
- [Publication vector database](https://github.com/sonyresearch/hakkenoss/tree/main/models/packages/contextualization/contextualization/impl/publication_vector_database): `models/packages/contextualization/contextualization/impl/publication_vector_database`
- [Document and entity agents](https://github.com/sonyresearch/hakkenoss/tree/main/models/packages/hakken-agents/hakken_agents): `models/packages/hakken-agents/hakken_agents`
- [Agent vector search](https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/hakken-agents/hakken_agents/vector_db/engine.py): `models/packages/hakken-agents/hakken_agents/vector_db/engine.py`
- [Document parser](https://github.com/sonyresearch/hakkenoss/blob/main/models/packages/hakken-agents/hakken_agents/tools/document_parser/engine.py): `models/packages/hakken-agents/hakken_agents/tools/document_parser/engine.py`

### Web experience

- [Interactive web UI](https://github.com/sonyresearch/hakkenoss/blob/main/ui/frontend/src/pages/ResultsPage/index.tsx): `ui/frontend/src/pages/ResultsPage/index.tsx`
- [Query form state](https://github.com/sonyresearch/hakkenoss/blob/main/ui/frontend/src/contexts/QueryFormContext/queryFormReducer.ts): `ui/frontend/src/contexts/QueryFormContext/queryFormReducer.ts`
- [Explanation requests](https://github.com/sonyresearch/hakkenoss/blob/main/ui/frontend/src/contexts/ExplanationContext/index.tsx): `ui/frontend/src/contexts/ExplanationContext/index.tsx`

### Other components

- **Researcher**
- **Biomedical sources**
- **Neo4j graph**
- **PostgreSQL**
- **Scientific publications**

## Connections

- Biomedical sources → Dataset processing: ingests
- Dataset processing → Temporal KG engine: processes graph data
- Temporal KG engine → Neo4j graph: constructs graph
- Neo4j graph → Knowledge graph embeddings: trains embeddings
- Knowledge graph embeddings → Hypothesis explanations: supports reasoning
- Researcher → Interactive web UI: uses
- Interactive web UI → Query form state: sets query
- Query form state → Query service: submits query
- Query service → Query REST router: routes complex queries (evidence: `services/query-interface/service.py`)
- Query REST router → Complex query: dispatches
- Complex query → Neo4j graph: searches graph
- Query service → Candidate results: returns candidates
- Interactive web UI → Candidate results: displays results
- Candidate results → Explanation requests: requests explanations (evidence: `ui/frontend/src/features/CandidateDashboard/components/ExplanationLoadingButtons/Query.tsx`)
- Explanation requests → API gateway: sends requests (evidence: `ui/frontend/src/contexts/ExplanationContext/index.tsx`)
- API gateway → Hypothesis explanations: routes explanation
- Candidate results → Publication contextualisation: fetches context
- Publication contextualisation → Publication vector database: retrieves publications
- Scientific publications → Publication vector database: indexes publications
- Researcher → Document and entity agents: submits documents
- Document and entity agents → Document parser: parses documents (evidence: `models/packages/hakken-agents/hakken_agents/tools/document_parser/engine.py`)
- Document and entity agents → Agent vector search: uses vector search (evidence: `models/packages/hakken-agents/hakken_agents/tools/element_resolver/engine.py`)
- Agent vector search → PostgreSQL: queries storage (evidence: `models/packages/hakken-agents/hakken_agents/vector_db/engine.py`)
