This project is a template for a FastAPI application with a MySQL database, using Uvicorn as the ASGI server, Alembic for database migrations, and Redis for caching or background tasks.
Before you start, ensure you have the following installed:
- Python 3.8+
- MySQL database
- Redis server
pip
(Python package installer)
Follow these steps to get the application up and running.
git clone https://github.com/pndiku/backend-developer-test.git
cd backend-developer-test
Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
Install the required Python packages:
pip install -r requirements.txt
Create a .env
file in the project root directory and add the following environment variables:
DATABASE_URL=mysql+pymysql://backend:backend@localhost/backend_db
REDIS_URL=redis://localhost:6379/0
Ensure your MySQL server is running. Then, initialize the database using Alembic:
alembic upgrade head
Start the Uvicorn server to run your FastAPI application:
uvicorn app.main:app --reload
This command will start the server at http://127.0.0.1:8000
.
This project is licensed under the MIT License. See the LICENSE
file for details.