A decentralized-style document integrity system built with the MERN Stack. This application allows users to register documents, generate unique cryptographic fingerprints (SHA-256 hashes), and verify the authenticity of files to detect tampering.
The system follows a Client–Server Architecture with a focus on Security at the Edge (Frontend Hashing).
- Local Hashing: Uses
crypto-jsto generate a SHA-256 hash before the file leaves the user's device. - State Management: Implemented with React Context API for global authentication and session handling.
- UI & Animation: Built using Tailwind CSS and Framer Motion.
- Integrity Re-Verification: The backend re-hashes uploaded files using the Node.js
cryptomodule to ensure the file was not modified during transmission. - File Handling: Managed with Multer for local or cloud storage.
- Database Storage: File metadata and hashes are stored in MongoDB.
- REST APIs are used for communication between frontend and backend.
- JWT Authentication secures all protected endpoints.
To meet the high-security requirements of a document registry, the following measures were implemented:
Each document receives a unique cryptographic fingerprint. Even a single-bit modification changes the entire hash.
Hashing occurs at two levels:
- Frontend: Ensures transparency for users.
- Backend: Ensures system-level verification and prevents tampering.
JWT tokens are stored in HttpOnly & Secure cookies to protect against XSS (Cross-Site Scripting) attacks.
Private pages such as the Dashboard and Admin Panel are protected using a Higher-Order Component (HOC) that verifies authentication before access.
API requests are restricted to trusted origins to prevent unauthorized third-party access.
Follow these steps to run the project locally.
- Node.js v18 or higher
- MongoDB Atlas account or Local MongoDB instance
cd backend
npm install
npm startcd frontend
npm install
npm run devCreate a .env file in the backend directory and add the following variables:
# Server Configuration
PORT=2000
# Database
MONGO_URL=your_mongodb_connection_string
# Authentication
JWT_SECRET=your_super_secret_key_123
# File Uploads
MAX_FILE_SIZE=5242880Note:
Use a long and complex JWT_SECRET in production environments for better security.
project-root │
├── backend
│ ├── controllers
│ ├── models
│ ├── routes
│ ├── middleware
│ ├── uploads
│ └── server.js
│
├── frontend
│ ├── components
│ ├── context
│ ├── pages
│ └── utils
│
└── README.md
| Layer | Technology |
|---|---|
| Frontend | Next.js, Tailwind CSS, Framer Motion |
| Backend | Node.js, Express.js |
| Database | MongoDB |
| Security | SHA-256 Hashing, JWT, HttpOnly Cookies |
| File Handling | Multer |
| Icons | Lucide React |
- Secure document registration
- SHA-256 cryptographic fingerprint generation
- File authenticity verification
- Double-layer integrity validation
- JWT-based authentication
- Secure cookie storage
- Protected dashboard and admin routes
- MongoDB document metadata storage
- File upload and verification workflow
- User uploads a document from the frontend.
- The frontend generates a SHA-256 hash using
crypto-js. - The file and hash are sent to the backend API.
- The backend re-calculates the hash using the Node.js crypto module.
- If hashes match, the document metadata and hash are stored in MongoDB.
- Later, users can upload the same document again to verify authenticity.
Asim Mir Full-Stack Web Developer with cyber-security.
