# inder-26/verichain architecture

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

- Interactive diagram: https://gitdiagram.com/inder-26/verichain
- Repository: https://github.com/inder-26/verichain

## Overview

##### Project type and purpose
- VeriChain is a full-stack, web-based document verification system.
- Purpose: accept document images via a web UI, extract text with AI/OCR, hash the extracted data, and store/verify that hash on a blockchain for immutable, tamper-proof verification.

##### File structure
- app.py: Flask server entry point
- requirements.txt / .env: Python dependencies and configuration
- document_verification.db: local SQLite database for metadata/logs
- static/: CSS (Tailwind, Bootstrap, custom main.css), favicon
- templates/: Flask HTML pages (index, upload, verify, result)
- uploads/: persistent storage for raw document images
- README.md: describes the AI-OCR (Gemini API) and NeoX blockchain integration

##### README for additional insights
- Architecture is implied: Browser ↔ Flask backend ↔ Gemini OCR API + NeoX blockchain ↔ local DB
- Technologies: Python/Flask, HTML5, Tailwind, Bootstrap, JavaScript, Gemini API, NeoX blockchain, SHA-256 hashing

##### Elements
- Notes on edges: annotate protocols (HTTP, REST, JSON), data formats (image, text, hash)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend"
        direction TB
        Browser["Web Browser UI"]:::frontend
        Index["templates/index.html"]:::frontend
        UploadPage["templates/upload.html"]:::frontend
        VerifyPage["templates/verify.html"]:::frontend
        ResultPage["templates/result.html"]:::frontend
        Static["static/main.css"]:::frontend
    end

    subgraph "Backend"
        direction TB
        App["Flask Server (app.py)"]:::internal
        UploadHandler["Upload Handler"]:::internal
        OCRHash["OCR/Hash Service"]:::internal
        BlockConnector["Blockchain Connector"]:::internal
        FileStore["File Store (images/)"]:::internal
        DB["SQLite DB (document_verification.db)"]:::internal
        Env[".env"]:::internal
        Req["requirements.txt"]:::internal
        README["README.md"]:::internal
    end

    Gemini["OCR Service (Gemini API)"]:::external
    NeoX["Blockchain Network (NeoX)"]:::external

    Browser -->|"1. Open UI"| Index
    Browser -->|"2. Open Upload Page"| UploadPage
    Browser -->|"3. Open Verify Page"| VerifyPage
    Browser -->|"4. Open Result Page"| ResultPage
    Browser -->|"5. POST /upload (image)"| App
    App --> UploadHandler
    UploadHandler -->|"save image"| FileStore
    UploadHandler -->|"log metadata"| DB
    UploadHandler --> OCRHash
    OCRHash -->|"send image (HTTP/JSON)"| Gemini
    Gemini -->|"return text"| OCRHash
    OCRHash -->|"SHA-256(text)"| UploadHandler
    UploadHandler --> BlockConnector
    BlockConnector -->|"submit hash tx"| NeoX
    NeoX -->|"tx confirmation"| BlockConnector
    BlockConnector -->|"record tx & timestamp"| DB
    App -->|"render result"| ResultPage
    Browser -->|"6. GET /verify"| App
    App --> BlockConnector
    BlockConnector -->|"fetch hash"| NeoX
    BlockConnector -->|"compare hashes"| App
    App -->|"render verify outcome"| VerifyPage

    click Index "https://github.com/inder-26/verichain/blob/main/templates/index.html"
    click UploadPage "https://github.com/inder-26/verichain/blob/main/templates/upload.html"
    click VerifyPage "https://github.com/inder-26/verichain/blob/main/templates/verify.html"
    click ResultPage "https://github.com/inder-26/verichain/blob/main/templates/result.html"
    click Static "https://github.com/inder-26/verichain/blob/main/static/main.css"
    click App "https://github.com/inder-26/verichain/blob/main/app.py"
    click FileStore "https://github.com/inder-26/verichain/tree/main/images/"
    click DB "https://github.com/inder-26/verichain/blob/main/document_verification.db"
    click Env "https://github.com/inder-26/verichain/blob/main/.env"
    click Req "https://github.com/inder-26/verichain/blob/main/requirements.txt"
    click README "https://github.com/inder-26/verichain/blob/main/README.md"

    classDef frontend fill:#FFF7C0,stroke:#333,stroke-width:1px
    classDef internal fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef external fill:#C1F0C1,stroke:#333,stroke-width:1px
```
