A Python-based global solution for scanning passports and verifying visa validity using Optical Character Recognition (OCR) and various API/data sources.
- Passport Image Upload or Scanning: Allows users to upload or scan passport images.
- OCR for Passport Data Extraction: Uses Tesseract OCR to extract passport details such as passport number, nationality, and date of birth.
- Visa Validity Check: Validates visa information against predefined rules (or through external API integration if available).
- User Authentication: Secure user registration and login system using Flask-Login.
- Database Management: Stores passport and visa details using SQLite.
- Security: Data encryption for sensitive information and HTTPS support for secure communication.
- Technologies Used
- Project Architecture
- Installation
- Usage
- API Endpoints
- Security Considerations
- Deployment
- ToDo
- Contribution
- License
- Python 3.9: Core programming language.
- Flask: Web framework used for creating the web application.
- OpenCV: For image processing and passport scanning.
- Tesseract-OCR: Optical Character Recognition library for extracting text from passport images.
- SQLAlchemy: ORM for database management (SQLite).
- Flask-Login: For user authentication and session management.
- Flask-WTF: For secure forms and CSRF protection.
+----------------------------------------------+
| User Interface (UI) |
| - HTML/CSS/JavaScript |
| - Passport Image Upload Form |
+----------------------------------------------+
|
v
+--------------------------------------------------+
| Web Application (Flask) |
| - Routes: |
| - `/upload`: Handles passport image upload |
| - `/register`: User registration |
| - `/login`: User login |
| - Authentication: Flask-Login |
| - Handles form submissions and processes data |
+--------------------------------------------------+
|
v
+--------------------------------------------------+
| OCR & Image Processing |
| - Tesseract: Extracts text from passport images |
| - OpenCV: Preprocesses images (grayscale, etc.) |
| - Focuses on the MRZ for passport data |
+--------------------------------------------------+
|
v
+--------------------------------------------------+
| Visa Validation Logic |
| - Validates visa expiration date |
| - Checks issuing country and visa number |
| - Predefined rules or external API integration |
+--------------------------------------------------+
|
v
+--------------------------------------------------+
| Database (SQLite/SQLAlchemy) |
| - User Table: Stores user credentials |
| - Passport Table: Stores passport details |
| - Visa Table: Stores visa details |
| - Logs all scans for auditing |
+--------------------------------------------------+
|
v
+--------------------------------------------------+
| Security Layer |
| - User Authentication via Flask-Login |
| - Data encryption using cryptography library |
| - HTTPS for secure communication |
| - CSRF protection via Flask-WTF |
+--------------------------------------------------+
|
v
+--------------------------------------------------+
| Deployment (Cloud) |
| - Dockerized for portability |
| - Deployable on Heroku or AWS |
| - Autoscaling and monitoring for production |
+--------------------------------------------------+
- User Interaction: Users interact with the web interface to upload passport images.
- File Upload: The Flask backend processes the uploaded images.
- OCR & Processing: The image is preprocessed, and Tesseract extracts passport details.
- Visa Validation: Visa information is validated using predefined rules or external APIs.
- Database Storage: All passport and visa details are stored securely in SQLite.
- Security: Data encryption and authentication ensure secure handling of sensitive data.
- Deployment: The app is packaged in Docker and deployed to cloud platforms like Heroku or AWS.
- Python 3.9+
- Tesseract-OCR installed on your machine (for OCR functionality)
- Install Tesseract: Installation Guide
-
Clone the repository:
git clone https://github.com/fahmifareed/worldwide-visa-check.git cd worldwide-visa-check
-
Set up a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Initialize the database:
python >>> from app import create_app, db >>> app = create_app() >>> with app.app_context(): >>> db.create_all()
-
Run the application:
flask run
-
Open a browser and visit:
http://127.0.0.1:5000
- Visit
/register
to create a new user account. - Provide a username, email, and password to register.
- After registering, visit
/login
to log in with your credentials.
- Once logged in, navigate to the homepage.
- Upload an image of a passport to initiate OCR processing.
- The system will extract passport details (name, passport number, nationality) and validate visa details if available.
Uploads a passport image and returns extracted details.
- Request: Form data with the passport image file.
- Response: Extracted passport and visa details.
Registers a new user.
- Request: JSON data with
username
,email
, andpassword
. - Response: Success or failure message.
Logs in an existing user.
- Request: JSON data with
username
andpassword
. - Response: Success or failure message.
Logs out the current user.
- Request: No data required.
- Response: Redirects to login page.
- Encryption: Passport and visa details are encrypted before being stored in the database using the
cryptography
library. - HTTPS: Use HTTPS for secure data transmission in production environments.
- Authentication: User authentication is handled with Flask-Login. Passwords are hashed and stored securely.
- CSRF Protection: Flask-WTF provides built-in CSRF protection for all forms.
-
Install the Heroku CLI and log in.
heroku login
-
Create a new Heroku app:
heroku create worldwide-visa-check
-
Push the code to Heroku:
git push heroku main
-
Set up environment variables for Flask:
heroku config:set FLASK_APP=run.py
-
Open the deployed app:
heroku open
Alternatively, you can deploy the application to AWS using Elastic Beanstalk for scalability.
-
Improve UI/UX
-
Enhance the UI for better user experience (mobile and desktop).
-
Extend Visa Validation Logic
-
Integrate real-time visa validation APIs (if available).
-
Cloud Storage Integration
-
Use AWS S3 or other cloud storage to store uploaded images.
-
Fork the repository.
-
Create a new feature branch:
git checkout -b feature/your-feature
-
Commit your changes:
git commit -m "Add your feature"
-
Push the branch to GitHub:
git push origin feature/your-feature
-
Create a Pull Request on the main repository.
This project is licensed under the MIT License. See the LICENSE file for more information.
Let me know if you'd like further changes!