A full-stack Todo app with user authentication, todos CRUD, and follow/followers. Backend is FastAPI + PostgreSQL; frontend is React (Vite) with Tailwind and DaisyUI.
- Authentication — Register users, login (JWT), protected routes
- Todos — Create, read, update, delete todos (requires login)
- Follow / Followers — Follow users and list who you follow / who follows you
- API docs — Interactive Swagger UI at
/docs
| Layer | Stack |
|---|---|
| Backend | Python 3, FastAPI, SQLAlchemy, PostgreSQL, JWT (python-jose), bcrypt |
| Frontend | React 19, Vite 6, Tailwind CSS 4, DaisyUI, React Hook Form |
- Python 3.10+
- Node.js 18+ and npm
- Docker (for local PostgreSQL; or use your own Postgres)
Your .env is already set to use the Docker database. To run everything:
- Start Docker Desktop (or the Docker daemon).
- Start PostgreSQL:
docker compose up -d
- Run backend + frontend — either use the one-command script below or run two terminals manually.
If .env is ready and Docker Postgres is up, you can start both backend and frontend with a single script (no need to open two terminals):
# First time only: install dependencies
pip install -r requirements.txt
cd frontend/todo_app && npm install && cd ../..
# From project root: start both servers
./start.sh- Backend runs at http://localhost:8000 (docs: http://localhost:8000/docs).
- Frontend runs at http://localhost:5173.
- Press Ctrl+C once to stop both.
Prerequisites: .env file with SECRET_KEY and DATABASE_URL; Docker Postgres running (docker compose up -d). The script checks for .env and exits with a message if it’s missing.
If you prefer to run backend and frontend separately:
- Terminal 1 — Backend (from project root):
pip install -r requirements.txt # once uvicorn main:app --reload - Terminal 2 — Frontend:
cd frontend/todo_app && npm install && npm run dev
- Open in browser: App http://localhost:5173 · API docs http://localhost:8000/docs
If you don’t have PostgreSQL installed or your cloud DB (e.g. AWS RDS) is unavailable:
-
Start Docker — Make sure Docker Desktop (or the Docker daemon) is running on your machine.
-
Start PostgreSQL in Docker (from project root):
docker compose up -d
This creates a database
todoappwith userpostgres/ passwordpostgreson port 5432. -
Use the Docker database in
.env— set:DATABASE_URL=postgresql+psycopg2://postgres:postgres@localhost:5432/todoapp
-
Then follow Running Locally below (backend + frontend). Tables are created on first backend run.
To stop: docker compose down.
From the project root (where main.py and requirements.txt are):
# Create and use a virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtBackend needs SECRET_KEY and DATABASE_URL. Use the example file:
cp example.env .envEdit .env and set:
- SECRET_KEY — A long random string (e.g. for JWT signing). Example:
SECRET_KEY=your-super-secret-key-at-least-32-chars-long
- DATABASE_URL — Your PostgreSQL connection string.
Local PostgreSQL example:
DATABASE_URL=postgresql+psycopg2://postgres:yourpassword@localhost:5432/your_database_nameCreate the database first (e.g. createdb your_database_name). Tables (users, todos, followers) are created automatically on first run.
Using the existing AWS RDS URL:
If you use the URL from example.env, keep the same format and only replace the placeholder values with your real secret and credentials.
From the project root:
uvicorn main:app --reload- API: http://localhost:8000
- Swagger docs: http://localhost:8000/docs
Admin user for Swagger: To log in from the docs (Authorize button), create an admin user once (with venv activated):
python scripts/create_admin_user.pyThen in Swagger UI click Authorize, and use username admin and password admin123.
In a second terminal:
cd frontend/todo_app
npm install
npm run dev- App: http://localhost:5173 (or the port Vite prints)
To call the backend from the frontend, use http://localhost:8000 as the API base (e.g. in fetch or axios). CORS is allowed for all origins in development.
# .env and Docker Postgres must be ready
./start.shpip install -r requirements.txt
# Set .env (SECRET_KEY, DATABASE_URL) then:
uvicorn main:app --reloadcd frontend/todo_app
npm install
npm run dev| Area | Prefix / Path | Notes |
|---|---|---|
| Auth | /auth |
POST /auth/create_user, POST /auth/token, GET /auth/get_users |
| Todos | (no prefix) | GET /todos (latest 20, newest first), GET /todo/{id}, POST /todo/create, PUT /todo/{id}, DELETE /todo/{id} (auth required for write) |
| Follow | (see router) | Follow user, list followed, list followers (auth required) |
OpenAPI JSON: http://localhost:8000/api/openapi.json
backenddevelopment/
├── main.py # FastAPI app, CORS, routers
├── database.py # SQLAlchemy engine, session, auth dependency
├── requirements.txt
├── example.env # Copy to .env and fill SECRET_KEY, DATABASE_URL
├── auths/ # User model, auth routes, JWT helper
├── todos/ # Todo model and CRUD routes
├── fan_followers/ # Follow/followers model and routes
└── frontend/
└── todo_app/ # React + Vite app
├── src/
│ ├── App.jsx
│ ├── api.js, context/
│ └── componants/ # Login, CreateTodo, TodoList, Navbar, etc.
├── package.json
└── vite.config.js
SECRET_KEY environment variable not set— Create.envfromexample.envand setSECRET_KEY.- Database connection errors — Check
DATABASE_URLin.env, that PostgreSQL is running, and the database exists. - CORS errors in browser — Backend allows all origins in dev; ensure you’re calling
http://localhost:8000from the frontend. - 401 on todo/follow endpoints — Use
POST /auth/tokenwith username/password to get an access token and send it in theAuthorization: Bearer <token>header.