# ilya-smirnov-de/boundary-agents-be architecture

> Architecture diagram of the GitHub repository ilya-smirnov-de/boundary-agents-be, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ilya-smirnov-de/boundary-agents-be
- Repository: https://github.com/ilya-smirnov-de/boundary-agents-be

## Overview

Boundary Agents BE is a Flask API that serves agent, property, relation, court, and entity data from FactGrid. Requests enter the route handlers in main.py, which build SPARQL queries where needed, execute them through the FactGrid client, and return result bindings. A separate recache endpoint starts a background download of project entities. Configuration supplies endpoint URLs and the server port. The excerpts show these call paths; the cache directory is referenced in code but is absent from the tree, so it is not modeled as a repository component.

Main entry points: [`factgrid/Client.py`](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/factgrid/Client.py) (FactGrid Client), [`factgrid/Queries.py`](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/factgrid/Queries.py) (SPARQL Queries), [`factgrid/Downloader.py`](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/factgrid/Downloader.py) (Entity Downloader), [`main.py`](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/main.py) (Agent Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_agent_routes["Agent Routes<br/>[main.py]"]
  node_property_routes["Property Routes<br/>[main.py]"]
  node_relation_routes["Relation Routes<br/>[main.py]"]
  node_court_routes["Court Routes<br/>[main.py]"]
  node_entity_route["Entity Route<br/>[main.py]"]
  node_recache_route["Recache Route<br/>[main.py]"]
end

subgraph group_query["Querying"]
  node_query_builder["SPARQL Queries<br/>[Queries.py]"]
  node_type_mappings["Type Mappings<br/>[constants.py]"]
end

subgraph group_integration["FactGrid Integration"]
  node_factgrid_client["FactGrid Client<br/>[Client.py]"]
  node_entity_downloader["Entity Downloader<br/>[Downloader.py]"]
  node_factgrid_sparql{{"FactGrid SPARQL"}}
  node_entity_data_service{{"Entity Data Service"}}
end

subgraph group_runtime["Runtime Configuration"]
  node_configuration["Configuration<br/>[Configuration.py]"]
  node_config_file["Config File<br/>[config.json]"]
end

node_caller(("API Caller"))

node_caller -->|"requests"| node_agent_routes
node_caller -->|"requests"| node_property_routes
node_caller -->|"requests"| node_relation_routes
node_caller -->|"requests"| node_court_routes
node_caller -->|"requests"| node_entity_route
node_caller -->|"requests"| node_recache_route
node_agent_routes -->|"builds queries"| node_query_builder
node_agent_routes -->|"executes queries"| node_factgrid_client
node_property_routes -->|"builds queries"| node_query_builder
node_property_routes -->|"executes queries"| node_factgrid_client
node_relation_routes -->|"builds queries"| node_query_builder
node_relation_routes -->|"executes queries"| node_factgrid_client
node_court_routes -->|"builds queries"| node_query_builder
node_court_routes -->|"executes queries"| node_factgrid_client
node_entity_route -->|"fetches entity"| node_factgrid_client
node_recache_route -->|"starts download"| node_entity_downloader
node_query_builder -->|"uses constants"| node_type_mappings
node_factgrid_client -->|"reads URLs"| node_configuration
node_factgrid_client -->|"sends queries"| node_factgrid_sparql
node_factgrid_client -->|"fetches JSON"| node_entity_data_service
node_entity_downloader -->|"requests project items"| node_query_builder
node_entity_downloader -->|"executes query"| node_factgrid_client
node_entity_downloader -->|"downloads entities"| node_entity_data_service
node_configuration -->|"loads settings"| node_config_file
node_configuration -->|"imports constants"| node_type_mappings

click node_agent_routes "https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/main.py"
click node_property_routes "https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/main.py"
click node_relation_routes "https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/main.py"
click node_court_routes "https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/main.py"
click node_entity_route "https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/main.py"
click node_recache_route "https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/main.py"
click node_query_builder "https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/factgrid/Queries.py"
click node_type_mappings "https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/constants.py"
click node_factgrid_client "https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/factgrid/Client.py"
click node_entity_downloader "https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/factgrid/Downloader.py"
click node_configuration "https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/config/Configuration.py"
click node_config_file "https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/config/config.json"

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_agent_routes,node_property_routes,node_relation_routes,node_court_routes,node_entity_route,node_recache_route toneBlue
class node_query_builder,node_type_mappings toneAmber
class node_factgrid_client,node_entity_downloader,node_factgrid_sparql,node_entity_data_service,node_caller toneMint
class node_configuration,node_config_file toneRose
```

## Components

### HTTP API

- [Agent Routes](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/main.py): `main.py`
- [Property Routes](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/main.py): `main.py`
- [Relation Routes](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/main.py): `main.py`
- [Court Routes](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/main.py): `main.py`
- [Entity Route](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/main.py): `main.py`
- [Recache Route](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/main.py): `main.py`

### Querying

- [SPARQL Queries](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/factgrid/Queries.py): `factgrid/Queries.py`
- [Type Mappings](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/constants.py): `constants.py`

### FactGrid Integration

- [FactGrid Client](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/factgrid/Client.py): `factgrid/Client.py`
- [Entity Downloader](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/factgrid/Downloader.py): `factgrid/Downloader.py`
- **FactGrid SPARQL**
- **Entity Data Service**

### Runtime Configuration

- [Configuration](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/config/Configuration.py): `config/Configuration.py`
- [Config File](https://github.com/ilya-smirnov-de/boundary-agents-be/blob/main/config/config.json): `config/config.json`

### Other components

- **API Caller**

## Connections

- API Caller → Agent Routes: requests (evidence: `main.py`)
- API Caller → Property Routes: requests (evidence: `main.py`)
- API Caller → Relation Routes: requests (evidence: `main.py`)
- API Caller → Court Routes: requests (evidence: `main.py`)
- API Caller → Entity Route: requests (evidence: `main.py`)
- API Caller → Recache Route: requests (evidence: `main.py`)
- Agent Routes → SPARQL Queries: builds queries (evidence: `main.py`)
- Agent Routes → FactGrid Client: executes queries (evidence: `main.py`)
- Property Routes → SPARQL Queries: builds queries (evidence: `main.py`)
- Property Routes → FactGrid Client: executes queries (evidence: `main.py`)
- Relation Routes → SPARQL Queries: builds queries (evidence: `main.py`)
- Relation Routes → FactGrid Client: executes queries (evidence: `main.py`)
- Court Routes → SPARQL Queries: builds queries (evidence: `main.py`)
- Court Routes → FactGrid Client: executes queries (evidence: `main.py`)
- Entity Route → FactGrid Client: fetches entity (evidence: `main.py`)
- Recache Route → Entity Downloader: starts download (evidence: `main.py`)
- SPARQL Queries → Type Mappings: uses constants (evidence: `factgrid/Queries.py`)
- FactGrid Client → Configuration: reads URLs (evidence: `factgrid/Client.py`)
- FactGrid Client → FactGrid SPARQL: sends queries (evidence: `factgrid/Client.py`)
- FactGrid Client → Entity Data Service: fetches JSON (evidence: `factgrid/Client.py`)
- Entity Downloader → SPARQL Queries: requests project items (evidence: `factgrid/Downloader.py`)
- Entity Downloader → FactGrid Client: executes query (evidence: `factgrid/Downloader.py`)
- Entity Downloader → Entity Data Service: downloads entities (evidence: `factgrid/Downloader.py`)
- Configuration → Config File: loads settings (evidence: `config/Configuration.py`)
- Configuration → Type Mappings: imports constants (evidence: `config/Configuration.py`)
