# sushanth-gs-bit/pb-hack architecture

> Architecture diagram of the GitHub repository sushanth-gs-bit/pb-hack, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sushanth-gs-bit/pb-hack
- Repository: https://github.com/sushanth-gs-bit/pb-hack

## Overview

ChainCert is a Flask-based certificate and marks-record verification demo. Users issue or seed records, inspect and verify them, and can simulate edits to see exact hash, field-fingerprint, proof-of-work, and chain-link failures. The app restores and persists chain state and activity events in SQLite. The graph reflects README-documented dashboard and API capabilities; unsampled template details are not expanded, and edges are limited to relationships shown in excerpts or the README.

Main entry points: [`app.py`](https://github.com/sushanth-gs-bit/pb-hack/blob/main/app.py) (Flask API and routes), [`blockchain.py`](https://github.com/sushanth-gs-bit/pb-hack/blob/main/blockchain.py) (Chain and block management), [`storage.py`](https://github.com/sushanth-gs-bit/pb-hack/blob/main/storage.py) (SQLite persistence and event log), [`templates/index.html`](https://github.com/sushanth-gs-bit/pb-hack/blob/main/templates/index.html) (Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_flask["Flask API and routes<br/>[app.py]"]
  node_dashboard["Dashboard<br/>[index.html]"]
  node_records["Record validation and issuance<br/>[app.py]"]
  node_tamper["Tamper simulation<br/>[app.py]"]
  node_export["Chain export<br/>[app.py]"]
end

subgraph group_chain["Chain verification"]
  node_chain_model["Chain and block management<br/>[blockchain.py]"]
  node_mining["Hashing and proof of work<br/>[blockchain.py]"]
  node_integrity["Integrity validation report<br/>[blockchain.py]"]
  node_record_verify["Record authenticity verification<br/>[blockchain.py]"]
end

subgraph group_persistence["Persistence and demo data"]
  node_sample_data["Sample certificates<br/>[samples.py]"]
  node_store[("SQLite persistence and event log<br/>[storage.py]")]
end

node_user(("Judge or issuer"))
node_sqlite[("SQLite database")]

node_user -->|"uses"| node_dashboard
node_dashboard -->|"requests"| node_flask
node_flask -->|"routes records"| node_records
node_records -->|"issues records"| node_chain_model
node_chain_model -->|"mines blocks"| node_mining
node_flask -->|"reports checks"| node_integrity
node_flask -->|"verifies records"| node_record_verify
node_flask -->|"handles edits"| node_tamper
node_tamper -->|"edits blocks"| node_chain_model
node_flask -->|"exports chain"| node_export
node_flask -->|"loads samples"| node_sample_data
node_flask -->|"loads and saves"| node_store
node_store -->|"reads and writes"| node_sqlite
node_store -->|"restores chain"| node_chain_model

click node_flask "https://github.com/sushanth-gs-bit/pb-hack/blob/main/app.py"
click node_dashboard "https://github.com/sushanth-gs-bit/pb-hack/blob/main/templates/index.html"
click node_records "https://github.com/sushanth-gs-bit/pb-hack/blob/main/app.py"
click node_chain_model "https://github.com/sushanth-gs-bit/pb-hack/blob/main/blockchain.py"
click node_mining "https://github.com/sushanth-gs-bit/pb-hack/blob/main/blockchain.py"
click node_integrity "https://github.com/sushanth-gs-bit/pb-hack/blob/main/blockchain.py"
click node_record_verify "https://github.com/sushanth-gs-bit/pb-hack/blob/main/blockchain.py"
click node_tamper "https://github.com/sushanth-gs-bit/pb-hack/blob/main/app.py"
click node_export "https://github.com/sushanth-gs-bit/pb-hack/blob/main/app.py"
click node_sample_data "https://github.com/sushanth-gs-bit/pb-hack/blob/main/samples.py"
click node_store "https://github.com/sushanth-gs-bit/pb-hack/blob/main/storage.py"

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_flask,node_dashboard,node_records,node_tamper,node_export toneBlue
class node_chain_model,node_mining,node_integrity,node_record_verify,node_sqlite toneAmber
class node_sample_data,node_store toneMint
class node_user toneIndigo
```

## Components

### Web application

- [Flask API and routes](https://github.com/sushanth-gs-bit/pb-hack/blob/main/app.py): `app.py`
- [Dashboard](https://github.com/sushanth-gs-bit/pb-hack/blob/main/templates/index.html): `templates/index.html`
- [Record validation and issuance](https://github.com/sushanth-gs-bit/pb-hack/blob/main/app.py): `app.py`
- [Tamper simulation](https://github.com/sushanth-gs-bit/pb-hack/blob/main/app.py): `app.py`
- [Chain export](https://github.com/sushanth-gs-bit/pb-hack/blob/main/app.py): `app.py`

### Chain verification

- [Chain and block management](https://github.com/sushanth-gs-bit/pb-hack/blob/main/blockchain.py): `blockchain.py`
- [Hashing and proof of work](https://github.com/sushanth-gs-bit/pb-hack/blob/main/blockchain.py): `blockchain.py`
- [Integrity validation report](https://github.com/sushanth-gs-bit/pb-hack/blob/main/blockchain.py): `blockchain.py`
- [Record authenticity verification](https://github.com/sushanth-gs-bit/pb-hack/blob/main/blockchain.py): `blockchain.py`

### Persistence and demo data

- [Sample certificates](https://github.com/sushanth-gs-bit/pb-hack/blob/main/samples.py): `samples.py`
- [SQLite persistence and event log](https://github.com/sushanth-gs-bit/pb-hack/blob/main/storage.py): `storage.py`

### Other components

- **Judge or issuer**
- **SQLite database**

## Connections

- Judge or issuer → Dashboard: uses (evidence: `README.md`)
- Dashboard → Flask API and routes: requests (evidence: `README.md`)
- Flask API and routes → Record validation and issuance: routes records (evidence: `app.py`)
- Record validation and issuance → Chain and block management: issues records (evidence: `app.py`)
- Chain and block management → Hashing and proof of work: mines blocks (evidence: `blockchain.py`)
- Flask API and routes → Integrity validation report: reports checks (evidence: `README.md`)
- Flask API and routes → Record authenticity verification: verifies records (evidence: `README.md`)
- Flask API and routes → Tamper simulation: handles edits (evidence: `app.py`)
- Tamper simulation → Chain and block management: edits blocks (evidence: `README.md`)
- Flask API and routes → Chain export: exports chain (evidence: `README.md`)
- Flask API and routes → Sample certificates: loads samples (evidence: `README.md`)
- Flask API and routes → SQLite persistence and event log: loads and saves (evidence: `app.py`)
- SQLite persistence and event log → SQLite database: reads and writes (evidence: `storage.py`)
- SQLite persistence and event log → Chain and block management: restores chain (evidence: `storage.py`)
