Skip to content

KoxiPi/distributed-task-microservice

Repository files navigation

Distributed RESTful Task Microservice

A containerized backend service for authenticated task management, built with Flask, PostgreSQL, Docker Compose, and GitHub Actions. The project is designed to show production-minded backend fundamentals: secure authentication, clean API boundaries, isolated infrastructure, automated checks, and a developer-friendly local setup.

Highlights

  • JWT-based authentication with Bcrypt password hashing
  • User-scoped task CRUD endpoints with request validation
  • PostgreSQL persistence with SQLAlchemy connection pooling
  • Docker Compose orchestration for one-command local startup
  • Pytest and Ruff wired into GitHub Actions CI

Tech Stack

  • Python 3.12
  • Flask
  • PostgreSQL
  • SQLAlchemy
  • Docker and Docker Compose
  • Pytest
  • Ruff
  • GitHub Actions

Architecture

Client
  |
  v
Flask API (`/api/v1`)
  |-- Auth routes
  |-- Task routes
  |
  v
SQLAlchemy ORM
  |
  v
PostgreSQL

The application layer is split into focused modules for config, extensions, auth, tasks, models, and payload validation. Docker Compose isolates the API and database services while keeping the developer workflow simple.

Project Structure

.
|-- app/
|   |-- auth/
|   |-- tasks/
|   |-- config.py
|   |-- extensions.py
|   |-- models.py
|   `-- schemas.py
|-- tests/
|-- .github/workflows/ci.yml
|-- docker-compose.yml
|-- Dockerfile
|-- requirements.txt
`-- run.py

Quick Start

  1. Copy .env.example to .env.
  2. Run docker compose up --build.
  3. Open http://localhost:5000/health.

API Overview

Auth

  • POST /api/v1/auth/register
  • POST /api/v1/auth/login

Tasks

  • GET /api/v1/tasks
  • POST /api/v1/tasks
  • GET /api/v1/tasks/<task_id>
  • PUT /api/v1/tasks/<task_id>
  • DELETE /api/v1/tasks/<task_id>

Example Flow

Register a user:

curl -X POST http://localhost:5000/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "engineer@example.com",
    "password": "password123",
    "password_confirmation": "password123"
  }'

Create a task with the returned JWT:

curl -X POST http://localhost:5000/api/v1/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <access_token>" \
  -d '{
    "title": "Ship backend service",
    "description": "Implement auth, CRUD, tests, and Docker support"
  }'

Local Quality Checks

ruff check .
pytest

Why This Project Matters

This repository is intentionally scoped like a strong portfolio backend project: it demonstrates API design, authentication, database integration, containerization, automated validation, and clean project organization without burying the core ideas under unnecessary complexity.

About

Distributed RESTful task microservice built with Flask, Docker, and PostgreSQL.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors