Task Manager API

A RESTful API for managing tasks and users built with FastAPI and SQLite.

Features

  • User authentication with JWT tokens
  • User registration and management
  • Task management with CRUD operations
  • Task filtering and pagination
  • Health check endpoint
  • OpenAPI documentation

Tech Stack

  • FastAPI: Modern, fast web framework for building APIs
  • SQLAlchemy: SQL toolkit and ORM
  • Alembic: Database migration tool
  • SQLite: Lightweight, file-based database
  • Pydantic: Data validation and settings management
  • JWT: JSON Web Tokens for authentication
  • Uvicorn: ASGI server for running the application

Project Structure

taskmanagerapi/
│
├── app/                    # Application package
│   ├── api/                # API endpoints
│   │   └── v1/             # API version 1
│   │       ├── endpoints/  # API endpoint modules
│   │       └── api.py      # API router
│   │
│   ├── core/               # Core modules
│   │   ├── config/         # Configuration
│   │   └── security/       # Security utilities
│   │
│   ├── crud/               # CRUD operations
│   ├── db/                 # Database setup and session
│   ├── models/             # SQLAlchemy models
│   └── schemas/            # Pydantic schemas
│
├── migrations/             # Alembic migrations
│   └── versions/           # Migration versions
│
├── alembic.ini             # Alembic configuration
├── main.py                 # Application entry point
├── requirements.txt        # Project dependencies
└── README.md               # Project documentation

Environment Variables

The application uses the following environment variables:

Variable Description Default
SECRET_KEY Secret key for JWT token generation Auto-generated secure token
ACCESS_TOKEN_EXPIRE_MINUTES JWT token expiration time in minutes 11520 (8 days)
DATABASE_URL SQLite database URL sqlite:////app/storage/db/db.sqlite

Getting Started

Prerequisites

  • Python 3.8+

Installation

  1. Clone the repository:
git clone <repository-url>
cd taskmanagerapi
  1. Install dependencies:
pip install -r requirements.txt
  1. Run database migrations:
alembic upgrade head

Running the Application

Run the application with Uvicorn:

uvicorn main:app --reload

The API will be available at http://127.0.0.1:8000.

API Documentation

Once the application is running, you can access:

API Endpoints

Authentication

  • POST /api/v1/auth/login - Get access token
  • POST /api/v1/auth/register - Register a new user

Users

  • GET /api/v1/users/me - Get current user
  • PUT /api/v1/users/me - Update current user
  • GET /api/v1/users/{user_id} - Get user by ID (admin only)
  • GET /api/v1/users/ - Get all users (admin only)

Tasks

  • GET /api/v1/tasks/ - Get all user's tasks
  • POST /api/v1/tasks/ - Create a new task
  • GET /api/v1/tasks/{task_id} - Get task by ID
  • PUT /api/v1/tasks/{task_id} - Update a task
  • DELETE /api/v1/tasks/{task_id} - Delete a task

Health Check

  • GET /health - Check API health status
Description
Project: Task Manager API
Readme 64 KiB
Languages
Python 98.3%
Mako 1.7%