A small, realistic backend service demonstrating API design, data handling, and deployment, built with FastAPI and designed to be deployed as part of a larger system.
It is designed for demonstration and collaboration purposes only — no real patient data is included.
fastapi-service/
├── src/ # Application source code
│ ├── api/ # API layer (routes, handlers, exceptions)
│ ├── core/ # Core functionality and configuration
│ ├── models/ # Pydantic data models
│ ├── storage/ # Data persistence layer
│ └── main.py # Application entry point
├── tests/ # Test suite
├── Dockerfile # Container definition
├── requirements.txt # Python dependencies
└── pyproject.toml # Project configuration
- FastAPI - Modern, fast web framework for building APIs
- Uvicorn - Lightning-fast ASGI server
- Pydantic - Data validation using Python type hints
- Docker - Containerised for distribution and testing
Recommended: Docker (fastest way to get started)
git clone https://github.com/deanna-spinks/fastapi-service.git
cd fastapi-service
docker build -t fastapi-service .
docker run -p 8000:8000 --env-file .env.development fastapi-serviceVisit http://localhost:8000/docs for interactive API documentation.
Development:
docker build -t fastapi-service .
docker run -p 8000:8000 --env-file .env.development fastapi-serviceProduction:
docker build -f Dockerfile.prod -t fastapi-service:prod .
docker run -p 8000:8000 --env-file .env.prod fastapi-service:prodConfigure via PORT and LOG_LEVEL environment variables.
Prerequisites: Python 3.13+
-
Clone and setup
git clone https://github.com/deanna-spinks/fastapi-service.git cd fastapi-service python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt
-
Run the service
uvicorn src.main:app --reload
The service will be available at http://localhost:8000
Once the service is running, visit:
- Interactive API Docs (Swagger): http://localhost:8000/docs
- Alternative API Docs (ReDoc): http://localhost:8000/redoc
GET /health
Returns service health status
GET /
Returns "FastAPI Service is running" message
| Method | Endpoint | Description |
|---|---|---|
| GET | /patients/ |
List all patients |
| POST | /patients/ |
Create a new patient |
| GET | /patients/{id} |
Get a specific patient |
| PATCH | /patients/{id} |
Partially update a patient |
| DELETE | /patients/{id} |
Delete a patient |
curl -X POST "http://localhost:8000/patients/" \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"age": 35,
"gender": "male",
"email": "john.doe@example.com",
"phone": "03 9876 5432"
}'- No real patient data included.
- Synthetic datasets used for demonstration.
- Patterns are intentionally generic.
- GitHub Actions workflow runs pytest on every push.
- Docker environment ensures reproducibility.
# Run all tests
pytest
# Run with coverage
pytest --cov=srcSee LICENSE
For questions or support, contact: admin@deannaspinks.onmicrosoft.com