A full-stack todo application with user authentication and task management built using Next.js 16, FastAPI, and Neon PostgreSQL.
This project implements a comprehensive todo application with user authentication, task management, and real-time updates. It follows a monorepo structure with clear separation of concerns between frontend and backend services.
- User Authentication: JWT-based authentication with registration and login
- Task Management: Create, read, update, delete, and mark tasks as complete/incomplete
- Secure API: Protected endpoints with proper authentication
- Responsive UI: Mobile-first design with responsive components
- Data Isolation: Users can only access their own tasks
- Next.js 16 (App Router)
- React 19+
- TypeScript
- Tailwind CSS
- Better Auth
- SWR for data fetching
- Python 3.13+
- FastAPI
- SQLModel
- Pydantic
- PostgreSQL (Neon)
- Docker & Docker Compose
- Environment-based configurations
- Node.js 18+
- Python 3.13+
- Docker and Docker Compose
- Git
- Clone the repository:
git clone <repository-url>
cd hackathon-todo-phase2- Set up backend:
cd backend
pip install -e .
# or if using uv:
uv pip install -e .- Set up frontend:
cd frontend
npm install
# or
pnpm install- Create a
.envfile in the backend directory:
DATABASE_URL=postgresql://username:password@localhost:5432/todo_app
BETTER_AUTH_SECRET=your_super_secret_jwt_key_here
FRONTEND_URL=http://localhost:3000
LOG_LEVEL=INFO- Set up Neon PostgreSQL database (or use local PostgreSQL for development)
- Create a
.env.localfile in the frontend directory:
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_BETTER_AUTH_SECRET=your_super_secret_jwt_key_here
NEXT_PUBLIC_OPENAI_DOMAIN_KEY=your_openai_domain_key_for_phase_iii- Start the backend:
cd backend
uvicorn main:app --reload- In a new terminal, start the frontend:
cd frontend
npm run dev
# or
pnpm devThe application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- Backend Documentation: http://localhost:8000/docs
Alternatively, you can run the entire application using Docker Compose:
docker-compose up --buildhackathon-todo-phase2/
├── backend/ # FastAPI backend application
│ ├── models.py # SQLModel database models
│ ├── db.py # Database connection layer
│ ├── auth.py # JWT authentication logic
│ ├── schemas.py # Pydantic schemas
│ ├── routes/
│ │ └── tasks.py # Task-related API endpoints
│ ├── main.py # FastAPI application entry point
│ ├── init_db.py # Database initialization script
│ └── pyproject.toml # Python dependencies
├── frontend/ # Next.js frontend application
│ ├── app/ # App Router pages
│ │ ├── auth/ # Authentication pages
│ │ │ ├── signin/
│ │ │ └── signup/
│ │ └── tasks/ # Tasks page
│ ├── components/ # Reusable UI components
│ │ └── tasks/ # Task-specific components
│ ├── lib/ # Utility functions
│ │ ├── auth.ts # Authentication helpers
│ │ ├── api.ts # API client wrapper
│ │ └── types.ts # TypeScript type definitions
│ ├── package.json # Frontend dependencies
│ └── .env.local # Frontend environment variables
├── docker-compose.yml # Docker configuration
├── .env # Environment variables template
└── README.md # This file
POST /api/auth/signup- Register a new userPOST /api/auth/signin- Authenticate a user
GET /api/{user_id}/tasks- Get all tasks for a userPOST /api/{user_id}/tasks- Create a new taskGET /api/{user_id}/tasks/{task_id}- Get a specific taskPUT /api/{user_id}/tasks/{task_id}- Update a taskDELETE /api/{user_id}/tasks/{task_id}- Delete a taskPATCH /api/{user_id}/tasks/{task_id}/complete- Toggle task completion
- Create feature specifications in the
specs/directory - Generate implementation plan:
sp.plan - Generate tasks:
sp.tasks - Implement features:
sp.implement
cd backend
pytestcd frontend
npm testRun the end-to-end test script:
python test_e2e.py- Set up environment variables for production
- Deploy using your preferred platform (Railway, Vercel, Render, etc.)
- Ensure the database connection is configured properly
- Build the application:
npm run build - Deploy to Vercel, Netlify, or your preferred hosting platform
- Configure environment variables
DATABASE_URL- PostgreSQL database connection stringBETTER_AUTH_SECRET- Secret key for JWT signingFRONTEND_URL- URL of the frontend application for CORS
NEXT_PUBLIC_API_URL- URL of the backend APINEXT_PUBLIC_BETTER_AUTH_SECRET- Secret key for authentication (if needed)
- JWT tokens for authentication
- User data isolation (users can only access their own tasks)
- Input validation on all endpoints
- Parameterized queries to prevent SQL injection
- CORS configured to only allow trusted origins
- Database Connection: Ensure your
DATABASE_URLis correctly configured - Authentication: Verify that
BETTER_AUTH_SECRETis the same in both frontend and backend - API Calls: Check that
NEXT_PUBLIC_API_URLpoints to the correct backend URL - CORS Errors: Ensure
FRONTEND_URLin backend.envmatches your frontend URL
- Enable DEBUG logging in the backend for detailed request/response logs
- Check browser developer tools for frontend errors
- Verify that both frontend and backend are running simultaneously during development
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for your changes
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.