CoolFace
Apppublic

DevMuhammadFasih/aidd-todo-api

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
App README

AIDD Todo API

Python backend with dual interfaces:

  • Phase 1: Console application with Rich UI
  • Phase 2: FastAPI RESTful API with Swagger documentation

Prerequisites

  • Python 3.13+
  • UV package manager

Installation

  1. 1.Navigate to the backend directory:
bash
cd backend
  1. 1.Install dependencies:
bash
uv sync

Running the Application

Phase 1: Console Application

bash
uv run python -m backend.main

Phase 2: API Server

bash
uv run uvicorn backend.api.main:app --reload --host 0.0.0.0 --port 8000

API Documentation: http://localhost:8000/docs (Swagger UI)

API Endpoints (Phase 2)

MethodEndpointDescription
GET/tasksList all tasks
POST/tasksCreate a new task
GET/tasks/{id}Get task by ID
PUT/tasks/{id}Update task
DELETE/tasks/{id}Delete task

Example: Create a Task (cURL)

bash
curl -X POST http://localhost:8000/tasks \
  -H "Content-Type: application/json" \
  -d '{"title": "Buy groceries", "description": "Milk, eggs, bread"}'

Response:

json
{
  "id": 1,
  "title": "Buy groceries",
  "description": "Milk, eggs, bread",
  "status": "Pending"
}

Console Usage Examples (Phase 1)

See the console application menu for interactive task management with Rich UI.

Development

Running Tests (Optional)

bash
uv run pytest

Type Checking

bash
uv run mypy src

Keyboard Shortcuts

  • Ctrl+C: Exit application immediately

Architecture

Domain Layer (Phase 1)

  • models.py: Task dataclass and TaskStatus enum
  • services.py: TaskService (business logic)
  • ui.py: ConsoleUI (Rich-based interface)
  • main.py: Console application entry point

API Layer (Phase 2)

  • api/main.py: FastAPI app initialization with CORS
  • api/routes.py: RESTful endpoints (GET, POST, PUT, DELETE)
  • api/schemas.py: Pydantic v2 request/response models

Storage: In-memory (shared between console and API interfaces)