# blue-core-lod/bluecore_api architecture

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

- Interactive diagram: https://gitdiagram.com/blue-core-lod/bluecore_api
- Repository: https://github.com/blue-core-lod/bluecore_api

## Overview

Blue Core API manages BIBFRAME resources and related profiles, versions, and change feeds. A client sends requests through the FastAPI application; resource routes create, retrieve, update, search, and serialize records, while batch and export routes initiate workflow operations. Profile management and MARC conversion are distinct capabilities. PostgreSQL is the documented persistence layer, and Keycloak and Airflow are documented external dependencies. Edges reflect shown imports, route registration, and README statements; unsampled route internals are not inferred.

Main entry points: [`src/bluecore_api/app/main.py`](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/main.py) (FastAPI application), [`src/bluecore_api/database.py`](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/database.py) (Database sessions), [`src/bluecore_api/app/routes/instances.py`](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/routes/instances.py) (Resource routes), [`src/bluecore_api/app/routes/profiles.py`](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/routes/profiles.py) (Profile routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routes"]
  node_app["FastAPI application<br/>[main.py]"]
  node_resource_routes["Resource routes<br/>[instances.py]"]
  node_search["Search routes<br/>[search.py]"]
  node_profile_routes["Profile routes<br/>[profiles.py]"]
  node_version_routes["Version routes<br/>[versions.py]"]
  node_batch_export["Batch and export<br/>[batches.py]"]
  node_conversion["MARC conversion<br/>[convert.py]"]
  node_change_feed["Change feeds<br/>[routes.py]"]
  node_change_schemas["Change-feed schemas<br/>[schemas.py]"]
end

subgraph group_resource["Resource processing"]
  node_jsonld["JSON-LD handling<br/>[jsonld.py]"]
  node_expansion["Graph expansion<br/>[expansion.py]"]
  node_responses["Response serialization"]
  node_serializer["Resource serialization<br/>[serializer.py]"]
  node_bibframe_schema["BIBFRAME models<br/>[bibframe.py]"]
  node_api_schemas["API schemas<br/>[schemas.py]"]
  node_view_fields["View fields<br/>[fields.py]"]
  node_view_model["View models<br/>[model.py]"]
  node_view_nodes["View nodes<br/>[nodes.py]"]
  node_view_vocabulary["View vocabulary<br/>[vocabulary.py]"]
end

subgraph group_profile["Profiles and versions"]
  node_profile_usage["Profile usage analysis<br/>[profile_usage.py]"]
  node_profile_versions["Profile version logic"]
  node_template_compat["Template compatibility<br/>[template_compat.py]"]
end

subgraph group_security["Identity and access"]
  node_auth["Role authorization"]
  node_keycloak["Keycloak"]
end

subgraph group_integrations["Persistence and workflows"]
  node_workflow["Workflow client<br/>[workflow.py]"]
  node_postgres[("PostgreSQL")]
  node_database["Database sessions<br/>[database.py]"]
  node_airflow["Airflow service"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_app -->|"registers routes"| node_resource_routes
node_app -->|"registers routes"| node_search
node_app -->|"registers routes"| node_profile_routes
node_app -->|"registers routes"| node_version_routes
node_app -.->|"registers routes"| node_batch_export
node_resource_routes -->|"opens sessions"| node_database
node_search -->|"queries"| node_database
node_profile_routes -->|"queries"| node_database
node_version_routes -->|"queries"| node_database
node_change_feed -->|"opens sessions"| node_database
node_database -->|"connects to"| node_postgres
node_batch_export -->|"starts workflows"| node_workflow
node_workflow -.->|"uses service"| node_airflow
node_resource_routes -->|"parses records"| node_jsonld
node_resource_routes -->|"builds responses"| node_responses
node_responses -->|"expands graphs"| node_expansion
node_responses -->|"loads JSON-LD"| node_jsonld
node_responses -.->|"renders views"| node_view_fields
node_responses -->|"validates output"| node_api_schemas
node_expansion -->|"loads graphs"| node_jsonld
node_expansion -->|"uses models"| node_view_model
node_view_fields -->|"uses nodes"| node_view_nodes
node_view_fields -->|"uses vocabulary"| node_view_vocabulary
node_view_fields -->|"reads models"| node_bibframe_schema
node_profile_routes -->|"checks usage"| node_profile_usage
node_profile_routes -->|"checks versions"| node_profile_versions
node_profile_routes -->|"checks compatibility"| node_template_compat
node_version_routes -->|"uses version logic"| node_profile_versions
node_app -.->|"authenticates requests"| node_keycloak
node_resource_routes -->|"checks permissions"| node_auth
node_change_feed -->|"validates output"| node_change_schemas

click node_app "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/main.py"
click node_resource_routes "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/routes/instances.py"
click node_search "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/routes/search.py"
click node_profile_routes "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/routes/profiles.py"
click node_version_routes "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/routes/versions.py"
click node_batch_export "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/routes/batches.py"
click node_conversion "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/routes/convert.py"
click node_change_feed "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/change_documents/routes.py"
click node_workflow "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/workflow.py"
click node_database "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/database.py"
click node_jsonld "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/utils/jsonld.py"
click node_expansion "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/expansion.py"
click node_responses "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/utils/serialize/response_generator.py"
click node_serializer "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/utils/serializer.py"
click node_bibframe_schema "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/schemas/bibframe.py"
click node_api_schemas "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/schemas/schemas.py"
click node_view_fields "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/views/fields.py"
click node_view_model "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/views/model.py"
click node_view_nodes "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/views/nodes.py"
click node_view_vocabulary "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/views/vocabulary.py"
click node_profile_usage "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/utils/profile_usage.py"
click node_profile_versions "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/utils/profile_versions.py"
click node_template_compat "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/utils/template_compat.py"
click node_auth "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/middleware/bluecore_check_permissions.py"
click node_change_schemas "https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/schemas/change_documents/schemas.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_app,node_resource_routes,node_search,node_profile_routes,node_version_routes,node_batch_export,node_conversion,node_change_feed,node_change_schemas,node_client toneBlue
class node_jsonld,node_expansion,node_responses,node_serializer,node_bibframe_schema,node_api_schemas,node_view_fields,node_view_model,node_view_nodes,node_view_vocabulary toneAmber
class node_profile_usage,node_profile_versions,node_template_compat toneMint
class node_auth,node_keycloak toneRose
class node_workflow,node_postgres,node_database,node_airflow toneIndigo
```

## Components

### API routes

- [FastAPI application](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/main.py): `src/bluecore_api/app/main.py`
- [Resource routes](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/routes/instances.py): `src/bluecore_api/app/routes/instances.py`
- [Search routes](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/routes/search.py): `src/bluecore_api/app/routes/search.py`
- [Profile routes](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/routes/profiles.py): `src/bluecore_api/app/routes/profiles.py`
- [Version routes](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/routes/versions.py): `src/bluecore_api/app/routes/versions.py`
- [Batch and export](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/routes/batches.py): `src/bluecore_api/app/routes/batches.py`
- [MARC conversion](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/routes/convert.py): `src/bluecore_api/app/routes/convert.py`
- [Change feeds](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/change_documents/routes.py): `src/bluecore_api/change_documents/routes.py`
- [Change-feed schemas](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/schemas/change_documents/schemas.py): `src/bluecore_api/schemas/change_documents/schemas.py`

### Resource processing

- [JSON-LD handling](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/utils/jsonld.py): `src/bluecore_api/app/utils/jsonld.py`
- [Graph expansion](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/expansion.py): `src/bluecore_api/expansion.py`
- [Response serialization](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/utils/serialize/response_generator.py): `src/bluecore_api/app/utils/serialize/response_generator.py`
- [Resource serialization](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/utils/serializer.py): `src/bluecore_api/app/utils/serializer.py`
- [BIBFRAME models](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/schemas/bibframe.py): `src/bluecore_api/schemas/bibframe.py`
- [API schemas](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/schemas/schemas.py): `src/bluecore_api/schemas/schemas.py`
- [View fields](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/views/fields.py): `src/bluecore_api/app/views/fields.py`
- [View models](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/views/model.py): `src/bluecore_api/app/views/model.py`
- [View nodes](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/views/nodes.py): `src/bluecore_api/app/views/nodes.py`
- [View vocabulary](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/views/vocabulary.py): `src/bluecore_api/app/views/vocabulary.py`

### Profiles and versions

- [Profile usage analysis](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/utils/profile_usage.py): `src/bluecore_api/app/utils/profile_usage.py`
- [Profile version logic](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/utils/profile_versions.py): `src/bluecore_api/app/utils/profile_versions.py`
- [Template compatibility](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/app/utils/template_compat.py): `src/bluecore_api/app/utils/template_compat.py`

### Identity and access

- [Role authorization](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/middleware/bluecore_check_permissions.py): `src/bluecore_api/middleware/bluecore_check_permissions.py`
- **Keycloak**

### Persistence and workflows

- [Workflow client](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/workflow.py): `src/bluecore_api/workflow.py`
- **PostgreSQL**
- [Database sessions](https://github.com/blue-core-lod/bluecore_api/blob/main/src/bluecore_api/database.py): `src/bluecore_api/database.py`
- **Airflow service**

### Other components

- **API client**

## Connections

- API client → FastAPI application: sends requests
- FastAPI application → Resource routes: registers routes (evidence: `src/bluecore_api/app/main.py`)
- FastAPI application → Search routes: registers routes (evidence: `src/bluecore_api/app/main.py`)
- FastAPI application → Profile routes: registers routes (evidence: `src/bluecore_api/app/main.py`)
- FastAPI application → Version routes: registers routes (evidence: `src/bluecore_api/app/main.py`)
- FastAPI application → Batch and export: registers routes (evidence: `src/bluecore_api/app/main.py`)
- Resource routes → Database sessions: opens sessions (evidence: `src/bluecore_api/app/routes/instances.py`)
- Search routes → Database sessions: queries (evidence: `src/bluecore_api/app/routes/search.py`)
- Profile routes → Database sessions: queries (evidence: `src/bluecore_api/app/routes/profiles.py`)
- Version routes → Database sessions: queries (evidence: `src/bluecore_api/app/routes/versions.py`)
- Change feeds → Database sessions: opens sessions (evidence: `src/bluecore_api/change_documents/routes.py`)
- Database sessions → PostgreSQL: connects to (evidence: `src/bluecore_api/database.py`)
- Batch and export → Workflow client: starts workflows (evidence: `src/bluecore_api/app/routes/batches.py`)
- Workflow client → Airflow service: uses service
- Resource routes → JSON-LD handling: parses records (evidence: `src/bluecore_api/app/routes/instances.py`)
- Resource routes → Response serialization: builds responses (evidence: `src/bluecore_api/app/routes/instances.py`)
- Response serialization → Graph expansion: expands graphs (evidence: `src/bluecore_api/app/utils/serialize/response_generator.py`)
- Response serialization → JSON-LD handling: loads JSON-LD (evidence: `src/bluecore_api/app/utils/serialize/response_generator.py`)
- Response serialization → View fields: renders views (evidence: `src/bluecore_api/app/utils/serialize/response_generator.py`)
- Response serialization → API schemas: validates output (evidence: `src/bluecore_api/app/utils/serialize/response_generator.py`)
- Graph expansion → JSON-LD handling: loads graphs (evidence: `src/bluecore_api/expansion.py`)
- Graph expansion → View models: uses models (evidence: `src/bluecore_api/expansion.py`)
- View fields → View nodes: uses nodes (evidence: `src/bluecore_api/app/views/fields.py`)
- View fields → View vocabulary: uses vocabulary (evidence: `src/bluecore_api/app/views/fields.py`)
- View fields → BIBFRAME models: reads models (evidence: `src/bluecore_api/app/views/fields.py`)
- Profile routes → Profile usage analysis: checks usage (evidence: `src/bluecore_api/app/routes/profiles.py`)
- Profile routes → Profile version logic: checks versions (evidence: `src/bluecore_api/app/routes/profiles.py`)
- Profile routes → Template compatibility: checks compatibility (evidence: `src/bluecore_api/app/routes/profiles.py`)
- Version routes → Profile version logic: uses version logic (evidence: `src/bluecore_api/app/routes/versions.py`)
- FastAPI application → Keycloak: authenticates requests
- Resource routes → Role authorization: checks permissions (evidence: `src/bluecore_api/app/routes/instances.py`)
- Change feeds → Change-feed schemas: validates output (evidence: `src/bluecore_api/change_documents/routes.py`)
