# shashanknayak2005/blockchain-main architecture

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

- Interactive diagram: https://gitdiagram.com/shashanknayak2005/blockchain-main
- Repository: https://github.com/shashanknayak2005/blockchain-main

## Overview

This product lets users authenticate, upload and manage PDF files, and download them only after the encrypted IPFS payload passes a blockchain-backed integrity check. The upload path encrypts and hashes the document, stores it on IPFS, anchors integrity metadata on Ethereum, and persists file metadata in MySQL; download verifies before key unwrap and decryption. The graph also covers file listing, details, deletion, on-demand verification, and tamper-demo operations. Backend service internals are shown at the documented boundary; omitted service excerpts limit finer call-level detail.

Main entry points: [`backend/src/services/file.service.js`](https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/services/file.service.js) (File orchestrator), [`backend/src/routes/file.routes.js`](https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/routes/file.routes.js) (File routes), [`frontend/src/App.jsx`](https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/App.jsx) (Web routes), [`frontend/src/pages/UploadPage.jsx`](https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/pages/UploadPage.jsx) (File pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web client"]
  node_app["Web routes<br/>[App.jsx]"]
  node_authui["Session context<br/>[AuthContext.jsx]"]
  node_fileui["File pages<br/>[UploadPage.jsx]"]
  node_verifyui["Download verifier"]
  node_fileclient["File API client<br/>[file.service.js]"]
  node_authclient["Auth API client<br/>[auth.service.js]"]
  node_http["HTTP client<br/>[api.js]"]
end

subgraph group_api["API and identity"]
  node_server["Express API<br/>[app.js]"]
  node_authroutes["Auth routes<br/>[auth.routes.js]"]
  node_fileroutes["File routes<br/>[file.routes.js]"]
  node_authcontroller["Auth controller<br/>[auth.controller.js]"]
  node_filecontroller["File controller<br/>[file.controller.js]"]
  node_authmw["JWT authorization<br/>[auth.middleware.js]"]
  node_uploadmw["PDF upload validation"]
end

subgraph group_files["File workflows"]
  node_filesvc["File orchestrator<br/>[file.service.js]"]
end

subgraph group_integrity["Integrity services"]
  node_crypto["Envelope encryption"]
  node_hash["SHA-256 hashing<br/>[hash.service.js]"]
  node_chain["Blockchain registry"]
end

subgraph group_persistence["Persistence"]
  node_ipfs["IPFS storage<br/>[ipfs.service.js]"]
  node_mysql[("MySQL metadata<br/>[database.js]")]
end

node_user(("User"))
node_eth[("Ethereum")]
node_pinata["Pinata IPFS"]

node_user -->|"uses"| node_app
node_app -->|"provides session"| node_authui
node_app -->|"routes to"| node_fileui
node_authui -->|"calls"| node_authclient
node_fileui -->|"requests files"| node_fileclient
node_fileui -->|"renders"| node_verifyui
node_verifyui -->|"verifies and downloads"| node_fileclient
node_fileclient -->|"sends requests"| node_http
node_authclient -->|"sends requests"| node_http
node_http -.->|"calls REST API"| node_server
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts"| node_fileroutes
node_authroutes -->|"dispatches"| node_authcontroller
node_authroutes -->|"authenticates"| node_authmw
node_fileroutes -->|"authorizes"| node_authmw
node_fileroutes -->|"validates upload"| node_uploadmw
node_fileroutes -->|"dispatches"| node_filecontroller
node_filecontroller -->|"delegates file actions"| node_filesvc
node_authcontroller -->|"reads and writes users"| node_mysql
node_filesvc -->|"reads and writes metadata"| node_mysql
node_filesvc -->|"encrypts and decrypts"| node_crypto
node_filesvc -->|"hashes payload"| node_hash
node_filesvc -->|"stores and fetches payload"| node_ipfs
node_filesvc -->|"registers and verifies"| node_chain
node_chain -->|"queries registry"| node_eth
node_ipfs -.->|"pins content"| node_pinata

click node_app "https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/App.jsx"
click node_authui "https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/context/AuthContext.jsx"
click node_fileui "https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/pages/UploadPage.jsx"
click node_verifyui "https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/components/DownloadVerificationModal.jsx"
click node_fileclient "https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/services/file.service.js"
click node_authclient "https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/services/auth.service.js"
click node_http "https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/services/api.js"
click node_server "https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/app.js"
click node_authroutes "https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/routes/auth.routes.js"
click node_fileroutes "https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/routes/file.routes.js"
click node_authcontroller "https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/controllers/auth.controller.js"
click node_filecontroller "https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/controllers/file.controller.js"
click node_authmw "https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/middleware/auth.middleware.js"
click node_uploadmw "https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/middleware/upload.middleware.js"
click node_filesvc "https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/services/file.service.js"
click node_crypto "https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/services/encryption/encryption.service.js"
click node_hash "https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/services/hashing/hash.service.js"
click node_ipfs "https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/services/ipfs/ipfs.service.js"
click node_chain "https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/services/blockchain/blockchain.service.js"
click node_mysql "https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/config/database.js"

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_app,node_authui,node_fileui,node_verifyui,node_fileclient,node_authclient,node_http,node_user toneBlue
class node_server,node_authroutes,node_fileroutes,node_authcontroller,node_filecontroller,node_authmw,node_uploadmw,node_eth toneAmber
class node_filesvc toneMint
class node_crypto,node_hash,node_chain toneRose
class node_ipfs,node_mysql,node_pinata toneIndigo
```

## Components

### Web client

- [Web routes](https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Session context](https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [File pages](https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/pages/UploadPage.jsx): `frontend/src/pages/UploadPage.jsx`
- [Download verifier](https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/components/DownloadVerificationModal.jsx): `frontend/src/components/DownloadVerificationModal.jsx`
- [File API client](https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/services/file.service.js): `frontend/src/services/file.service.js`
- [Auth API client](https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/services/auth.service.js): `frontend/src/services/auth.service.js`
- [HTTP client](https://github.com/shashanknayak2005/blockchain-main/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### API and identity

- [Express API](https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/app.js): `backend/src/app.js`
- [Auth routes](https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/routes/auth.routes.js): `backend/src/routes/auth.routes.js`
- [File routes](https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/routes/file.routes.js): `backend/src/routes/file.routes.js`
- [Auth controller](https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/controllers/auth.controller.js): `backend/src/controllers/auth.controller.js`
- [File controller](https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/controllers/file.controller.js): `backend/src/controllers/file.controller.js`
- [JWT authorization](https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/middleware/auth.middleware.js): `backend/src/middleware/auth.middleware.js`
- [PDF upload validation](https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/middleware/upload.middleware.js): `backend/src/middleware/upload.middleware.js`

### File workflows

- [File orchestrator](https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/services/file.service.js): `backend/src/services/file.service.js`

### Integrity services

- [Envelope encryption](https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/services/encryption/encryption.service.js): `backend/src/services/encryption/encryption.service.js`
- [SHA-256 hashing](https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/services/hashing/hash.service.js): `backend/src/services/hashing/hash.service.js`
- [Blockchain registry](https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/services/blockchain/blockchain.service.js): `backend/src/services/blockchain/blockchain.service.js`

### Persistence

- [IPFS storage](https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/services/ipfs/ipfs.service.js): `backend/src/services/ipfs/ipfs.service.js`
- [MySQL metadata](https://github.com/shashanknayak2005/blockchain-main/blob/main/backend/src/config/database.js): `backend/src/config/database.js`

### Other components

- **User**
- **Ethereum**
- **Pinata IPFS**

## Connections

- User → Web routes: uses (evidence: `frontend/src/App.jsx`)
- Web routes → Session context: provides session (evidence: `frontend/src/App.jsx`)
- Web routes → File pages: routes to (evidence: `frontend/src/App.jsx`)
- Session context → Auth API client: calls (evidence: `frontend/src/context/AuthContext.jsx`)
- File pages → File API client: requests files (evidence: `frontend/src/pages/UploadPage.jsx`)
- File pages → Download verifier: renders
- Download verifier → File API client: verifies and downloads (evidence: `frontend/src/components/DownloadVerificationModal.jsx`)
- File API client → HTTP client: sends requests (evidence: `frontend/src/services/file.service.js`)
- Auth API client → HTTP client: sends requests (evidence: `frontend/src/services/auth.service.js`)
- HTTP client → Express API: calls REST API
- Express API → Auth routes: mounts (evidence: `backend/src/app.js`)
- Express API → File routes: mounts (evidence: `backend/src/app.js`)
- Auth routes → Auth controller: dispatches (evidence: `backend/src/routes/auth.routes.js`)
- Auth routes → JWT authorization: authenticates (evidence: `backend/src/routes/auth.routes.js`)
- File routes → JWT authorization: authorizes (evidence: `backend/src/routes/file.routes.js`)
- File routes → PDF upload validation: validates upload (evidence: `backend/src/routes/file.routes.js`)
- File routes → File controller: dispatches (evidence: `backend/src/routes/file.routes.js`)
- File controller → File orchestrator: delegates file actions (evidence: `backend/src/controllers/file.controller.js`)
- Auth controller → MySQL metadata: reads and writes users (evidence: `backend/src/controllers/auth.controller.js`)
- File orchestrator → MySQL metadata: reads and writes metadata (evidence: `backend/src/services/file.service.js`)
- File orchestrator → Envelope encryption: encrypts and decrypts (evidence: `backend/src/services/file.service.js`)
- File orchestrator → SHA-256 hashing: hashes payload (evidence: `backend/src/services/file.service.js`)
- File orchestrator → IPFS storage: stores and fetches payload (evidence: `backend/src/services/file.service.js`)
- File orchestrator → Blockchain registry: registers and verifies (evidence: `backend/src/services/file.service.js`)
- Blockchain registry → Ethereum: queries registry (evidence: `backend/src/services/blockchain/blockchain.service.js`)
- IPFS storage → Pinata IPFS: pins content
