Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“„ Document Verification System (DVS)

Python FastAPI React PostgreSQL Docker JWT MIT License

An enterprise-grade full-stack Document Verification System built with FastAPI, React, PostgreSQL, and Docker.

The application enables organizations to securely manage document verification workflows through Role-Based Access Control (RBAC), JWT Authentication, Email OTP Verification, OCR-powered document processing, Audit Logging, and a modern responsive dashboard for Employees, Verifiers, and Administrators.

Designed with scalability, maintainability, and security in mind, this project demonstrates industry-standard backend architecture and modern frontend development practices.


πŸ–ΌοΈ Application Preview

Admin Dashboard


✨ Table of Contents

  • Overview
  • Key Features
  • Role-Based Access Control
  • Technology Stack
  • System Architecture
  • Project Structure
  • Installation
  • Backend Setup
  • Frontend Setup
  • Docker Deployment
  • Database Migration
  • API Documentation
  • OCR Support
  • Screenshots
  • Security Features
  • Future Improvements
  • Contributing
  • License
  • Author

πŸš€ Overview

The Document Verification System simplifies and secures document verification processes by providing separate dashboards for different user roles.

Employees can upload and manage their documents, Verifiers can review and approve submitted files, while Administrators have complete control over users, verification workflows, audit logs, and system monitoring.

The application follows modern software engineering practices including:

  • Clean architecture
  • RESTful APIs
  • Secure authentication
  • Token-based authorization
  • OCR document extraction
  • Comprehensive audit logging
  • Responsive React frontend
  • Docker containerization

⭐ Key Features

πŸ” Authentication & Security

  • Email Registration
  • Secure Login
  • Strong Password Policy
  • Email OTP Verification
  • JWT Authentication
  • Refresh Token Rotation
  • Token Revocation
  • Account Lockout Protection
  • Password History Validation
  • Forgot Password Workflow
  • Security Questions Verification
  • Date of Birth Verification
  • BCrypt Password Hashing
  • Security Headers Middleware
  • Rate Limiting
  • CORS Protection

πŸ‘₯ Role-Based Access Control (RBAC)

Three independent roles are supported throughout the application.

Role Responsibilities
πŸ‘€ Employee Upload and manage personal documents
βœ… Verifier Review, approve and reject submitted documents
πŸ‘‘ Administrator Complete system administration and monitoring

Administrators can promote users, manage permissions, monitor verification activities, and oversee the entire platform.


πŸ“‚ Document Management

  • Secure File Upload
  • PDF Support
  • Image Support
  • File Type Validation
  • MIME Validation
  • File Size Validation
  • Filename Sanitization
  • OCR Text Extraction
  • Document Preview
  • Download Documents
  • Delete Documents
  • Verification Status Tracking

βœ… Verification Workflow

The verification lifecycle includes:

  • Pending Queue
  • Review Requests
  • Document Approval
  • Document Rejection
  • Verification Remarks
  • Verification History
  • Audit Trail

πŸ‘¨β€πŸ’Ό Administration

Administrators have access to:

  • User Management
  • Role Management
  • Account Activation
  • Account Deactivation
  • User Profiles
  • Verification Statistics
  • Document Oversight
  • Audit Log Viewer
  • Security Monitoring

πŸ“Š Audit Logging

Every important activity is securely recorded, including:

  • User Login
  • Logout
  • Registration
  • Password Changes
  • Password Reset Requests
  • Document Uploads
  • Verification Decisions
  • User Management
  • Role Changes
  • Administrative Operations
  • Client IP Address
  • Browser Information

🎨 Frontend Features

  • React 18
  • Vite
  • Tailwind CSS
  • Responsive Design
  • Dark Mode
  • Glassmorphism UI
  • Animated Components
  • OTP Input Component
  • Charts & Analytics
  • Drag & Drop Uploads
  • Protected Routes
  • Role-Based Navigation

πŸ› οΈ Technology Stack

Category Technology
Backend FastAPI
Frontend React 18
Styling Tailwind CSS
Database PostgreSQL
ORM SQLAlchemy 2.0
Validation Pydantic v2
Authentication JWT
Password Hashing BCrypt
OCR Engine Tesseract OCR
Database Migration Alembic
Charts Recharts
Testing Pytest
Containerization Docker
Version Control Git & GitHub

πŸ—οΈ System Architecture

                        React Frontend
                              β”‚
                              β”‚ REST API
                              β–Ό
                     FastAPI Backend
                              β”‚
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β–Ό               β–Ό               β–Ό
 Authentication   Business Logic   OCR Processing
     β”‚               β”‚               β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β–Ό
             SQLAlchemy ORM
                     β”‚
                     β–Ό
               PostgreSQL

πŸ“ Project Structure

document-verification-system/
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ routers/
β”‚   β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ middleware/
β”‚   β”œβ”€β”€ models.py
β”‚   β”œβ”€β”€ schemas.py
β”‚   β”œβ”€β”€ database.py
β”‚   β”œβ”€β”€ config.py
β”‚   β”œβ”€β”€ auth.py
β”‚   β”œβ”€β”€ dependencies.py
β”‚   β”œβ”€β”€ main.py
β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”œβ”€β”€ seed.py
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── .env.example
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── services/
β”‚   β”‚
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ vite.config.js
β”‚   β”œβ”€β”€ tailwind.config.js
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── nginx.conf
β”‚
β”œβ”€β”€ images_folder/
β”‚   β”œβ”€β”€ admin_dashboard.jpg
β”‚   β”œβ”€β”€ employee_dashboard.jpg
β”‚   β”œβ”€β”€ verifier_dashboard.jpg
β”‚   β”œβ”€β”€ verify_document.jpg
β”‚   β”œβ”€β”€ upload_document.jpg
β”‚   └── ...
β”‚
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ README.md
└── LICENSE

πŸ”’ Security Highlights

  • βœ… JWT Authentication
  • βœ… Refresh Token Rotation
  • βœ… Email OTP Verification
  • βœ… BCrypt Password Hashing
  • βœ… Secure Password Reset Workflow
  • βœ… Password History Validation
  • βœ… Account Lockout Protection
  • βœ… Role-Based Authorization (RBAC)
  • βœ… Audit Logging
  • βœ… Security Headers
  • βœ… Rate Limiting
  • βœ… CORS Protection

βš™οΈ Local Development Setup

πŸ“‹ Prerequisites

Before running the project, ensure the following software is installed:

Software Recommended Version
Python 3.11+
Node.js 18+
npm Latest
PostgreSQL 15+
Git Latest
Docker Desktop (Optional) Latest
Tesseract OCR Latest

πŸ“₯ Clone the Repository

git clone https://github.com/HuzaifaAIDev/document-verification-system.git

cd document-verification-system

πŸ–₯️ Backend Setup

Navigate to the backend directory:

cd backend

Create Virtual Environment

Windows

python -m venv .venv

.venv\Scripts\activate

Linux / macOS

python3 -m venv .venv

source .venv/bin/activate

Install Dependencies

pip install --upgrade pip

pip install -r requirements.txt

Configure Environment Variables

Create a local environment file:

cp .env.example .env

For Windows (PowerShell), if cp is unavailable:

copy .env.example .env

Open the .env file and configure the required values.

Example:

DATABASE_URL=postgresql://username:password@localhost:5432/document_verification

SECRET_KEY=your-generated-secret-key

ACCESS_TOKEN_EXPIRE_MINUTES=30

REFRESH_TOKEN_EXPIRE_DAYS=7

ALGORITHM=HS256

SMTP_SERVER=smtp.gmail.com

SMTP_PORT=587

SMTP_USERNAME=your-email@gmail.com

SMTP_PASSWORD=your-app-password

EMAIL_FROM=your-email@gmail.com

FRONTEND_URL=http://localhost:5173

Important: Never commit your .env file to GitHub. Only commit .env.example.


Generate a Secure Secret Key

Generate a secure secret key:

python -c "import secrets; print(secrets.token_urlsafe(48))"

Copy the generated key into:

SECRET_KEY=

Create the Development Administrator

Run:

python seed.py

This script creates the default administrator account for local development.

Change the default credentials before deploying the application to production.


Run the Backend Server

uvicorn main:app --reload

Backend will be available at:

http://localhost:8000

πŸ“š API Documentation

FastAPI automatically generates interactive API documentation.

Documentation URL
Swagger UI http://localhost:8000/docs
ReDoc http://localhost:8000/redoc
OpenAPI Schema http://localhost:8000/openapi.json

🌐 Frontend Setup

Open a new terminal.

Navigate to the frontend:

cd frontend

Install Dependencies

npm install

Configure Frontend Environment

Create the environment file:

cp .env.example .env

Example:

VITE_API_URL=http://localhost:8000

Start Development Server

npm run dev

Frontend:

http://localhost:5173

🐳 Docker Deployment

Docker allows the complete application stack to run inside containers.


Configure Backend Environment

cp backend/.env.example backend/.env

Update all required environment variables before deployment.


Build Containers

docker compose build

Start Containers

docker compose up

or

docker compose up --build

Run in Detached Mode

docker compose up -d

Stop Containers

docker compose down

πŸ—„οΈ Services

Service URL
React Frontend http://localhost:5173
FastAPI Backend http://localhost:8000
Swagger UI http://localhost:8000/docs
PostgreSQL localhost:5432

πŸ—ƒοΈ Database Migration

This project uses Alembic for version-controlled database migrations.


Generate Migration

alembic revision --autogenerate -m "Initial Migration"

Apply Migration

alembic upgrade head

Roll Back One Migration

alembic downgrade -1

Show Current Migration

alembic current

πŸ§ͺ Running Tests

Navigate to the backend directory:

cd backend

Run all tests:

pytest

Run with verbose output:

pytest -v

Generate a coverage report (if configured):

pytest --cov=.

πŸ“‘ API Modules

Endpoint Description
/auth User authentication and authorization
/users User profile management
/documents Upload and document management
/verifier Document verification workflow
/admin Administrative operations

πŸ”„ Verification Workflow

Employee
    β”‚
    β–Ό
Upload Document
    β”‚
    β–Ό
Pending Verification
    β”‚
    β–Ό
Verifier Review
    β”‚
 β”Œβ”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 β”‚               β”‚
 β–Ό               β–Ό
Approved      Rejected
 β”‚               β”‚
 β–Ό               β–Ό
Visible to User with Status

πŸ“ Supported File Types

The application currently supports:

  • PDF (.pdf)
  • PNG (.png)
  • JPG (.jpg)
  • JPEG (.jpeg)

Additional formats can be integrated in future releases.


πŸ” OCR Processing

The system integrates Tesseract OCR for extracting text from uploaded documents.

Extracted text can be utilized for:

  • Document verification
  • Search functionality
  • Metadata extraction
  • Data validation
  • Future AI-powered document analysis

OCR supports both scanned images and PDF documents.

πŸ“Έ Application Screenshots

The following screenshots demonstrate the primary workflows and interfaces available within the Document Verification System.


πŸ” Sign In

Sign In


πŸ“ Sign Up

Sign Up


πŸ”‘ Reset Password

Reset Password


πŸ‘€ Employee Dashboard

Employee Dashboard


πŸ“€ Upload Document

Upload Document


πŸ“‚ My Documents

My Documents


πŸ‘€ Employee Profile

Employee Profile


βœ… Verifier Dashboard

Verifier Dashboard


πŸ“„ Verify Document

Verify Document


πŸ“œ Verification History

Verification History


πŸ‘₯ Verifier User Details

Verifier User Details


πŸ‘€ Verifier Profile

Verifier Profile


πŸ‘‘ Admin Dashboard

Admin Dashboard


βš™οΈ Admin Console

Admin Console


πŸ‘₯ User Management

User Management


πŸ“‹ Audit Logs

Audit Logs


πŸ‘€ Admin Profile

Admin Profile


πŸ”’ Security Features

The application has been designed with security as a primary objective.

Authentication

  • JWT Access Tokens
  • Refresh Token Rotation
  • Secure Logout
  • Token Revocation
  • Email OTP Verification
  • Password Reset Workflow

Password Protection

  • BCrypt Password Hashing
  • Password History Validation
  • Strong Password Policy
  • Account Lockout Protection

API Security

  • Role-Based Access Control (RBAC)
  • Security Headers Middleware
  • CORS Protection
  • Request Validation
  • Rate Limiting

Monitoring

  • Audit Logging
  • User Activity Tracking
  • Login History
  • Verification History
  • Administrative Action Logging

πŸš€ Future Improvements

The project roadmap includes several enhancements aimed at improving scalability, security, and user experience.

Planned Features

  • Multi-Factor Authentication (MFA)
  • Redis Caching
  • Elasticsearch Integration
  • AI-Powered Document Validation
  • Automatic Fraud Detection
  • Virus & Malware Scanning
  • Digital Signatures
  • Watermarking
  • WebSocket Notifications
  • Email Notifications
  • SMS Notifications
  • Kubernetes Deployment
  • CI/CD Pipeline
  • Cloud Storage Integration
  • Background Task Processing
  • Monitoring with Prometheus & Grafana
  • API Rate Analytics
  • Mobile Application Support

🌍 Production Deployment Recommendations

Before deploying to production, it is recommended to:

  • Enable HTTPS using a trusted SSL certificate.
  • Store secrets securely using environment variables or a secrets manager.
  • Use a managed PostgreSQL database.
  • Configure automated database backups.
  • Use a production SMTP provider.
  • Enable centralized logging.
  • Monitor application health.
  • Configure reverse proxy (Nginx or Traefik).
  • Enable firewall rules.
  • Rotate secrets regularly.
  • Restrict CORS origins.
  • Configure secure cookies.
  • Enable automatic security updates.

🀝 Contributing

Contributions are welcome and appreciated.

If you would like to contribute:

  1. Fork the repository.
  2. Create a feature branch.
git checkout -b feature/your-feature
  1. Commit your changes.
git commit -m "Add new feature"
  1. Push your branch.
git push origin feature/your-feature
  1. Open a Pull Request.

Please ensure that:

  • Code follows the existing style.
  • New functionality includes appropriate tests where applicable.
  • Documentation is updated for any new features.

πŸ“œ License

This project is licensed under the MIT License.

See the LICENSE file for additional details.


πŸ‘¨β€πŸ’» Author

Hafiz Muhammad Huzaifa

Bachelor of Science in Artificial Intelligence

Passionate about building secure, scalable, and production-ready AI and Full-Stack applications using modern software engineering practices.

Connect With Me


⭐ Acknowledgements

Special thanks to the open-source community and the maintainers of the technologies used in this project.

This project is powered by:

  • FastAPI
  • React
  • PostgreSQL
  • SQLAlchemy
  • Pydantic
  • Docker
  • Tesseract OCR
  • Tailwind CSS
  • Alembic
  • Pytest

πŸ’‘ Support

If you find this project helpful:

⭐ Star the repository

🍴 Fork the repository

🐞 Report issues

πŸ’¬ Share suggestions

πŸ“’ Share the project with others

Your support helps improve the project and motivates future development.


❀️ Thank You

Thank you for taking the time to explore the Document Verification System.

Feedback, suggestions, and contributions are always welcome.

About

AI-powered Document Verification System built with FastAPI and React

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages