/store-backend-fastapi

Backend for an online store using FastAPI, PostgreSQL, Docker, and Mailpit for managing products, orders, users, and sending emails

Primary LanguagePython

Evoltronic Store

A project focused on an online shop for selling electronic products. You'll find management of products, orders, user authentication, and user registration.

Index

  1. Features
  2. Technologies
  3. Project Structure
  4. Installation
  5. Usage
  6. Tests
  7. License
  8. Contact
  9. Summary

Features

  • User Authentication: Users can register, log in, email verification, and recover passwords.
  • Product Management: Administrators can add, edit, and delete products.
  • Order Management: Customers can place orders and view their order details.
  • Product Categories: Organizes products into categories for easy navigation.
  • Email Sending with Mailpit: Registration, confirmation via emails.

Technologies

This project was developed using the following technologies:

  • Python: version 3.13.0.
  • FastAPI: version 0.115.8
  • PostgreSQL:version 16.8
  • Docker: version 27.3.1
  • SQLAlchemy: version 2.0.38
  • Pydantic: version 2.10.6

Project Structure

The project follows a modular to ensure future scalability. Below is the main directory structure:

โ”ฃ ๐Ÿ“‚api
โ”ƒ โ”ฃ ๐Ÿ“‚routes
โ”ƒ โ”ƒ โ”ฃ ๐Ÿ“‚admin
โ”ƒ โ”ƒ โ”ฃ ๐Ÿ“‚auth
โ”ƒ โ”ƒ โ”ฃ ๐Ÿ“‚client
โ”ƒ โ”ƒ โ”— ๐Ÿ“‚public
โ”ƒ โ”— ๐Ÿ“œapi.py
โ”ฃ ๐Ÿ“‚core
โ”ฃ ๐Ÿ“‚dependencies
โ”ฃ ๐Ÿ“‚middlewares
โ”ฃ ๐Ÿ“‚models
โ”ƒ โ”ฃ ๐Ÿ“‚category
โ”ƒ โ”ฃ ๐Ÿ“‚order
โ”ƒ โ”ฃ ๐Ÿ“‚product
โ”ƒ โ”ฃ ๐Ÿ“‚user
โ”ƒ โ”— ๐Ÿ“œ__init__.py
โ”ฃ ๐Ÿ“‚responses
โ”ฃ ๐Ÿ“‚schemas
โ”ฃ ๐Ÿ“‚services
โ”ƒ โ”ฃ ๐Ÿ“‚category
โ”ƒ โ”ฃ ๐Ÿ“‚order
โ”ƒ โ”ฃ ๐Ÿ“‚product
โ”ƒ โ”ฃ ๐Ÿ“œemail.py
โ”ƒ โ”ฃ ๐Ÿ“œuser_profile.py
โ”ƒ โ”— ๐Ÿ“œuser.py
โ”ฃ ๐Ÿ“‚templates
โ”ƒ โ”— ๐Ÿ“‚user
โ”ฃ ๐Ÿ“‚utils
โ”— ๐Ÿ“œmain.py

Installation

Prerequisites

Before getting started, make sure you have the following installed:

  • Docker
  • Python >= 3.8
  • PostgreSQL

Installation Instructions

  1. Clone this repository:

    git clone https://github.com/nuriadevs/store-backend-fastapi.git
    cd evoltronic_store
  2. Build and start the Docker containers:

    docker-compose up --build
  3. Run the migrations:

    docker exec -it fastapi_app alembic upgrade head
  4. Open the browser to view the routes:

    http://localhost:8000/docs
  5. Open the browser to receive the emails:

    http://localhost:8025/

Usage

Postman

If you want to explore and test the API, you can use the Postman collection weโ€™ve prepared. You can find it in the api_docs/evoltronic.json file. Enjoy it! Login using the admin user provided in the migration

Register a new user (client)

POST/users
 {
  "username": "Lolo",
  "email": "lolo@example.com",
  "password": "PassHashed_123!"
}

Create a new product

POST/products/create
{
  "name": "Laptop",
  "description": "Laptop Samsung ultra.",
  "price": 800.50,
  "stock": 10,
  "category_id": 1
}

Tests

docker-compose exec app pytest

Contact

If you have any questions send me an email.

โœ‰๏ธ Email

Summary

  • Run the migration to test the application with an admin user.
  • Don't forget to create your own .env file for the variables.
  • This project is under construction...can be improved.