Skip to content

ulugbekbackend/Delivery-project-API

Repository files navigation

🚀 Delivery Project API (FastAPI)

A high-performance Delivery API built with FastAPI. This project provides authentication, product management, and order processing features using JWT-based security.


📌 Features

  • 🔐 JWT Authentication (Access & Refresh tokens)
  • 👤 User registration & login
  • 📦 Product management (Admin only)
  • 🛒 Order creation and management
  • 🔄 Order status updates
  • 🧾 Role-based access control (Admin / User)
  • ⚡ FastAPI automatic documentation

🛠️ Technologies Used

  • FastAPI
  • PostgreSQL
  • SQLAlchemy
  • Pydantic
  • fastapi-jwt-auth
  • Werkzeug (password hashing)

📸 API Preview (Swagger UI)

🔹 Swagger Documentation

Swagger 1

Swagger 2


📁 Project Structure

project/
├── demo_images/
│   ├── swagger1.png
│   ├── swagger2.png
├── main.py
├── auth_routes.py
├── order_routes.py
├── product_routes.py
├── models.py
├── schemas.py
├── database.py
├── init_db.py
├── config.py
├── requirements.txt
├── .env                     
├── .env.example                     
├── .gitignore              
└── README.md

⚙️ Environment Variables

Create a .env file in the root directory:

# Database Configuration
DB_USER=postgres_user
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=delivery_db

# Application Configuration
SECRET_KEY=your_secret_key_here_min_32_characters
SQL_ECHO=False

▶️ Installation & Run

1. Clone repository

git clone https://github.com/ulugbekbackend/Delivery-project-API.git
cd Delivery-project-API

2. Create virtual environment

python -m venv venv
source venv/bin/activate   # Linux / Mac
venv\Scripts\activate      # Windows

3. Install dependencies

pip install -r requirements.txt

4. PostgreSQL Database yaratish

CREATE DATABASE delivery_db;

5. Run server

uvicorn main:app --reload

🌐 API Documentation

After running the server:


🔐 Authentication

Signup

POST /auth/signup

Login

POST /auth/login

Response:

{
  "access": "token",
  "refresh": "token"
}

Refresh Token

GET /auth/login/refresh

📦 Product Endpoints (Admin only)

  • POST /product/create
  • GET /product/list
  • GET /product/{id}
  • PUT /product/{id}/update
  • PATCH /product/{id}/update
  • DELETE /product/{id}/delete

🛒 Order Endpoints

  • POST /order/make
  • GET /order/list (Admin only)
  • GET /order/{id} (Admin only)
  • GET /order/user/orders
  • GET /order/user/order/{id}
  • PUT /order/{id}/update
  • PATCH /order/{id}/update-status
  • DELETE /order/{id}/delete

👥 User Roles

Role Permissions
User Create & manage own orders
Admin Manage products & view all orders

📊 Order Statuses

  • PENDING
  • IN_TRANSIT
  • DELIVERED

🐛 Debugging

SQL Query'larni ko'rish

.env faylida:

SQL_ECHO=True

🔒 Security

  • Passwords are hashed using Werkzeug
  • JWT authentication for all protected routes
  • Role-based authorization

📌 Notes

  • Only admin users (is_staff=True) can manage products
  • Users can only modify their own orders
  • Orders can only be deleted if status is PENDING

👨‍💻 Author

Ulugbek Yuldoshev - Python Backend Engineer | Full Stack Developer


⭐ Contributing

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


📄 License

This project is open-source and available under the MIT License.

About

Delivery API is a backend service designed to manage delivery operations efficiently. It allows creating orders, tracking them, and managing their delivery status. In this project, I built a RESTful API that includes order management (CRUD), status updates (e.g., pending, in progress, delivered), and relationships between users and orders.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages