# aditya24rathore/atm-project architecture

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

- Interactive diagram: https://gitdiagram.com/aditya24rathore/atm-project
- Repository: https://github.com/aditya24rathore/atm-project

## Overview

##### Project type and purpose (what you are diagramming)
This repo is a **single-process C console application** (“ATM System”) meant for **educational ATM-like flows**:
- **PIN setup + PIN verification**
- **Lockout after 3 failures**
- **Menu-driven transactions**: balance, deposit, withdraw
- **All state is in-memory for the lifetime of the process** (no DB/files/network)

##### What the file tree implies about architecture scope
From the tree:
- `ATM.c` is effectively the entire system (monolithic source)
- `output/ATM.exe` is a build artifact, not an architectural component
- No `src/`, `include/`, `tests/`, no persistence layer, no external services

##### `main` → Auth Gate → calls `PIN()` repeatedly
- Auth Gate **reads PIN state**, increments **failed-attempt state**
- If failed attempts == 3 → transition to **Blocked/Exit**
##### `main` → OS/System Layer (`system("cls")`) at relevant points

- **Monolith / Single executable**
- **Layering by concern (logical, not physical folders):**
- UI (CLI) vs Control vs Domain/Transactions vs State vs OS calls
- **Gatekeeper pattern** for authentication (PIN check) before allowing access to menu
- **In-memory state store** (global balance variable)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% =========================
    %% Diagram A — System Context
    %% =========================
    subgraph "System Context (As-Is)"
        U["User"]:::external
        T["Terminal / Console"]:::external
        OS["Operating System"]:::os

        APPCTX["ATM Console App (single-process)"]:::container
        NOTE1["Notes:\n- No DB / No network / No files\n- State resets each run\n- Single account, single balance variable"]:::note
    end

    U <-->|"input/output"| T
    T -->|"runs"| APPCTX
    APPCTX -->|"system('cls')"| OS
    APPCTX --- NOTE1

    %% =========================
    %% Diagram B/C — Container + Components inside ATM.exe
    %% =========================
    subgraph "ATM.exe (Monolith in C) — Internal Components"
        direction TB

        subgraph "UI / I-O Layer"
            direction TB
            CLI["CLI UI\n(printf/scanf prompts,\nmenu display, errors)"]:::ui
        end

        subgraph "Control Flow"
            direction TB
            MAIN["Program Controller\nmain()"]:::control
            AUTH["Auth Gate + Lockout Policy\n(compare PIN, attempts 0..3,\nblock on 3 failures)"]:::control
            MENU["Menu Dispatcher\n(loop + switch/case,\nexit on 0)"]:::control
        end

        subgraph "Authentication / PIN Management"
            direction TB
            GENPIN["PIN Generation\nGen_Pin()"]:::auth
            PININ["PIN Entry\nPIN()"]:::auth
        end

        subgraph "Domain / Transaction Engine"
            direction TB
            BAL["CheckBalance()"]:::domain
            DEP["Deposit()\n(validate amount > 0)"]:::domain
            WDR["Withdraw()\n(validate amount > 0\nand <= balance)"]:::domain
        end

        subgraph "In-Memory State Store (lifetime of process)"
            direction TB
            STATE[("In-Memory State\n- amt (double, global)\n- Stored PIN\n- failedAttempts (0..3)\n- transient inputs")]:::state
        end

        subgraph "System/OS Dependency"
            direction TB
            SYSCMD["OS/System Calls\nsystem('cls')\n(Windows-specific)"]:::os
        end
    end

    %% Calls / control flow
    MAIN -->|"calls"| GENPIN
    MAIN -->|"calls(loop)"| AUTH
    AUTH -->|"calls(attempt)"| PININ
    AUTH -->|"onSuccess"| MENU

    MENU -->|"choice=1"| BAL
    MENU -->|"choice=2"| DEP
    MENU -->|"choice=3"| WDR
    MENU -->|"choice=0"| EXIT(("Exit")):::exitnode

    %% CLI usage
    U -->|"enters PIN/choice/amount"| CLI
    CLI -->|"delivers inputs"| MAIN
    CLI <-->|"prompts/results/errors"| GENPIN
    CLI <-->|"prompts/results/errors"| PININ
    CLI <-->|"menu display"| MENU
    CLI <-->|"prints balance"| BAL
    CLI <-->|"prints status/errors"| DEP
    CLI <-->|"prints status/errors"| WDR

    %% State read/write (dashed)
    GENPIN -.->|"writes Stored PIN"| STATE
    PININ -.->|"reads attempt"| STATE
    AUTH -.->|"reads Stored PIN"| STATE
    AUTH -.->|"writes failedAttempts++"| STATE

    BAL -.->|"reads amt"| STATE
    DEP -.->|"R/W amt"| STATE
    WDR -.->|"R/W amt"| STATE

    %% OS call usage
    MAIN -->|"calls"| SYSCMD
    SYSCMD -->|"executes via OS"| OS

    %% Auth failure exit
    AUTH -->|"failedAttempts==3"| BLOCKED["Blocked / Exit\n(Card locked)"]:::exitnode
    BLOCKED --> EXIT

    %% =========================
    %% Diagram D — Activity (Control-Flow Accuracy)
    %% =========================
    subgraph "Runtime Activity (High-Level Flow)"
        direction TB
        A0([Start]):::start
        A1["Gen_Pin() (set initial PIN)"]:::auth
        A2["system('cls')"]:::os
        A3{"Authenticate\n(up to 3 attempts)"}:::control
        A4["PIN() (read attempt)"]:::auth
        A5{"PIN matches?"}:::control
        A6["failedAttempts++"]:::state
        A7{"failedAttempts==3?"}:::control
        A8["Blocked / Exit"]:::exitnode
        A9["Enter Menu Loop"]:::control
        A10["Display menu + read choice"]:::ui
        A11{"Choice"}:::control
        A12["CheckBalance()"]:::domain
        A13["Deposit()"]:::domain
        A14["Withdraw()"]:::domain
        A15{"choice==0?"}:::control
        A16([End]):::endstyle
    end

    A0 --> A1 --> A2 --> A3
    A3 --> A4 --> A5
    A5 -->|"Yes"| A9
    A5 -->|"No"| A6 --> A7
    A7 -->|"Yes"| A8 --> A16
    A7 -->|"No"| A3

    A9 --> A10 --> A11
    A11 -->|"1"| A12 --> A10
    A11 -->|"2"| A13 --> A10
    A11 -->|"3"| A14 --> A10
    A11 -->|"0"| A15
    A15 -->|"Yes"| A16
    A15 -->|"No"| A10

    %% =========================
    %% Click Events (from component_mapping)
    %% =========================
    click APPCTX "https://github.com/aditya24rathore/atm-project/blob/main/ATM.c"
    click MAIN "https://github.com/aditya24rathore/atm-project/blob/main/ATM.c"
    click CLI "https://github.com/aditya24rathore/atm-project/blob/main/ATM.c"
    click GENPIN "https://github.com/aditya24rathore/atm-project/blob/main/ATM.c"
    click PININ "https://github.com/aditya24rathore/atm-project/blob/main/ATM.c"
    click AUTH "https://github.com/aditya24rathore/atm-project/blob/main/ATM.c"
    click MENU "https://github.com/aditya24rathore/atm-project/blob/main/ATM.c"
    click BAL "https://github.com/aditya24rathore/atm-project/blob/main/ATM.c"
    click DEP "https://github.com/aditya24rathore/atm-project/blob/main/ATM.c"
    click WDR "https://github.com/aditya24rathore/atm-project/blob/main/ATM.c"
    click STATE "https://github.com/aditya24rathore/atm-project/blob/main/ATM.c"
    click SYSCMD "https://github.com/aditya24rathore/atm-project/blob/main/ATM.c"
    click NOTE1 "https://github.com/aditya24rathore/atm-project/blob/main/README.md"

    %% Additional mapped artifacts
    BUILD["Build Artifact\nATM.exe"]:::artifact
    DOCIMG["Documentation Images\n(screenshots/diagrams)"]:::artifact
    README["Project Documentation\nREADME"]:::artifact

    APPCTX --- BUILD
    APPCTX --- DOCIMG
    APPCTX --- README

    click BUILD "https://github.com/aditya24rathore/atm-project/blob/main/output/ATM.exe"
    click DOCIMG "https://github.com/aditya24rathore/atm-project/tree/main/images/"
    click README "https://github.com/aditya24rathore/atm-project/blob/main/README.md"

    %% =========================
    %% Styles
    %% =========================
    classDef external fill:#E6F0FF,stroke:#1D4ED8,stroke-width:1.5px,color:#0B1220
    classDef container fill:#0F172A,stroke:#334155,stroke-width:2px,color:#F8FAFC
    classDef ui fill:#DBEAFE,stroke:#2563EB,stroke-width:1.5px,color:#0B1220
    classDef control fill:#F3E8FF,stroke:#7C3AED,stroke-width:1.5px,color:#0B1220
    classDef auth fill:#EDE9FE,stroke:#6D28D9,stroke-width:1.5px,color:#0B1220
    classDef domain fill:#DCFCE7,stroke:#16A34A,stroke-width:1.5px,color:#0B1220
    classDef state fill:#FFEDD5,stroke:#F97316,stroke-width:1.5px,color:#0B1220
    classDef os fill:#E5E7EB,stroke:#374151,stroke-width:1.5px,color:#111827
    classDef note fill:#FEF9C3,stroke:#CA8A04,stroke-width:1.5px,color:#111827
    classDef artifact fill:#F1F5F9,stroke:#64748B,stroke-width:1.5px,color:#0B1220
    classDef exitnode fill:#FFE4E6,stroke:#E11D48,stroke-width:1.5px,color:#111827
    classDef start fill:#D1FAE5,stroke:#059669,stroke-width:1.5px,color:#064E3B
    classDef endstyle fill:#E2E8F0,stroke:#475569,stroke-width:1.5px,color:#0B1220
```
