Skip to content

Latest commit

 

History

History
49 lines (33 loc) · 1.51 KB

File metadata and controls

49 lines (33 loc) · 1.51 KB

Todo demo (FastAPI + Next.js + PostgreSQL)

Layout

  • backend/ — FastAPI API: app/routes/ (HTTP), app/services/ (rules), app/dao/ (Postgres via SQLAlchemy, in-memory fallback, DB session). Settings live in app/config.py; API body/response models in app/routes/schemas.py.
  • frontend/ — Next.js App Router, Tailwind CSS, TanStack Query.

With PostgreSQL configured, tables are created on API startup (create_all). No migration tool.

Prerequisites

  • Python 3.11+
  • Node 20+
  • PostgreSQL only if you set DATABASE_URL (otherwise in-memory mode)

Backend

cd backend
python3 -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -e .
cp .env.example .env
# Optional: set DATABASE_URL for Postgres; omit it to use in-memory storage.
uvicorn app.main:app --reload

API: http://localhost:8000 — docs at /docs, health at /health.

Frontend

cd frontend
cp .env.local.example .env.local   # optional; defaults to http://localhost:8000
npm install
npm run dev

App: http://localhost:3000

If you see a broken Turbopack or .next error, run npm run clean in frontend/, then npm run dev again.

Environment

Copy backend/.env.example to backend/.env. To use Postgres, set DATABASE_URL, for example:

postgresql+psycopg://namanrusia:YOUR_PASSWORD@localhost:5432/todo_app

GET /health includes "storage": "memory" or "storage": "postgres".