# abhi608/disdat architecture

> Architecture diagram of the GitHub repository abhi608/disdat, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhi608/disdat
- Repository: https://github.com/abhi608/disdat

## Overview

##### Project Overview and Purpose
- This project is a simulation tool designed to mimic concurrency control in a distributed database. It handles transactions, locking, and site management to simulate the behavior of distributed data management systems.
- The README explains that you compile the executable from source using Makefile and run the simulation against an input file, which likely contains transaction instructions.

##### File Structure for Architectural Components
- Top-level files such as Makefile, README.md, and design.pdf help give background context.
- The “include” directory contains header files that define the main components, including:
- constants, datamanager, instruction, io, lock, locktable, site, sitemanager, transaction, transactionmanager, variable, and utility functions.
- The “src” directory implements the logic for these components, with each corresponding .cpp file handling functionality for the module named in its header—for instance, transaction.cpp manages transaction operations.
- The “bin” directory yields the final executable.
- The “test” directory holds scripts and sample input/output files used to validate the simulation.

##### Identifying Key Architectural Components
- Input/Output Manager: Reads instruction files and displays or logs simulation outputs.
- Instruction Processor: Converts input into structured commands.
- Transaction Manager: Manages transaction lifecycles, including processing commits, rollbacks, and conflict resolution.
- Lock Manager & Lock Table: Implements concurrency control by managing locks on data items.
- Data/Variable Manager: Manages simulated variables (database items) and possibly their state across different sites.
- Site Manager: Simulates distributed sites in the database that execute transactions.
- Coordinator/Runner (possibly through the start.cpp): Initiates and controls the overall simulation.

##### Representing Their Interactions
- The executable (bin/main) uses the start component to kick off the simulation.
- Input is processed by the IO module which hands off parsed instructions to the Instruction Processor.
- The Transaction Manager then coordinates with the Lock Manager to grant or queue locks via the Lock Table.
- Depending on the instruction, the Transaction Manager will interact with the Data Manager and Site Manager to replicate the distributed nature of the database.

##### Final Checklist
- Use clear labels for each component (e.g., "Input Handler", "Instruction Parser", "Transaction Manager", "Lock Manager", "Data Manager", "Site Manager").
- Fully detail any dependencies such as the relationship between transaction and lock components to capture the concurrency control simulation aspect.

## Diagram (Mermaid)

```mermaid
flowchart TD
    C1["Coordinator/Runner"]:::coordinator
    IO["Input/Output Manager"]:::io
    IP["Instruction Processor"]:::instruction
    TM["Transaction Manager"]:::transaction
    LM["Lock Manager & Lock Table"]:::lock
    DM["Data/Variable Manager"]:::data
    SM["Site Manager"]:::site

    C1 -->|"starts_simulation"| IO
    IO -->|"Parsed_Commands"| IP
    IP -->|"Transaction_Commands"| TM
    TM -->|"Lock_Request"| LM
    LM -->|"Lock_Callback"| TM
    TM -->|"Read_Write"| DM
    TM -->|"Distribute_Txn"| SM

    click C1 "https://github.com/abhi608/disdat/blob/main/src/start.cpp"
    click C1 "https://github.com/abhi608/disdat/tree/main/bin/main"

    click IO "https://github.com/abhi608/disdat/blob/main/include/io.h"
    click IO "https://github.com/abhi608/disdat/blob/main/src/io.cpp"
    click IO "https://github.com/abhi608/disdat/tree/main/test/"

    click IP "https://github.com/abhi608/disdat/blob/main/include/instruction.h"
    click IP "https://github.com/abhi608/disdat/blob/main/src/instruction.cpp"

    click TM "https://github.com/abhi608/disdat/blob/main/include/transactionmanager.h"
    click TM "https://github.com/abhi608/disdat/blob/main/src/transactionmanager.cpp"

    click LM "https://github.com/abhi608/disdat/blob/main/include/lock.h"
    click LM "https://github.com/abhi608/disdat/blob/main/include/locktable.h"
    click LM "https://github.com/abhi608/disdat/blob/main/src/lock.cpp"
    click LM "https://github.com/abhi608/disdat/blob/main/src/locktable.cpp"

    click DM "https://github.com/abhi608/disdat/blob/main/include/datamanager.h"
    click DM "https://github.com/abhi608/disdat/blob/main/src/datamanager.cpp"
    click DM "https://github.com/abhi608/disdat/blob/main/include/variable.h"
    click DM "https://github.com/abhi608/disdat/blob/main/src/variable.cpp"

    click SM "https://github.com/abhi608/disdat/blob/main/include/site.h"
    click SM "https://github.com/abhi608/disdat/blob/main/include/sitemanager.h"
    click SM "https://github.com/abhi608/disdat/blob/main/src/site.cpp"
    click SM "https://github.com/abhi608/disdat/blob/main/src/sitemanager.cpp"

    classDef coordinator fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef io fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef instruction fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef transaction fill:#FFE4B5,stroke:#333,stroke-width:2px;
    classDef lock fill:#FF7F7F,stroke:#333,stroke-width:2px;
    classDef data fill:#FFFF99,stroke:#333,stroke-width:2px;
    classDef site fill:#FFC0CB,stroke:#333,stroke-width:2px;
```
