kieled / ecommerce-backend

Ecommerce graphql FastAPI application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ecommerce graphql application

This repository contains code for a FastAPI application with various routers and queries implemented using the Strawberry library. The code provides an API for managing products, orders, users, addresses, and other related functionalities. It also includes middleware for handling CORS (Cross-Origin Resource Sharing) and an asynchronous context manager for managing the lifespan of the application.

🌟 Features

Blank for now...

❗ Requirements

  1. Docker ( >=23.0.4 ) and docker compose plugin ( >=2.18.1 )
  2. 2GB RAM
  3. 5GB+ ROM

➕ Installation

  1. Clone the repository:
git clone https://github.com/kieled/ecommerce-backend.git
  1. Rename .env.example to .env and change variables like you want
  2. Run command to start project
docker compose up -d --build
  1. To check logs use this command [ Optional ]:
docker compose logs -f api consumer inst payment

This will start the server on: http://localhost:8000

🔴 Usage

  1. FastAPI docs available on: http://localhost:8000/docs
  2. GraphQL User Interface on: http://localhost:8000/graphql

💠 HTTP Endpoints

The following API endpoints are available:

Authentication

  • POST /setup - Endpoint for setting up the application (creates superuser account). Requires the secret_key, username, and password fields as form data. Accessible only with a valid secret_key (from env file).
  • POST /instagram/auth - Endpoint for authenticating with an Instagram account. Requires the username, password, and optional verification_code (If you receive code on the email or 2FA, just resend your request with this code again) and locale fields as form data. [AdminOnly]

Images

  • POST /load-images - Endpoint for loading images. Requires the images field as a form data list of files to be uploaded. [AdminOnly]
  • GET /download/{product_id} - Endpoint for downloading product images as a ZIP file. Requires the product_id path parameter. [AdminOnly]
  • POST /upload-files/ - Endpoint for uploading temporary images. Requires the files field as a form data list of files to be uploaded. [AdminOnly]

🔵 GraphQL Endpoints

GraphQL Queries

The following GraphQL queries are available:

  • requisites - Retrieves a list of requisites based on the type_id parameter. [AdminOnly]
  • active_requisite - Retrieves the active requisite based on the type_id parameter.
  • orders - Retrieves a list of orders with pagination support. [AdminOnly]
  • order_detail - Retrieves detailed information about a specific order. [AdminOnly]
  • users - Retrieves a list of users with pagination support. [AdminOnly]
  • self - Retrieves information about the current authenticated user.
  • hash - Generates a hash for a given password.
  • location_search - Retrieves information about a location based on a query.
  • location_reverse - Retrieves information about a location based on latitude and longitude.
  • order_public_list - Retrieves a list of public orders with pagination support.
  • order_public_detail - Retrieves detailed information about a specific public order.
  • check_promo - Checks the validity of a promo code.
  • requisite_types - Retrieves a list of requisite types.
  • products - Retrieves a list of products with pagination support. [AdminOnly]
  • product_detail - Retrieves detailed information about a specific product. [AdminOnly]
  • fetch_product - Parses product information from an Aliexpress URL. [AdminOnly]
  • products_public - Retrieves a list of public products with pagination support.
  • public_detail - Retrieves detailed information about a specific public product.
  • product_categories - Retrieves a list of product categories.

GraphQL Mutations

The following GraphQL mutations are available:

  • update_requisite - This mutation updates the transactions information based on the provided payload. [AdminOnly]
  • delete_requisite - This mutation deletes a requisite by its ID. [AdminOnly]
  • create_requisite - This mutation creates a new requisite based on the provided payload. [AdminOnly]
  • update_order - This mutation updates the order information based on the provided order input. [AdminOnly]
  • create_order - This mutation creates a new order based on the provided payload, including an address, products, and promo information.
  • login - This mutation performs administrator authorization by taking a username and password as input.
  • logout - This mutation logs out the authenticated user.
  • refresh - This mutation refreshes the JSON Web Token (JWT) token for an authenticated user.
  • telegram_login - This mutation performs authorization for customers through a Telegram widget.
  • confirm_transaction - This mutation confirms a transaction by its associated order ID. [AdminOnly]
  • create_requisite_type - This mutation creates a new requisite type based on the provided payload. [AdminOnly]
  • update_requisite_type - This mutation updates a requisite type based on the provided payload. [AdminOnly]
  • delete_requisite_type - This mutation deletes a requisite type by its ID. [AdminOnly]
  • create_product - This mutation creates a new product based on the provided product input. [AdminOnly]
  • update_product - This mutation updates the product information based on the provided product input. [AdminOnly]
  • delete_product - This mutation deletes a product by its ID. [AdminOnly]
  • update_product_category - This mutation updates a product category based on the provided payload. [AdminOnly]
  • create_product_category - This mutation creates a new product category based on the provided payload. [AdminOnly]
  • delete_product_category - This mutation deletes a product category by its ID. [AdminOnly]

♻️ Dependencies

The main dependencies used in this code are:

  • FastAPI - A modern, fast (high-performance) web framework for building APIs with Python.
  • Strawberry - A GraphQL library for Python that aims to provide a straightforward and type-safe approach to building GraphQL APIs.
  • aio-pika - a wrapper for the aiormq for asyncio and humans.
  • Uvicorn - an ASGI web server implementation for Python.

About

Ecommerce graphql FastAPI application


Languages

Language:Python 99.0%Language:Dockerfile 0.6%Language:Mako 0.4%Language:Shell 0.0%