# jenish-1235/nosql-database-simulation-implementation architecture

> Architecture diagram of the GitHub repository jenish-1235/nosql-database-simulation-implementation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jenish-1235/nosql-database-simulation-implementation
- Repository: https://github.com/jenish-1235/nosql-database-simulation-implementation

## Overview

This repository is a FastAPI-backed key-value database simulation. Requests enter through the API: writes update the in-memory table and append to the write-ahead log; reads check memory before falling back to SSTables. Startup reconstructs memory from persisted state, and sufficiently large tables are dumped to SSTables. The graph shows these documented flows and file-backed storage. Some storage paths are hard-coded in the sampled managers; unsampled behavior is not inferred.

Main entry points: [`core/file_io_manager.py`](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/core/file_io_manager.py) (File I/O), [`services/database_service.py`](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/services/database_service.py) (Database service), [`api/v1/endpoints/database.py`](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/api/v1/endpoints/database.py) (Database endpoints), [`core/ssTable_manager.py`](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/core/ssTable_manager.py) (SSTable manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_app["FastAPI app<br/>[main.py]"]
  node_router["API router<br/>[api.py]"]
  node_endpoint["Database endpoints<br/>[database.py]"]
end

subgraph group_service["Database service"]
  node_database_service["Database service"]
  node_memtable["In-memory table"]
  node_data_schema["Request data schema<br/>[data.py]"]
end

subgraph group_managers["Storage managers"]
  node_memtable_manager["Memtable recovery"]
  node_wal_manager["WAL manager<br/>[WAL_manager.py]"]
  node_sst_manager["SSTable manager<br/>[ssTable_manager.py]"]
  node_file_io["File I/O<br/>[file_io_manager.py]"]
  node_sst_schema["SSTable model"]
end

subgraph group_storage["Persistent storage"]
  node_wal_file[("WAL file<br/>[wal_file.txt]")]
  node_sst_file[("SSTable file<br/>[sst_file.txt]")]
  node_sst_ids[("SSTable ID file<br/>[sstable_ids.txt]")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_router
node_router -->|"registers routes"| node_endpoint
node_client -.->|"calls endpoints"| node_endpoint
node_endpoint -->|"reads and writes"| node_database_service
node_endpoint -->|"appends writes"| node_wal_manager
node_database_service -->|"updates and checks"| node_memtable
node_database_service -->|"reconstructs from"| node_memtable_manager
node_database_service -->|"reads and dumps"| node_sst_manager
node_memtable_manager -->|"loads latest table"| node_sst_manager
node_memtable_manager -->|"reads WAL"| node_file_io
node_wal_manager -->|"writes records"| node_file_io
node_sst_manager -->|"reads and writes"| node_file_io
node_file_io -->|"reads and writes"| node_wal_file
node_file_io -->|"reads and writes"| node_sst_file
node_file_io -->|"reads and writes"| node_sst_ids
node_sst_manager -->|"creates tables"| node_sst_schema
node_database_service -->|"creates dump"| node_sst_schema

click node_app "https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/main.py"
click node_router "https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/api/v1/api.py"
click node_endpoint "https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/api/v1/endpoints/database.py"
click node_database_service "https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/services/database_service.py"
click node_memtable "https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/services/database_service.py"
click node_data_schema "https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/schemas/data.py"
click node_memtable_manager "https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/core/memTable_manager.py"
click node_wal_manager "https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/core/WAL_manager.py"
click node_sst_manager "https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/core/ssTable_manager.py"
click node_file_io "https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/core/file_io_manager.py"
click node_sst_schema "https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/schemas/sorted_set_table.py"
click node_wal_file "https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/persistent-storage/wal_file.txt"
click node_sst_file "https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/persistent-storage/sst_file.txt"
click node_sst_ids "https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/persistent-storage/sstable_ids.txt"

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_router,node_endpoint,node_client toneBlue
class node_database_service,node_memtable,node_data_schema toneAmber
class node_memtable_manager,node_wal_manager,node_sst_manager,node_file_io,node_sst_schema toneMint
class node_wal_file,node_sst_file,node_sst_ids toneRose
```

## Components

### API

- [FastAPI app](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/main.py): `main.py`
- [API router](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/api/v1/api.py): `api/v1/api.py`
- [Database endpoints](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/api/v1/endpoints/database.py): `api/v1/endpoints/database.py`

### Database service

- [Database service](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/services/database_service.py): `services/database_service.py`
- [In-memory table](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/services/database_service.py): `services/database_service.py`
- [Request data schema](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/schemas/data.py): `schemas/data.py`

### Storage managers

- [Memtable recovery](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/core/memTable_manager.py): `core/memTable_manager.py`
- [WAL manager](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/core/WAL_manager.py): `core/WAL_manager.py`
- [SSTable manager](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/core/ssTable_manager.py): `core/ssTable_manager.py`
- [File I/O](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/core/file_io_manager.py): `core/file_io_manager.py`
- [SSTable model](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/schemas/sorted_set_table.py): `schemas/sorted_set_table.py`

### Persistent storage

- [WAL file](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/persistent-storage/wal_file.txt): `persistent-storage/wal_file.txt`
- [SSTable file](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/persistent-storage/sst_file.txt): `persistent-storage/sst_file.txt`
- [SSTable ID file](https://github.com/jenish-1235/nosql-database-simulation-implementation/blob/main/persistent-storage/sstable_ids.txt): `persistent-storage/sstable_ids.txt`

### Other components

- **API client**

## Connections

- API client → FastAPI app: sends requests
- FastAPI app → API router: mounts routes (evidence: `main.py`)
- API router → Database endpoints: registers routes (evidence: `api/v1/api.py`)
- API client → Database endpoints: calls endpoints
- Database endpoints → Database service: reads and writes (evidence: `api/v1/endpoints/database.py`)
- Database endpoints → WAL manager: appends writes (evidence: `api/v1/endpoints/database.py`)
- Database service → In-memory table: updates and checks (evidence: `services/database_service.py`)
- Database service → Memtable recovery: reconstructs from (evidence: `services/database_service.py`)
- Database service → SSTable manager: reads and dumps (evidence: `services/database_service.py`)
- Memtable recovery → SSTable manager: loads latest table (evidence: `core/memTable_manager.py`)
- Memtable recovery → File I/O: reads WAL (evidence: `core/memTable_manager.py`)
- WAL manager → File I/O: writes records (evidence: `core/WAL_manager.py`)
- SSTable manager → File I/O: reads and writes (evidence: `core/ssTable_manager.py`)
- File I/O → WAL file: reads and writes (evidence: `core/file_io_manager.py`)
- File I/O → SSTable file: reads and writes (evidence: `core/file_io_manager.py`)
- File I/O → SSTable ID file: reads and writes (evidence: `core/file_io_manager.py`)
- SSTable manager → SSTable model: creates tables (evidence: `core/ssTable_manager.py`)
- Database service → SSTable model: creates dump (evidence: `services/database_service.py`)
