Skip to content

Modular Flask REST API for school records using Azure DB PostgreSQL. Dockerized, tested with Pytest, CI/CD integrated, featuring CRUD, bulk ops, and structured error handling.

License

Notifications You must be signed in to change notification settings

victoriacheng15/school-management-api

Repository files navigation

School Management API

A backend and DevOps learning project that simulates a real-world school management system. It started as a simple SQLite prototype and evolved into a Dockerized Flask API connected to Azure Database for PostgreSQL, complete with automated CI/CD and test coverage reporting.

πŸ“Ί Demos

Flask API in Production

Watch a Flask REST API in action, deployed on Azure Web App with Docker, using ACR for images, Azure PostgreSQL for data, and Nginx to hide the long Azure URL behind a simple endpoint...

πŸ‘‰ Watch the Demo

Infrastructure as Code with Terraform

See how Terraform provisions the same Azure backend (PostgreSQL + Web App) declaratively, replacing manual portal clicks with versioned, repeatable code. This demo covers terraform plan, apply, and real-time validation in the Azure Portal.

⚠️ Not used in production
The live School Management API is deployed via GitHub Actions + Docker + GHCR, not Terraform.
This setup is ephemeral β€” created for demo and destroyed afterward.

πŸ‘‰ Watch the Terraform Demo


🧰 Tech Stack

Python Flask PostgreSQL Azure Docker Pytest GitHub Actions

πŸ“˜ Documentation & Notes

🧠 Why I Built This

I built this project to gain real backend engineering experience beyond tutorials β€” focusing on how systems evolve from local development to cloud deployment.

Goals

  • Design clean, modular REST APIs for multiple entities
  • Implement CRUD + archiving logic to preserve data history
  • Write maintainable and testable backend logic
  • Practice containerization using multi-stage Docker builds
  • Build automated CI/CD pipelines for linting, testing, and coverage reporting
  • Deploy to the cloud with Azure Database for PostgreSQL

DevOps & Automation

  • Continuous integration via GitHub Actions
  • Ruff for formatting and linting
  • Pytest for unit and integration testing
  • Coverage reports automatically posted in pull requests

βš™οΈ What It Does

  • Exposes RESTful endpoints for students, instructors, courses, enrollments, and more
  • Supports full CRUD + soft-delete (archive) logic
  • Uses PostgreSQL (Dockerized locally, Azure-managed in production)
  • Fully containerized for consistent deployment
  • Includes automated tests for routes and business logic

🌍 Environment Overview

This project is designed to simulate real development and deployment environments:

Environment Description
Local (Direct) Run Flask API with your local Python env and PostgreSQL. Fastest for debugging.
Local (Dockerized) Use Docker Compose to spin up Flask API + PostgreSQL. Reproducible, isolated environment.
Production (Azure) Deployed Flask API connected to Azure Database for PostgreSQL. Provides reliability, backups, scalability.

πŸ§ͺ Running Locally

1. Local Development (Direct)

# Install dependencies
pip install -r requirements.txt
# Run app
python run.py

(Optionally, install PostgreSQL locally and configure your .env.)

2. Local Development (Dockerized) - Recommended

make up      # start API + DB containers via Docker Compose
./api_client.sh read students
make down    # stop containers
make down V=1  # clear volumes if needed

3. Production (Azure)

  • Deploy Docker image via ACR to Azure Web App
  • Connect to Azure Database for PostgreSQL
  • Update environment variables and run init scripts (scripts/init_azure_db.sh)

οΏ½ API Highlights

Includes a helper Bash script api_client.sh to simplify testing via command line.

./api_client.sh read students
./api_client.sh create instructors
./api_client.sh archive courses
Resource GET POST PUT PATCH (Archive)
Students βœ” βœ” βœ” βœ”
Instructors βœ” βœ” βœ” βœ”
Courses βœ” βœ” βœ” βœ”
Enrollments βœ” βœ” βœ” βœ”
Programs βœ” βœ” βœ” βœ”
Departments βœ” βœ” βœ” βœ”
Assignments βœ” βœ” βœ” βœ”
Terms βœ” βœ” βœ” βœ”

🧾 Summary

This project evolved from a simple CRUD API into a production-ready backend with:

  • Dockerized PostgreSQL
  • Automated CI/CD
  • Cloud deployment on Azure

It represents a practical journey through backend design, DevOps practices, and system evolution β€” the way real-world services grow.

About

Modular Flask REST API for school records using Azure DB PostgreSQL. Dockerized, tested with Pytest, CI/CD integrated, featuring CRUD, bulk ops, and structured error handling.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors 3

  •  
  •  
  •