Before you begin
Make sure you have completed the Installation guide and have:- Python 3.8+ installed
- MySQL database running
- All dependencies installed
- Environment variables configured
Quick setup
Start the development server
Navigate to your project directory and activate your virtual environment:Start the FastAPI server with auto-reload enabled:The server will start on
http://localhost:8000 with the API accessible at http://localhost:8000/api.The
--reload flag enables hot reloading, which automatically restarts the server when you make code changes. Perfect for development!Verify the server is running
Open a new terminal window and test the health check endpoint:You should receive:
Explore the interactive documentation
Explore the interactive documentation
FastAPI automatically generates interactive API documentation. Visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Create a user account
Register a new user using the signup endpoint:Expected response:
The password must be at least 6 characters long. In production, use strong passwords with mixed case, numbers, and special characters.
Authenticate and get an access token
Log in with your credentials to receive a JWT access token:Expected response:Store the token in an environment variable for easier use:
Make your first authenticated request
Now you can make authenticated API calls by including the token in the Authorization header.Let’s add a product to your inventory:Expected response:
Understanding authentication
Understanding authentication
ExpireEye uses JWT (JSON Web Tokens) for authentication:
- All protected endpoints require an
Authorizationheader - The header format is:
Authorization: Bearer <your_token> - Tokens contain encoded user information (userId, email)
- The backend middleware validates tokens on every request
POST /api/auth/loginPOST /api/auth/signupGET /api/status
What you just learned
Congratulations! You’ve successfully:- Started the ExpireEye Backend server
- Created a user account
- Authenticated and received a JWT token
- Made authenticated API requests
- Added and retrieved products from the inventory
Common API patterns
Working with user-specific inventory
Add products to your personal inventory with expiry dates:Getting notifications
The API includes a notification system for expiring products. Access via WebSocket:Uploading images for detection
Use the YOLO detection endpoint to identify products from images:Next steps
Now that you’re up and running, explore more features:- Browse the API Reference for detailed endpoint documentation
- Check out Authentication to learn more about JWT tokens and security
- Explore WebSocket Notifications for real-time notifications
- Learn about Features to understand all capabilities
Troubleshooting
401 Unauthorized error
401 Unauthorized error
Database connection errors
Database connection errors
If you see database connection errors:
- Verify MySQL is running:
mysql -u root -p - Check your
.envdatabase credentials - Ensure the database exists:
SHOW DATABASES; - Run migrations if needed:
alembic upgrade head
Module not found errors
Module not found errors
Missing Python dependencies:Make sure your virtual environment is activated before installing.
Port already in use
Port already in use
If port 8000 is occupied, specify a different port:Then access the API at
http://localhost:8001/apiFor more detailed troubleshooting, check the terminal output where uvicorn is running. FastAPI provides helpful error messages and stack traces during development.