# datagems-eosc/user-profiler architecture

> Architecture diagram of the GitHub repository datagems-eosc/user-profiler, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/datagems-eosc/user-profiler
- Repository: https://github.com/datagems-eosc/user-profiler

## Overview

User Profiler is a FastAPI service for managing graph-backed user profiles, with an optional Streamlit interface. The main workflow accepts profile edits or query notifications, stores profile data and query history, and can fetch DMM query history to generate and refresh session keywords with an LLM. Profile reads can also produce a portable, privacy-trimmed interest profile that merges and ranks session and ORCID keywords. The graph follows the documented user-profile model, including sessions, location, ORCID research and publications. Edges reflect shown imports, calls, UI requests, or README statements; unsampled endpoint details are not inferred.

Main entry points: [`up_api/main.py`](https://github.com/datagems-eosc/user-profiler/blob/main/up_api/main.py) (FastAPI endpoints), [`up_api/resources/data_models.py`](https://github.com/datagems-eosc/user-profiler/blob/main/up_api/resources/data_models.py) (Profile models), [`up_api/resources/LLM_helpers.py`](https://github.com/datagems-eosc/user-profiler/blob/main/up_api/resources/LLM_helpers.py) (Keyword extraction), [`up_api/resources/graph_helpers.py`](https://github.com/datagems-eosc/user-profiler/blob/main/up_api/resources/graph_helpers.py) (Graph CRUD)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interfaces"]
  node_streamlit["Streamlit UI<br/>[app.py]"]
end

subgraph group_service["API service"]
  node_api["FastAPI endpoints<br/>[main.py]"]
  node_auth["Bearer auth<br/>[security.py]"]
end

subgraph group_profile["Profile domain"]
  node_models["Profile models<br/>[data_models.py]"]
  node_profile_logic["Profile shaping<br/>[profile_helpers.py]"]
  node_keyword_llm["Keyword extraction<br/>[LLM_helpers.py]"]
  node_profile_schema["Profile graph schema<br/>[user_model.pg]"]
end

subgraph group_integrations["External integrations"]
  node_orcid_client["ORCID client<br/>[orcid_helpers.py]"]
  node_dmm["DMM query service"]
  node_llm_service["LLM API"]
  node_orcid_service["ORCID public API"]
  node_identity["OIDC JWKS"]
end

subgraph group_persistence["Graph persistence"]
  node_graph_crud["Graph CRUD<br/>[graph_helpers.py]"]
  node_grafeo[("Grafeo database")]
end

node_user(("API caller"))

node_user -->|"uses"| node_streamlit
node_user -->|"requests"| node_api
node_streamlit -->|"calls HTTP"| node_api
node_api -->|"requires auth"| node_auth
node_auth -->|"fetches keys"| node_identity
node_api -->|"uses models"| node_models
node_api -->|"loads and saves"| node_graph_crud
node_api -->|"shapes profiles"| node_profile_logic
node_api -->|"generates keywords"| node_keyword_llm
node_api -->|"fetches ORCID"| node_orcid_client
node_api -->|"fetches query history"| node_dmm
node_keyword_llm -->|"requests extraction"| node_llm_service
node_orcid_client -->|"fetches profile"| node_orcid_service
node_graph_crud -->|"executes queries"| node_grafeo
node_graph_crud -->|"uses profile model"| node_models
node_keyword_llm -->|"validates output"| node_models
node_profile_logic -->|"uses query model"| node_models
node_profile_schema -->|"defines graph shape"| node_models

click node_streamlit "https://github.com/datagems-eosc/user-profiler/blob/main/app.py"
click node_api "https://github.com/datagems-eosc/user-profiler/blob/main/up_api/main.py"
click node_auth "https://github.com/datagems-eosc/user-profiler/blob/main/up_api/resources/security.py"
click node_models "https://github.com/datagems-eosc/user-profiler/blob/main/up_api/resources/data_models.py"
click node_profile_logic "https://github.com/datagems-eosc/user-profiler/blob/main/up_api/resources/profile_helpers.py"
click node_keyword_llm "https://github.com/datagems-eosc/user-profiler/blob/main/up_api/resources/LLM_helpers.py"
click node_orcid_client "https://github.com/datagems-eosc/user-profiler/blob/main/up_api/resources/orcid_helpers.py"
click node_graph_crud "https://github.com/datagems-eosc/user-profiler/blob/main/up_api/resources/graph_helpers.py"
click node_profile_schema "https://github.com/datagems-eosc/user-profiler/blob/main/schema/user_model.pg"

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_streamlit toneBlue
class node_api,node_auth toneAmber
class node_models,node_profile_logic,node_keyword_llm,node_profile_schema,node_user toneMint
class node_orcid_client,node_dmm,node_llm_service,node_orcid_service,node_identity toneRose
class node_graph_crud,node_grafeo toneIndigo
```

## Components

### User interfaces

- [Streamlit UI](https://github.com/datagems-eosc/user-profiler/blob/main/app.py): `app.py`

### API service

- [FastAPI endpoints](https://github.com/datagems-eosc/user-profiler/blob/main/up_api/main.py): `up_api/main.py`
- [Bearer auth](https://github.com/datagems-eosc/user-profiler/blob/main/up_api/resources/security.py): `up_api/resources/security.py`

### Profile domain

- [Profile models](https://github.com/datagems-eosc/user-profiler/blob/main/up_api/resources/data_models.py): `up_api/resources/data_models.py`
- [Profile shaping](https://github.com/datagems-eosc/user-profiler/blob/main/up_api/resources/profile_helpers.py): `up_api/resources/profile_helpers.py`
- [Keyword extraction](https://github.com/datagems-eosc/user-profiler/blob/main/up_api/resources/LLM_helpers.py): `up_api/resources/LLM_helpers.py`
- [Profile graph schema](https://github.com/datagems-eosc/user-profiler/blob/main/schema/user_model.pg): `schema/user_model.pg`

### External integrations

- [ORCID client](https://github.com/datagems-eosc/user-profiler/blob/main/up_api/resources/orcid_helpers.py): `up_api/resources/orcid_helpers.py`
- **DMM query service**
- **LLM API**
- **ORCID public API**
- **OIDC JWKS**

### Graph persistence

- [Graph CRUD](https://github.com/datagems-eosc/user-profiler/blob/main/up_api/resources/graph_helpers.py): `up_api/resources/graph_helpers.py`
- **Grafeo database**

### Other components

- **API caller**

## Connections

- API caller → Streamlit UI: uses (evidence: `README.md`)
- API caller → FastAPI endpoints: requests (evidence: `README.md`)
- Streamlit UI → FastAPI endpoints: calls HTTP (evidence: `app.py`)
- FastAPI endpoints → Bearer auth: requires auth (evidence: `up_api/main.py`)
- Bearer auth → OIDC JWKS: fetches keys (evidence: `up_api/resources/security.py`)
- FastAPI endpoints → Profile models: uses models (evidence: `up_api/main.py`)
- FastAPI endpoints → Graph CRUD: loads and saves (evidence: `up_api/main.py`)
- FastAPI endpoints → Profile shaping: shapes profiles (evidence: `up_api/main.py`)
- FastAPI endpoints → Keyword extraction: generates keywords (evidence: `up_api/main.py`)
- FastAPI endpoints → ORCID client: fetches ORCID (evidence: `up_api/main.py`)
- FastAPI endpoints → DMM query service: fetches query history (evidence: `up_api/main.py`)
- Keyword extraction → LLM API: requests extraction (evidence: `up_api/resources/LLM_helpers.py`)
- ORCID client → ORCID public API: fetches profile (evidence: `up_api/resources/orcid_helpers.py`)
- Graph CRUD → Grafeo database: executes queries (evidence: `up_api/resources/graph_helpers.py`)
- Graph CRUD → Profile models: uses profile model (evidence: `up_api/resources/graph_helpers.py`)
- Keyword extraction → Profile models: validates output (evidence: `up_api/resources/LLM_helpers.py`)
- Profile shaping → Profile models: uses query model (evidence: `up_api/resources/profile_helpers.py`)
- Profile graph schema → Profile models: defines graph shape (evidence: `README.md`)
