A Flask-based web application for managing incoming and outgoing letters with OCR (Optical Character Recognition) features to extract text from scanned letter images.
- OCR Processing: Extract text from scanned letter images
- Incoming Letter Management: Input, edit, and view incoming letters
- Outgoing Letter Management: Input, edit, and view outgoing letters with supervisor approval
- Authentication System: Login with admin and supervisor roles
- Dashboard: Statistics and letter reports
- Document Generation: Automatic leave letter generation
- Python 3.8 or newer
- pip (Python package installer)
- Tesseract OCR Engine
brew install tesseract
brew install tesseract-lang # For Indonesian languagesudo apt update
sudo apt install tesseract-ocr
sudo apt install tesseract-ocr-ind # For Indonesian language- Download installer from GitHub Tesseract
- Install and ensure it's added to PATH
- Download Indonesian language data from tessdata
git clone <repository-url>
cd OCR-ScanLetter_WebApp# Create virtual environment
python -m venv venv
# Activate virtual environment
# macOS/Linux:
source venv/bin/activate
# Windows:
venv\Scripts\activatepip install -r requirements.txtCreate a .env file in the root directory:
FLASK_APP=app.py
FLASK_ENV=development
SECRET_KEY=your-secret-key-here
DATABASE_URL=sqlite:///instance/app.db# Run the application to create database
python app.pypython app.pyThe application will run at http://localhost:5001
id: Primary keyusername: Username for loginemail: User emailpassword_hash: Hashed passwordrole: User role (admin/supervisor)is_approved: User approval statuscreated_at: Creation timestamp
id_suratKeluar: Primary keytanggal_suratKeluar: Letter datepengirim_suratKeluar: Letter senderpenerima_suratKeluar: Letter recipientnomor_suratKeluar: Letter numberkode_suratKeluar: Letter codejenis_suratKeluar: Letter typeisi_suratKeluar: Letter contentgambar_suratKeluar: Letter image filestatus_suratKeluar: Letter status (approved)created_at: Creation timestamp
id_suratMasuk: Primary keytanggal_suratMasuk: Letter datepengirim_suratMasuk: Letter senderpenerima_suratMasuk: Letter recipientnomor_suratMasuk: Letter numberkode_suratMasuk: Letter codejenis_suratMasuk: Letter typeisi_suratMasuk: Letter contentfile_suratMasuk: Letter filestatus_suratMasuk: Letter status (pending/approved/rejected)created_at: Creation timestamp
- Access
http://localhost:5001 - Login with username and password
- Roles: admin or supervisor
- Menu: "Input Surat Masuk"
- Upload letter image
- Fill letter data form
- Letter automatically gets "Approved" status
- Menu: "Input Surat Keluar"
- Upload letter file
- Fill letter data form
- Letter gets "Pending" status awaiting supervisor approval
- Menu: "Persetujuan Surat" → "Surat Keluar Pending"
- View list of pending outgoing letters
- Click "Approve" or "Reject"
- Menu: "OCR Surat Masuk" or "OCR Surat Keluar"
- Upload letter image
- System will automatically extract text
- Edit extraction results if needed
- Menu: "Laporan Statistik"
- View charts and letter statistics
- Application uses PIL (Pillow) instead of OpenCV
- Ensure Pillow is installed:
pip install Pillow
- Ensure Tesseract OCR is installed
- Set environment variable
TESSDATA_PREFIXif needed - For Windows, ensure Tesseract is in PATH
- Delete
instance/app.dbfile if exists - Restart application to create new database
- Ensure
static/ocr/uploadsfolder has write permission - Create folder if it doesn't exist
Flask==3.1.0: Web frameworkFlask-Login==0.6.3: User session managementFlask-SQLAlchemy==3.1.1: Database ORMFlask-WTF==1.2.2: Form handling
Pillow==11.1.0: Image processingpytesseract==0.3.13: OCR engine wrapper
python-docx==1.2.0: Word document processingdocx-mailmerge2==0.9.0: Mail merge functionality
SQLAlchemy==2.0.37: Database ORMalembic==1.14.1: Database migrations
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Project Link: https://github.com/asmuiahmad/OCR-ScanLetter_WebApp.git