FastAPI backend with PostgreSQL for the TaskMate task management application.
- ✅ User authentication (JWT)
- ✅ Task CRUD operations
- ✅ PostgreSQL database
- ✅ RESTful API
- ✅ Auto-generated API docs (Swagger)
- ✅ CORS enabled for Flutter app
- Framework: FastAPI
- Database: PostgreSQL
- Authentication: JWT (JSON Web Tokens)
- ORM: SQLAlchemy
- Password Hashing: bcrypt
- Python 3.8+
- PostgreSQL 12+
- Clone the repository:
git clone https://github.com/NoobProgrammer008/taskmate-backend.git
cd taskmate-backend- Create virtual environment:
python -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # Mac/Linux- Install dependencies:
pip install -r requirements.txt- Setup PostgreSQL:
CREATE DATABASE taskmate_db;- Configure environment variables:
Create .env file:
DB_USER=postgres
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=taskmate_db
SECRET_KEY=your-secret-key-here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30- Run the server:
uvicorn app.main:app --reloadServer will run at: http://localhost:8000
Access interactive API docs at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
POST /auth/signup- Register new userPOST /auth/login- Login userGET /auth/me- Get current user
GET /tasks/- Get all tasksPOST /tasks/- Create new taskGET /tasks/{id}- Get task by IDPUT /tasks/{id}- Update taskDELETE /tasks/{id}- Delete taskPATCH /tasks/{id}/toggle- Toggle task completion
GET /users/me- Get current user profilePUT /users/me- Update user profile
- id (Primary Key)
- name
- email (Unique)
- hashed_password
- bio
- created_at
- id (Primary Key)
- title
- description
- date
- time
- is_completed
- created_at
- user_id (Foreign Key)
- User signs up →
/auth/signup - User logs in →
/auth/login→ Receives JWT token - User includes token in header:
Authorization: Bearer <token> - Access protected endpoints
taskmate_backend/
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI app
│ ├── database.py # Database connection
│ ├── models.py # SQLAlchemy models
│ ├── schemas.py # Pydantic schemas
│ ├── auth.py # Authentication logic
│ └── routers/
│ ├── auth.py # Auth endpoints
│ ├── tasks.py # Task endpoints
│ └── users.py # User endpoints
├── .env # Environment variables
├── .gitignore
├── requirements.txt
└── README.md
- Push to GitHub
- Connect Railway to your repo
- Add PostgreSQL service
- Set environment variables
- Deploy!
heroku create taskmate-api
heroku addons:create heroku-postgresql:hobby-dev
git push heroku mainPull requests are welcome! For major changes, please open an issue first.
MIT License
Your Name
- GitHub: @NoobProgrammer008