Data Model (`ModelExecution`)
Relevant source files
The following files were used as context for generating this wiki page:- frontend/src/hooks/useModelData.ts
- frontend/src/components/LocationInfo.tsx
- frontend/src/components/Hero.tsx
- frontend/src/components/ModelExecutionDashboard.tsx
- frontend/src/components/dashboard/ModelList.tsx
- frontend/src/components/dashboard/SummaryStats.tsx
- frontend/src/components/VersionLeaderboard.tsx
The ModelExecution data model is a client-side data structure that aggregates information about a specific AI model across all observed servers. Instead of viewing data from a server-centric perspective, ModelExecution provides a model-centric view, summarizing where each unique model is found, whether it's running, and other statistical data.
This structure is not fetched directly from an API endpoint. It is dynamically generated within the frontend by processing a raw list of server data. The primary logic for this transformation resides in the useModelData hook, which fetches server information and then computes the ModelExecution array. This aggregated data then powers the Model Execution Dashboard.
Source Data (ServerData)
The foundation for the ModelExecution model is the ServerData interface. The application fetches a JSON file (/data/live_servers.json) containing an object, which is then converted into an array of ServerData objects. Each object represents a single exposed server discovered by the monitoring system.
Sources: frontend/src/hooks/useModelData.ts:18-24, frontend/src/components/LocationInfo.tsx:50-53
ServerData and ServerModel Relationship
The ServerData object contains details about the server itself (IP, location, version) and two arrays of ServerModel objects: local (models present on the server's disk) and running (models currently loaded into memory).
The following diagram illustrates the relationship between these two data structures.
This ER diagram shows that a ServerData entity can contain many local models and many running models, both of which are represented by the ServerModel structure.
Sources: frontend/src/components/LocationInfo.tsx:8-30, frontend/src/components/Hero.tsx:14-36
ServerData Interface
The table below details the properties of the ServerData interface.
| Field | Type | Description | Source File |
|---|---|---|---|
ip | string | The IP address of the server. | LocationInfo.tsx:13 |
port | number | The port number the service is running on. | LocationInfo.tsx:14 |
version | string | The version of the Ollama software. | LocationInfo.tsx:15 |
city | string | The city where the server is located. | LocationInfo.tsx:16 |
country | string | The two-letter country code (e.g., 'US'). | LocationInfo.tsx:17 |
country_name | string | The full name of the country. | LocationInfo.tsx:18 |
region | string | The region or state. | LocationInfo.tsx:19 |
latitude | string | The geographical latitude. | LocationInfo.tsx:20 |
longitude | string | The geographical longitude. | LocationInfo.tsx:21 |
local | ServerModel[] | An array of models available locally on the server. | LocationInfo.tsx:22 |
running | ServerModel[] | An array of models currently running on the server. | LocationInfo.tsx:23 |
first_seen_online | string | ISO timestamp of when the server was first observed. | LocationInfo.tsx:24 |
age | string | A human-readable string representing the server's age. | LocationInfo.tsx:25 |
status | string | The current status, e.g., 'live'. | LocationInfo.tsx:26 |
last_observed | string | ISO timestamp of when the server was last observed (only in Hero.tsx). | Hero.tsx:34 |
Data Transformation (useModelData hook)
The useModelData hook is responsible for fetching the raw ServerData and transforming it into the ModelExecution array. This is done within a useMemo hook that re-computes the data whenever the source serverData changes.
The logic iterates through each server and, for each model listed in the local and running arrays, it aggregates the data into a Map where the key is the model name. This ensures all information for a single model (e.g., "llama3:8b") is grouped together from across all servers.
Sources: frontend/src/hooks/useModelData.ts:45-108
Aggregation Flow
The following flowchart shows the process of transforming ServerData[] into ModelExecution[].
This diagram outlines the data transformation pipeline within the useModelData hook, from fetching raw data to producing the final modelExecutions array.
Sources: frontend/src/hooks/useModelData.ts:45-110
The ModelExecution Data Structure
The ModelExecution object is a composite structure containing metadata, aggregation data, and statistics for a single AI model.
ModelExecution Class Diagram
This diagram shows the structure of the ModelExecution type and its relationship with ServerData.
This class diagram illustrates the composition of the ModelExecution object, which is built from Metadata, Aggregation, and Statistics objects. The Aggregation part contains an array of ServerExecution instances, each linking back to the original ServerData.
Sources: frontend/src/hooks/useModelData.ts:51-55, 60-66, 81-87
Field Definitions
The ModelExecution object is broken down into three main properties as detailed below.
metadata
Contains static information about the model.
| Field | Type | Description | Source |
|---|---|---|---|
modelName | string | The unique name of the model (e.g., gemma:2b). | useModelData.ts:52 |
averageSize | number | The average size of the model in bytes, calculated across all servers. | useModelData.ts:105 |
aggregation
Contains aggregated data from all servers where the model was found.
| Field | Type | Description | Source |
|---|---|---|---|
totalServers | number | The total count of unique servers where this model is present. | useModelData.ts:68, 90 |
runningServers | number | The count of servers where this model is currently in a 'running' state. | useModelData.ts:69, 91 |
totalSize | number | The sum of the model's size in bytes across all instances. | useModelData.ts:70, 92 |
servers | ServerExecution[] | An array of objects, each detailing an instance of the model on a specific server. | useModelData.ts:60, 81 |
statistics
Contains calculated statistics about the model's usage.
| Field | Type | Description | Source |
|---|---|---|---|
lastActivity | string | The most recent last_observed timestamp from any server running this model. | useModelData.ts:72, 95 |
executionFrequency | number | A ratio of runningServers to totalServers (0 to 1). | useModelData.ts:106 |
Data Consumption
The generated modelExecutions array is consumed by several components in the dashboard to display the data.
This diagram shows how the modelExecutions data flows from the useModelData hook to the main dashboard component, which then distributes it to child components like SummaryStats and ModelList for rendering.
ModelExecutionDashboard.tsx: This component acts as the orchestrator. It calls theuseModelDatahook to get themodelExecutionsand then passes this data to child components. It also manages filtering, sorting, and pagination.
Sources: frontend/src/components/ModelExecutionDashboard.tsx:16, 29SummaryStats.tsx: This component receives the fullmodelExecutionsarray to calculate and display high-level statistics like "Unique Models", "Active Executions", and "Total Model Size".
Sources: frontend/src/components/dashboard/SummaryStats.tsx:11, 15ModelList.tsx: This component receives a paginated and filtered slice of themodelExecutionsarray and maps over it to render aModelCardfor each model.
Sources: frontend/src/components/dashboard/ModelList.tsx:10, 50
Conclusion
The ModelExecution data model is a critical client-side abstraction in the LLaMa Leaks application. It transforms a raw, server-oriented list of data into an aggregated, model-centric view. This computed structure simplifies the rendering of complex statistics and relationships on the dashboard, allowing users to easily see which models are most prevalent, where they are running, and how actively they are being used across the observed network of exposed servers.