Prerequisites
Before you begin, ensure you have the following installed on your system:- Python 3.8 or higher - The backend is built with FastAPI and requires Python 3.8+
- MySQL Server - Database server (MySQL 5.7+ or MariaDB 10.3+)
- pip - Python package installer (usually comes with Python)
- Git - For cloning the repository
You can verify your Python version by running
python --version or python3 --version in your terminal.Installation steps
Create a virtual environment
Itβs recommended to use a virtual environment to isolate project dependencies:Activate the virtual environment:
When activated, you should see
(venv) at the beginning of your terminal prompt.Install dependencies
Install all required Python packages from the requirements file:This will install FastAPI, SQLAlchemy, Uvicorn, and other dependencies including:
fastapi==0.116.1- Web frameworkuvicorn==0.35.0- ASGI serversqlalchemy==2.0.41- ORM for database operationsalembic==1.16.4- Database migration toolbcrypt==4.3.0- Password hashingPyJWT==2.10.1- JWT token handlingpymssql==2.3.7- MySQL database driverpython-dotenv==1.1.1- Environment variable management
Set up MySQL database
Create a new MySQL database for the project:Create a database user (optional but recommended):
Configure environment variables
Copy the example environment file and configure it with your settings:Open
.env in your text editor and update the following variables:How to generate a secure SECRET_KEY
How to generate a secure SECRET_KEY
You can generate a secure secret key using Python:Or using OpenSSL in your terminal:
The Nutrition API and Cloudinary credentials are optional. The core authentication and product management features will work without them.
Run database migrations
Initialize the database schema using Alembic migrations:This command will create all necessary tables in your database including:
users- User accounts and authenticationproducts- Product master inventoryuser_products- User-specific product instances with expiry datesnotifications- Expiry notificationsnutrition- Nutritional informationscan_logs- Product scan history
Troubleshooting migration errors
Troubleshooting migration errors
If you encounter errors during migration:
- Connection refused: Verify MySQL is running and credentials are correct
- Permission denied: Ensure the database user has proper privileges
- Table already exists: Reset the database and run migrations again:
Next steps
Now that you have ExpireEye Backend installed, you can:- Follow the Quickstart guide to make your first API request
- Explore the interactive API documentation at
http://localhost:8000/docs - Review the API Reference for detailed endpoint documentation
Optional configuration
YOLO object detection
The backend includes YOLO-based product detection capabilities. To use this feature:- Ensure you have CUDA-compatible GPU for optimal performance (optional)
- The required PyTorch and YOLO dependencies are already in
requirements.txt - Model weights will be downloaded automatically on first use
Production deployment
For production environments:- Set
--reloadto false when starting uvicorn - Use a production-grade ASGI server like Gunicorn with Uvicorn workers
- Configure proper CORS origins in
app/main.py - Use environment-specific
.envfiles - Enable HTTPS/SSL certificates
- Set up proper database connection pooling