Skip to content

deanna-spinks/fastapi-service

Repository files navigation

FastAPI Patient Management Service

⚠️ Status: WIP / Exploratory / Learning Project

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.

📋 Table of Contents

🏗️ Architecture

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

🛠️ Tech Stack

  • 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

🚀 Quick Start

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-service

Visit http://localhost:8000/docs for interactive API documentation.

🏃 Running the Service

Option 1: Docker (Recommended)

Development:

docker build -t fastapi-service .
docker run -p 8000:8000 --env-file .env.development fastapi-service

Production:

docker build -f Dockerfile.prod -t fastapi-service:prod .
docker run -p 8000:8000 --env-file .env.prod fastapi-service:prod

Configure via PORT and LOG_LEVEL environment variables.

Option 2: Local Development

Prerequisites: Python 3.13+

  1. 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
  2. Run the service

    uvicorn src.main:app --reload

The service will be available at http://localhost:8000

📚 API Documentation

Once the service is running, visit:

Available Endpoints

Health Check

GET /health

Returns service health status

Root

GET /

Returns "FastAPI Service is running" message

Patient Management

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

Example: Create 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"
  }'

Data Privacy & Safety

  • No real patient data included.
  • Synthetic datasets used for demonstration.
  • Patterns are intentionally generic.

CI / Testing

  • GitHub Actions workflow runs pytest on every push.
  • Docker environment ensures reproducibility.
# Run all tests
pytest

# Run with coverage
pytest --cov=src

📄 License

See LICENSE

📧 Contact

For questions or support, contact: admin@deannaspinks.onmicrosoft.com

About

A modern, cloud-ready Patient Management microservice built with FastAPI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors