Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

📌 Task Management API

A production-ready RESTful backend system built using FastAPI, PostgreSQL, and SQLAlchemy, supporting full CRUD operations, JWT authentication, pagination, and filtering.

🚀 Features

Full CRUD operations for task management

PostgreSQL relational database integration

SQLAlchemy ORM for query abstraction

JWT-based authentication (HS256)

Dependency injection for DB session management

Pagination using skip and limit

Dynamic filtering (completed=true/false)

Timestamp auditing (created_at, updated_at)

Clean layered architecture (Router → Service → Model)

🏗️ Architecture

The project follows a layered backend architecture:

Client ↓ FastAPI Router (HTTP layer) ↓ Service Layer (Business Logic) ↓ SQLAlchemy ORM ↓ PostgreSQL Database Folder Structure app/ ├── core/ │ ├── config.py │ ├── security.py │ └── dependencies.py ├── db/ │ └── database.py ├── models/ │ └── task_model.py ├── schemas/ │ └── task_schema.py ├── services/ │ └── task_service.py ├── routers/ │ ├── tasks.py │ └── auth.py └── main.py 🔐 Authentication

JWT authentication is implemented using the HS256 algorithm.

Token contains sub (username) and expiration claim.

Tokens are signed using a secret key.

Protected routes validate tokens using dependency injection.

Invalid or expired tokens return 401 Unauthorized.

🗄️ Database Schema Table: tasks Column Type Description id Integer Primary Key title String Task title description String Optional details completed Boolean Task status created_at Timestamp Auto-generated updated_at Timestamp Auto-updated

Indexes:

Primary key indexed

completed indexed for filtering efficiency

📡 API Endpoints Authentication POST /login

Returns JWT access token.

Tasks (Protected) POST /tasks/ GET /tasks/ GET /tasks/?completed=true GET /tasks/?skip=0&limit=10 PUT /tasks/{task_id} DELETE /tasks/{task_id} ⚙️ Setup Instructions 1️⃣ Clone Repository git clone cd task-manager-api 2️⃣ Create Virtual Environment python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate 3️⃣ Install Dependencies pip install -r requirements.txt 4️⃣ Configure Environment Variables

Create .env file:

DATABASE_URL=postgresql://username:password@localhost:5432/taskdb SECRET_KEY=your-secret-key 5️⃣ Run Server uvicorn app.main:app --reload

Swagger docs available at:

http://127.0.0.1:8000/docs 🧠 Key Engineering Decisions

Used SQLAlchemy ORM for abstraction and maintainability.

Implemented service layer to separate HTTP from business logic.

Used dependency injection for DB session lifecycle management.

Added pagination to ensure scalability.

Centralized configuration using environment variables.

Designed system for future RBAC integration.

🔮 Future Improvements

Role-Based Access Control (RBAC)

Refresh tokens

Docker containerization

Unit testing with pytest

CI/CD integration

Deployment to cloud (Render / AWS / Railway)

🎯 Learning Outcomes

This project demonstrates:

Backend API design

Database schema normalization

Authentication flow with JWT

Clean architecture principles

Scalable query handling

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages