# iliyas-amine/c-mmap-graph architecture

> Architecture diagram of the GitHub repository iliyas-amine/c-mmap-graph, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iliyas-amine/c-mmap-graph
- Repository: https://github.com/iliyas-amine/c-mmap-graph

## Overview

This is a C library for storing and querying a graph in a fixed-size, memory-mapped file. A caller opens a graph to obtain a handle, then uses the public API to manage node data and edges or query neighbors; the API delegates persistence and graph operations to internal modules. The graph core defines the on-disk layout and allocators. The README is empty, so capabilities and relationships here are based on the provided headers and source excerpts; unsampled behavior is not inferred.

Main entry points: [`src/api.c`](https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/api.c) (Graph API), [`src/graph_core.c`](https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/graph_core.c) (Graph layout), [`src/file_mapper.c`](https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/file_mapper.c) (File mapping), [`src/graph_ops.c`](https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/graph_ops.c) (Node data operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_api_surface["Graph API<br/>[api.c]"]
end

subgraph group_persistence["File Persistence"]
  node_file_mapping["File mapping<br/>[file_mapper.c]"]
  node_mapped_file[("Mapped graph file")]
end

subgraph group_engine["Graph Engine"]
  node_graph_layout["Graph layout<br/>[graph_core.c]"]
  node_allocators["Slot and node allocators<br/>[graph_core.c]"]
  node_node_data["Node data operations<br/>[graph_ops.c]"]
  node_edge_ops["Edge operations<br/>[graph_ops.c]"]
  node_neighbor_queries["Neighbor queries<br/>[graph_ops.c]"]
end

node_caller(("Library caller"))

node_caller -->|"calls"| node_api_surface
node_api_surface -->|"opens, syncs, closes"| node_file_mapping
node_file_mapping -->|"maps file"| node_mapped_file
node_file_mapping -->|"initializes layout"| node_graph_layout
node_api_surface -->|"loads graph"| node_graph_layout
node_api_surface -->|"allocates nodes"| node_allocators
node_api_surface -->|"reads and writes data"| node_node_data
node_api_surface -->|"adds and removes edges"| node_edge_ops
node_api_surface -->|"queries neighbors"| node_neighbor_queries
node_node_data -->|"loads graph"| node_graph_layout
node_edge_ops -->|"loads graph"| node_graph_layout
node_neighbor_queries -->|"loads graph"| node_graph_layout
node_graph_layout -->|"defines mapped structures"| node_mapped_file
node_allocators -->|"updates graph state"| node_graph_layout

click node_api_surface "https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/api.c"
click node_file_mapping "https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/file_mapper.c"
click node_graph_layout "https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/graph_core.c"
click node_allocators "https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/graph_core.c"
click node_node_data "https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/graph_ops.c"
click node_edge_ops "https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/graph_ops.c"
click node_neighbor_queries "https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/graph_ops.c"

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_api_surface toneBlue
class node_file_mapping,node_mapped_file toneAmber
class node_graph_layout,node_allocators,node_node_data,node_edge_ops,node_neighbor_queries toneMint
class node_caller toneIndigo
```

## Components

### Public API

- [Graph API](https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/api.c): `src/api.c`

### File Persistence

- [File mapping](https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/file_mapper.c): `src/file_mapper.c`
- **Mapped graph file**

### Graph Engine

- [Graph layout](https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/graph_core.c): `src/graph_core.c`
- [Slot and node allocators](https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/graph_core.c): `src/graph_core.c`
- [Node data operations](https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/graph_ops.c): `src/graph_ops.c`
- [Edge operations](https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/graph_ops.c): `src/graph_ops.c`
- [Neighbor queries](https://github.com/iliyas-amine/c-mmap-graph/blob/main/src/graph_ops.c): `src/graph_ops.c`

### Other components

- **Library caller**

## Connections

- Library caller → Graph API: calls
- Graph API → File mapping: opens, syncs, closes (evidence: `src/api.c`)
- File mapping → Mapped graph file: maps file (evidence: `src/file_mapper.c`)
- File mapping → Graph layout: initializes layout (evidence: `src/file_mapper.c`)
- Graph API → Graph layout: loads graph (evidence: `src/api.c`)
- Graph API → Slot and node allocators: allocates nodes (evidence: `src/api.c`)
- Graph API → Node data operations: reads and writes data (evidence: `src/api.c`)
- Graph API → Edge operations: adds and removes edges (evidence: `src/api.c`)
- Graph API → Neighbor queries: queries neighbors (evidence: `src/api.c`)
- Node data operations → Graph layout: loads graph (evidence: `src/graph_ops.c`)
- Edge operations → Graph layout: loads graph (evidence: `src/graph_ops.c`)
- Neighbor queries → Graph layout: loads graph (evidence: `src/graph_ops.c`)
- Graph layout → Mapped graph file: defines mapped structures (evidence: `src/graph_core.c`)
- Slot and node allocators → Graph layout: updates graph state (evidence: `src/graph_core.c`)
