CoolFace
Apppublic

Zaraa7/phase3-todo-api

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

Backend Core & Data Layer

RESTful API for managing user-owned tasks with JWT authentication.

Tech Stack

  • Framework: FastAPI
  • ORM: SQLModel
  • Database: Neon PostgreSQL (serverless)
  • Authentication: JWT (Better Auth compatible)

Quick Start

bash
# Create virtual environment
python -m venv venv
venv\Scripts\activate  # Windows
source venv/bin/activate  # macOS/Linux

# Install dependencies
pip install -r requirements.txt

# Configure environment
cp .env.example .env
# Edit .env with your DATABASE_URL and JWT_SECRET

# Run server
uvicorn app.main:app --reload --port 8000

Environment Variables

VariableDescriptionExample
DATABASE_URLNeon PostgreSQL connection stringpostgresql://user:pass@host.neon.tech/db?sslmode=require
JWT_SECRETShared secret with Better Authyour-secret-key
JWT_ALGORITHMJWT signing algorithmHS256
CORS_ORIGINSAllowed frontend originshttp://localhost:3000
DEBUGEnable SQL loggingfalse

API Endpoints

MethodEndpointDescription
GET/healthHealth check (no auth)
POST/api/tasksCreate task
GET/api/tasksList user's tasks
GET/api/tasks/{id}Get task by ID
PUT/api/tasks/{id}Update task
DELETE/api/tasks/{id}Delete task

API Documentation

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

Project Structure

backend/
├── app/
│   ├── main.py          # FastAPI application
│   ├── config.py        # Environment configuration
│   ├── database.py      # Database connection
│   ├── auth/jwt.py      # JWT verification
│   ├── models/task.py   # SQLModel Task
│   ├── schemas/task.py  # Pydantic schemas
│   └── routers/tasks.py # CRUD endpoints
├── requirements.txt
├── .env.example
└── README.md

For detailed setup instructions, see quickstart.md.