# batistedecat/bapicoin-blockchain- architecture

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

- Interactive diagram: https://gitdiagram.com/batistedecat/bapicoin-blockchain-
- Repository: https://github.com/batistedecat/bapicoin-blockchain-
- Video tour (about a minute): https://gitdiagram.com/batistedecat/bapicoin-blockchain-/video

## Overview

BapiCoin is an educational blockchain with a Streamlit interface and a Flask REST node. Users submit transactions to a pending pool, mine blocks that include those transactions and a reward, and inspect the chain. Nodes can register peers and replace their chain when a longer valid chain is found. The graph reflects the sampled Python code and README; peer-chain retrieval is documented and implemented, but deployment wiring for the Streamlit app is not established by the repository.

Main entry points: [`bapicoin.py`](https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py) (Blockchain instance), [`streamlit_interface.py`](https://github.com/batistedecat/bapicoin-blockchain-/blob/main/streamlit_interface.py) (Streamlit controls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Streamlit interface"]
  node_ui["Streamlit controls"]
end

subgraph group_api["REST API"]
  node_chain_endpoint["Chain endpoint<br/>[bapicoin.py]"]
  node_transaction_endpoint["Transaction endpoint<br/>[bapicoin.py]"]
  node_mine_endpoint["Mining endpoint<br/>[bapicoin.py]"]
  node_register_endpoint["Registration endpoint<br/>[bapicoin.py]"]
  node_resolve_endpoint["Resolution endpoint<br/>[bapicoin.py]"]
end

subgraph group_core["Blockchain core"]
  node_blockchain["Blockchain instance<br/>[bapicoin.py]"]
  node_pool["Transaction pool<br/>[bapicoin.py]"]
  node_chain[("In-memory chain<br/>[bapicoin.py]")]
  node_proof_work["Proof of Work<br/>[bapicoin.py]"]
  node_hashing["Block hashing<br/>[bapicoin.py]"]
  node_chain_validation["Chain validation<br/>[bapicoin.py]"]
end

subgraph group_network["Peer network"]
  node_peer_registry[("Peer registry<br/>[bapicoin.py]")]
  node_peer_nodes(("Registered peer nodes"))
end

node_user(("User"))

node_user -->|"interacts"| node_ui
node_ui -->|"GET chain"| node_chain_endpoint
node_ui -->|"POST transaction"| node_transaction_endpoint
node_ui -->|"GET mine"| node_mine_endpoint
node_chain_endpoint -->|"reads"| node_chain
node_transaction_endpoint -->|"adds transaction"| node_blockchain
node_blockchain -->|"queues"| node_pool
node_mine_endpoint -->|"reads last block"| node_blockchain
node_mine_endpoint -->|"finds proof"| node_proof_work
node_proof_work -->|"checks proof"| node_hashing
node_mine_endpoint -->|"adds reward"| node_blockchain
node_mine_endpoint -->|"hashes previous block"| node_hashing
node_mine_endpoint -->|"forges block"| node_blockchain
node_blockchain -->|"takes pending transactions"| node_pool
node_blockchain -->|"appends block"| node_chain
node_register_endpoint -->|"registers nodes"| node_blockchain
node_blockchain -->|"stores addresses"| node_peer_registry
node_resolve_endpoint -->|"resolves conflicts"| node_blockchain
node_blockchain -->|"reads peers"| node_peer_registry
node_blockchain -->|"requests chain"| node_peer_nodes
node_peer_nodes -->|"returns chain data"| node_blockchain
node_blockchain -->|"checks candidate"| node_chain_validation
node_chain_validation -->|"checks links"| node_hashing
node_chain_validation -->|"checks proofs"| node_proof_work
node_blockchain -->|"replaces chain"| node_chain

click node_ui "https://github.com/batistedecat/bapicoin-blockchain-/blob/main/streamlit_interface.py"
click node_chain_endpoint "https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py"
click node_transaction_endpoint "https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py"
click node_mine_endpoint "https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py"
click node_register_endpoint "https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py"
click node_resolve_endpoint "https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py"
click node_blockchain "https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py"
click node_pool "https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py"
click node_chain "https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py"
click node_proof_work "https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py"
click node_hashing "https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py"
click node_chain_validation "https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py"
click node_peer_registry "https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.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_ui,node_user toneBlue
class node_chain_endpoint,node_transaction_endpoint,node_mine_endpoint,node_register_endpoint,node_resolve_endpoint toneAmber
class node_blockchain,node_pool,node_chain,node_proof_work,node_hashing,node_chain_validation toneMint
class node_peer_registry,node_peer_nodes toneRose
```

## Components

### Streamlit interface

- [Streamlit controls](https://github.com/batistedecat/bapicoin-blockchain-/blob/main/streamlit_interface.py): `streamlit_interface.py`

### REST API

- [Chain endpoint](https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py): `bapicoin.py`
- [Transaction endpoint](https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py): `bapicoin.py`
- [Mining endpoint](https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py): `bapicoin.py`
- [Registration endpoint](https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py): `bapicoin.py`
- [Resolution endpoint](https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py): `bapicoin.py`

### Blockchain core

- [Blockchain instance](https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py): `bapicoin.py`
- [Transaction pool](https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py): `bapicoin.py`
- [In-memory chain](https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py): `bapicoin.py`
- [Proof of Work](https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py): `bapicoin.py`
- [Block hashing](https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py): `bapicoin.py`
- [Chain validation](https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py): `bapicoin.py`

### Peer network

- [Peer registry](https://github.com/batistedecat/bapicoin-blockchain-/blob/main/bapicoin.py): `bapicoin.py`
- **Registered peer nodes**

### Other components

- **User**

## Connections

- User → Streamlit controls: interacts
- Streamlit controls → Chain endpoint: GET chain
- Streamlit controls → Transaction endpoint: POST transaction
- Streamlit controls → Mining endpoint: GET mine
- Chain endpoint → In-memory chain: reads
- Transaction endpoint → Blockchain instance: adds transaction
- Blockchain instance → Transaction pool: queues
- Mining endpoint → Blockchain instance: reads last block
- Mining endpoint → Proof of Work: finds proof
- Proof of Work → Block hashing: checks proof
- Mining endpoint → Blockchain instance: adds reward
- Mining endpoint → Block hashing: hashes previous block
- Mining endpoint → Blockchain instance: forges block
- Blockchain instance → Transaction pool: takes pending transactions
- Blockchain instance → In-memory chain: appends block
- Registration endpoint → Blockchain instance: registers nodes
- Blockchain instance → Peer registry: stores addresses
- Resolution endpoint → Blockchain instance: resolves conflicts
- Blockchain instance → Peer registry: reads peers
- Blockchain instance → Registered peer nodes: requests chain
- Registered peer nodes → Blockchain instance: returns chain data
- Blockchain instance → Chain validation: checks candidate
- Chain validation → Block hashing: checks links
- Chain validation → Proof of Work: checks proofs
- Blockchain instance → In-memory chain: replaces chain
