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
- Clone the repository:
git clone <repository-url>
cd taskmanagerapi
- Install dependencies:
pip install -r requirements.txt
- 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:
- Interactive API documentation: http://127.0.0.1:8000/docs
- Alternative API documentation: http://127.0.0.1:8000/redoc
- OpenAPI schema: http://127.0.0.1:8000/openapi.json
API Endpoints
Authentication
POST /api/v1/auth/login
- Get access tokenPOST /api/v1/auth/register
- Register a new user
Users
GET /api/v1/users/me
- Get current userPUT /api/v1/users/me
- Update current userGET /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 tasksPOST /api/v1/tasks/
- Create a new taskGET /api/v1/tasks/{task_id}
- Get task by IDPUT /api/v1/tasks/{task_id}
- Update a taskDELETE /api/v1/tasks/{task_id}
- Delete a task
Health Check
GET /health
- Check API health status
Description
Languages
Python
98.3%
Mako
1.7%