# anandpandit-001/ftl_simulator architecture

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

- Interactive diagram: https://gitdiagram.com/anandpandit-001/ftl_simulator
- Repository: https://github.com/anandpandit-001/ftl_simulator

## Overview

This is a C simulation of a flash translation layer (FTL): the driver issues sector-based reads and writes, while the FTL translates them to NAND pages and uses garbage collection to reclaim space during overwrites. The flash module models NAND storage in memory. The driver’s calls and the flash implementation are excerpted; the FTL implementation is not, so its internal links to flash are shown as unverified.

Main entry points: [`src/main.c`](https://github.com/anandpandit-001/ftl_simulator/blob/main/src/main.c) (Test driver), [`src/ftl.c`](https://github.com/anandpandit-001/ftl_simulator/blob/main/src/ftl.c) (Sector translation and GC), [`inc/ftl.h`](https://github.com/anandpandit-001/ftl_simulator/blob/main/inc/ftl.h) (FTL interface), [`inc/flash.h`](https://github.com/anandpandit-001/ftl_simulator/blob/main/inc/flash.h) (Flash interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_driver["Simulation driver"]
  node_driver_main["Test driver<br/>[main.c]"]
end

subgraph group_ftl["Translation layer"]
  node_ftl_api["FTL interface<br/>[ftl.h]"]
  node_ftl_runtime["Sector translation and GC<br/>[ftl.c]"]
end

subgraph group_nand["NAND model"]
  node_flash_api["Flash interface<br/>[flash.h]"]
  node_flash_model[("Flash array<br/>[flash.c]")]
end

node_user(("User"))

node_user -->|"runs simulation"| node_driver_main
node_driver_main -->|"initializes, reads, writes"| node_ftl_api
node_driver_main -->|"initializes, frees"| node_flash_api
node_ftl_runtime -.->|"uses NAND operations"| node_flash_model

click node_driver_main "https://github.com/anandpandit-001/ftl_simulator/blob/main/src/main.c"
click node_ftl_api "https://github.com/anandpandit-001/ftl_simulator/blob/main/inc/ftl.h"
click node_ftl_runtime "https://github.com/anandpandit-001/ftl_simulator/blob/main/src/ftl.c"
click node_flash_api "https://github.com/anandpandit-001/ftl_simulator/blob/main/inc/flash.h"
click node_flash_model "https://github.com/anandpandit-001/ftl_simulator/blob/main/src/flash.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_driver_main,node_user toneBlue
class node_ftl_api,node_ftl_runtime toneAmber
class node_flash_api,node_flash_model toneMint
```

## Components

### Simulation driver

- [Test driver](https://github.com/anandpandit-001/ftl_simulator/blob/main/src/main.c): `src/main.c`

### Translation layer

- [FTL interface](https://github.com/anandpandit-001/ftl_simulator/blob/main/inc/ftl.h): `inc/ftl.h`
- [Sector translation and GC](https://github.com/anandpandit-001/ftl_simulator/blob/main/src/ftl.c): `src/ftl.c`

### NAND model

- [Flash interface](https://github.com/anandpandit-001/ftl_simulator/blob/main/inc/flash.h): `inc/flash.h`
- [Flash array](https://github.com/anandpandit-001/ftl_simulator/blob/main/src/flash.c): `src/flash.c`

### Other components

- **User**

## Connections

- User → Test driver: runs simulation (evidence: `Readme.md`)
- Test driver → FTL interface: initializes, reads, writes (evidence: `src/main.c`)
- Test driver → Flash interface: initializes, frees (evidence: `src/main.c`)
- Sector translation and GC → Flash array: uses NAND operations
