Skip to content

NoobProgrammer008/taskmate-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TaskMate Backend API

FastAPI backend with PostgreSQL for the TaskMate task management application.

🚀 Features

  • ✅ User authentication (JWT)
  • ✅ Task CRUD operations
  • ✅ PostgreSQL database
  • ✅ RESTful API
  • ✅ Auto-generated API docs (Swagger)
  • ✅ CORS enabled for Flutter app

🛠️ Tech Stack

  • Framework: FastAPI
  • Database: PostgreSQL
  • Authentication: JWT (JSON Web Tokens)
  • ORM: SQLAlchemy
  • Password Hashing: bcrypt

📋 Prerequisites

  • Python 3.8+
  • PostgreSQL 12+

⚙️ Installation

  1. Clone the repository:
git clone https://github.com/NoobProgrammer008/taskmate-backend.git
cd taskmate-backend
  1. Create virtual environment:
python -m venv venv
venv\Scripts\activate  # Windows
source venv/bin/activate  # Mac/Linux
  1. Install dependencies:
pip install -r requirements.txt
  1. Setup PostgreSQL:
CREATE DATABASE taskmate_db;
  1. 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
  1. Run the server:
uvicorn app.main:app --reload

Server will run at: http://localhost:8000

📚 API Documentation

Access interactive API docs at:

🔗 API Endpoints

Authentication

  • POST /auth/signup - Register new user
  • POST /auth/login - Login user
  • GET /auth/me - Get current user

Tasks

  • GET /tasks/ - Get all tasks
  • POST /tasks/ - Create new task
  • GET /tasks/{id} - Get task by ID
  • PUT /tasks/{id} - Update task
  • DELETE /tasks/{id} - Delete task
  • PATCH /tasks/{id}/toggle - Toggle task completion

Users

  • GET /users/me - Get current user profile
  • PUT /users/me - Update user profile

🗄️ Database Schema

Users Table

  • id (Primary Key)
  • name
  • email (Unique)
  • hashed_password
  • bio
  • created_at

Tasks Table

  • id (Primary Key)
  • title
  • description
  • date
  • time
  • is_completed
  • created_at
  • user_id (Foreign Key)

🔐 Authentication Flow

  1. User signs up → /auth/signup
  2. User logs in → /auth/login → Receives JWT token
  3. User includes token in header: Authorization: Bearer <token>
  4. Access protected endpoints

📦 Project Structure

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

🚀 Deployment

Railway (Recommended)

  1. Push to GitHub
  2. Connect Railway to your repo
  3. Add PostgreSQL service
  4. Set environment variables
  5. Deploy!

Heroku

heroku create taskmate-api
heroku addons:create heroku-postgresql:hobby-dev
git push heroku main

🤝 Contributing

Pull requests are welcome! For major changes, please open an issue first.

📄 License

MIT License

👤 Author

Your Name

About

TaskMate Backend - FastAPI + PostgreSQL API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages