SIEA (Smart Invoice Entry Automation) is an intelligent invoice processing system that enables users to scan or photograph invoices for automatic data extraction. Built with modern web technologies and AI-powered OCR, it automatically extracts invoice data and stores it securely with enterprise-grade encryption.
- Camera Integration: Real-time invoice scanning with web camera
- File Upload: Drag & drop invoice photo upload
- AI-Powered OCR: Google Gemini 1.5 Flash for intelligent data extraction
- Secure Storage: PostgreSQL database with AES-256 encryption
- Excel Export: Styled Excel file generation (.xlsx)
- Data Security: 5-year automatic data retention policy
- User Management: JWT-based authentication system
- Responsive Design: Mobile and desktop compatible interface
- Modern UI: User-friendly interface designed with Tailwind CSS
- Multi-language: Turkish and English invoice support
- Containerized: Full Docker support for easy deployment
- Framework: FastAPI (Python)
- Database: PostgreSQL
- ORM: SQLAlchemy
- Authentication: JWT + bcrypt
- AI OCR: Google Gemini 1.5 Flash
- Excel Export: pandas + openpyxl + xlsxwriter
- Encryption: cryptography (Fernet)
- Framework: React.js 18
- Routing: React Router DOM
- Styling: Tailwind CSS
- Icons: Lucide React
- Camera: react-webcam
- File Upload: react-dropzone
- Notifications: react-toastify
- HTTP Client: Axios
- Containerization: Docker & Docker Compose
- Web Server: Nginx
- SSL: Let's Encrypt ready
- Database Migration: Custom migration system
- Python: 3.8+
- Node.js: 16+
- PostgreSQL: 12+
- Google Gemini API Key
# Clone the repository
git clone https://github.com/yourusername/SIEA.git
cd SIEA
# Run automatic setup
python setup.py# Copy environment template
cp backend/env_example.txt backend/.env
# Generate secure keys
python -c "import secrets; print('SECRET_KEY=' + secrets.token_urlsafe(32))"
python -c "from cryptography.fernet import Fernet; print('ENCRYPTION_KEY=' + Fernet.generate_key().decode())"Update backend/.env with your values:
DATABASE_URL=postgresql://username:password@localhost:5432/siea_db
SECRET_KEY=your-generated-secret-key
ENCRYPTION_KEY=your-generated-encryption-key
GEMINI_API_KEY=your-gemini-api-key
MAX_FILE_SIZE=10485760
ALLOWED_EXTENSIONS=.jpg,.jpeg,.png,.pdf# Install PostgreSQL and create database
createdb siea_db
# Run migrations
cd backend
python database/migrations.pycd backend
pip install -r requirements.txt
python main.pycd frontend
npm install
npm startdocker-compose -f docker-compose.dev.yml up --builddocker-compose up --buildOnce the backend is running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/register |
User registration |
| POST | /auth/login |
User login |
| POST | /invoices/upload |
Upload and process invoice |
| GET | /invoices |
Get user's invoices |
| GET | /invoices/export/excel |
Export invoices to Excel |
| POST | /debug/ocr |
Debug OCR processing |
| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | - |
SECRET_KEY |
JWT secret key | - |
ENCRYPTION_KEY |
Fernet encryption key | - |
GEMINI_API_KEY |
Google Gemini API key | - |
MAX_FILE_SIZE |
Maximum upload size (bytes) | 10485760 |
ALLOWED_EXTENSIONS |
Allowed file extensions | .jpg,.jpeg,.png,.pdf |
- Visit Google AI Studio
- Create a new API key
- Add it to your
.envfile
SIEA/
βββ backend/ # FastAPI backend
β βββ database/ # Database models and migrations
β βββ schemas/ # Pydantic schemas
β βββ services/ # Business logic services
β βββ main.py # FastAPI application
β βββ requirements.txt # Python dependencies
βββ frontend/ # React frontend
β βββ public/ # Static files
β βββ src/ # React source code
β β βββ components/ # Reusable components
β β βββ contexts/ # React contexts
β β βββ pages/ # Page components
β β βββ App.js # Main App component
β βββ package.json # Node.js dependencies
βββ scripts/ # Deployment scripts
βββ docker-compose.yml # Production Docker setup
βββ docker-compose.dev.yml # Development Docker setup
βββ README.md # This file
- Data Encryption: All sensitive data encrypted with Fernet (AES-256)
- JWT Authentication: Secure token-based authentication
- Password Hashing: bcrypt with salt
- SQL Injection Protection: SQLAlchemy ORM
- CORS Protection: Configurable CORS settings
- File Validation: Type and size validation
- Data Retention: Automatic cleanup after 5 years
- Company Name: Extracted from the top of the invoice
- Invoice Number: Found after "FATURA NO:", "INVOICE NO:", etc.
- Invoice Date: Date in DD.MM.YYYY or DD/MM/YYYY format
- Total Amount: Total amount without currency symbol
- Tax Amount: VAT/KDV amount without currency symbol
- Model: Google Gemini 1.5 Flash
- Languages: Turkish and English
- Accuracy: High accuracy with structured prompts
- Fallback: Regex-based extraction for non-JSON responses
- ID, email, full name, password hash
- Creation and update timestamps
- Active status
- ID, filename, processing timestamp
- Extracted data (encrypted JSON)
- Company name, invoice number, date
- Total amount, tax amount
- User relationship
- Expiration date (5 years)
- Database Indexing: Optimized queries with proper indexes
- Image Processing: Efficient image handling
- Lazy Loading: Frontend components loaded on demand
- Code Splitting: Optimized bundle sizes
- Caching: Session caching with potential Redis integration
# Backend tests
cd backend
python -m pytest
# Frontend tests
cd frontend
npm test-
Server Setup:
# Install Docker and Docker Compose curl -fsSL https://get.docker.com -o get-docker.sh sh get-docker.sh -
SSL Configuration:
# Update nginx.conf with your domain # Configure Let's Encrypt
-
Deploy:
./scripts/deploy-production.sh
- Heroku: Use provided Procfile
- Railway: Direct deployment support
- AWS: ECS with provided Docker images
- DigitalOcean: App Platform compatible
-
Gemini API Errors:
- Verify API key is correct
- Check API quotas and limits
- Ensure proper image format
-
Database Connection:
- Verify PostgreSQL is running
- Check connection string format
- Ensure database exists
-
Frontend Build Issues:
- Clear node_modules:
rm -rf node_modules && npm install - Check Node.js version compatibility
- Clear node_modules:
Enable debug logging by setting environment variable:
export DEBUG=true- Multi-language Support: Additional language support
- Batch Processing: Multiple invoice upload
- API Integration: Third-party accounting software
- Mobile App: React Native mobile application
- Advanced Analytics: Invoice analytics dashboard
- Cloud Storage: AWS S3 integration
- OCR Improvements: Custom model training
- Fork the repository
- Create your 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
- Follow PEP 8 for Python code
- Use ESLint for JavaScript code
- Write tests for new features
- Update documentation as needed
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Check this README and code comments
- Issues: Open an issue on GitHub
- Discussions: Use GitHub Discussions for questions
- Google Gemini: AI-powered OCR capabilities
- FastAPI: High-performance Python web framework
- React: Frontend user interface library
- Tailwind CSS: Utility-first CSS framework
- PostgreSQL: Robust database system