Skip to content

mbrav/signup_api

Repository files navigation

FastAPI and Pytest CI License wakatime

FastAPI signup_api

An 100% asynchronous Fast API service for signups and Telegram integration.

Intent

As of now, this project is mainly an architecture design experimental ground with an abstract end goal in mind, rather than an actual functioning app and therefore would be most useful if used as a starting template example. The project uses FastAPI as a base framework with the following stack:

  • Integration with SQLAlchemy's new ORM statement paradigm to be implemented in v2.0;
  • Asynchronous PostgreSQL databse via asyncpg, one of the fastest and high performant Database Client Libraries for python/asyncio;
  • Integration with Telegram library aiogram using its upcoming v3.0 version with webhooks as an integration method with FastAPI;
  • A token authorization system using the argon2 password hashing algorithm, the password-hashing function that won the Password Hashing Competition (PHC);
  • Asynchronous task scheduling using apscheduler;
  • Designed to run efficently as possbile on a device such as the Raspberry Pi;
  • Asynchronous pytests using pytest-asyncio and httpx libraries instead of the synchronous requests library;
  • Vue.js 3.2 basic frontend with potential future experimentation with vite and vuetify framework.

Backend

With docker-compose installed, do:

docker-compose up

Go to 0.0.0.0:8000/docs for SwaggerUI

Run FastAPI Backend locally

$ git clone https://github.com/mbrav/signup_api.git
$ cd signup_api

Setup a local python environment:

$ python3 -m venv venv
$ source venv/bin/activate

Install dependencies with poetry:

$ cd app
$ poetry install

Copy .env file:

$ cp .env.example .env

Run server:

$ python main.py

Run server with uvicorn:

$ python -m uvicorn main:app --host 0.0.0.0 --port 8000 --workers 1 --reload

Advanced config:

$ python -m uvicorn main:app --host 0.0.0.0 --port 8000 --workers 2 --ssl-keyfile ~/ssl/keys/server.key --ssl-certfile ~/ssl/certs/server.crt

Go to 0.0.0.0:8000/docs for SwaggerUI

Run pytest

$ python -m pytest