This is a FastAPI-based backend system for managing customer orders, billing, and shipping information for Pier 2 Imports. It includes API endpoints for retrieving order history, performing analytics, and ensuring no duplicate customer records.
- Docker & Docker Compose
- Python 3.8+
git clone https://github.com/stekolla/p2-backend.git
cd p2-backend
Create a .env
file in the root directory of the project using .env.local
as an example.
docker-compose up --build
This will start the FastAPI backend and a PostgreSQL database container.
Once running, the API will be available at http://localhost:8000/
- Docs: http://localhost:8000/doc
- Redoc: http://localhost:8000/redoc
For more complex examples, see the examples
folder.
To run unit tests inside the container:
docker-compose exec api pytest
To seed the database with some fake data for local use:
docker-compose exec api python app/database_seed.py
To create a new DB migration:
docker-compose exec api alembic revision --autogenerate -m "Your message here"
Migrations will be applied automatically when the API container starts, or you can apply them manually after creating them.
To apply any new database migrations:
docker-compose exec api alembic upgrade head
To access the database directly:
docker-compose exec db psql -U <user> -d <database>
See PROCESS.md for an overview of my process building this out.