Automated Action d1c05cbd6e Implement Task Manager API with FastAPI and SQLite
- Set up project structure and dependencies
- Create database models for tasks and users with SQLAlchemy
- Configure Alembic for database migrations
- Implement authentication system with JWT tokens
- Create CRUD API endpoints for tasks and users
- Add health check endpoint
- Update README with documentation
2025-06-12 18:14:56 +00:00

132 lines
3.4 KiB
Markdown

# 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:
```bash
git clone <repository-url>
cd taskmanagerapi
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Run database migrations:
```bash
alembic upgrade head
```
### Running the Application
Run the application with Uvicorn:
```bash
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 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