A fast, documented, and tested python3 API boilerplate application
Tired of reinventing the wheel every time you need user authentication in a project?
Fill out a simple config file and have RESTful API endpoints for everything needed for account management.

Features:
- Full API documentation via Swagger at /docs
- Account confirmation and password resets via email, powered by Sendgrid
- Production Docker setup
- Thorough unit test coverage
- json logging
Running locally (first time)
uses Python3.6+, Docker, and Docker-compose
- Create a virtual environment for dependencies with python3 -m venv .venv/. Activate it with source .venv/bin/activate.
- Dependencies are managed with Poetry. Install dependencies with poetry install.
- Run pre-commit install to configure git commit hooks (for flake8 checking and black formatting).
- Copy default.env to a new file .env.
- Run docker-compose up -d database to run a local PostgreSQL instance for testing and development.
- Initialize the database with python3 app/utils/init_db.py.
- Run the application with python3 app/main.py.
View documentation at http://localhost:8000/docs
- Create a PostgreSQL instance on the cloud provider of your choice (AWS, Digital Ocean, etc).
- Fill out .env with your credentials, and change API_ENV to PRODUCTION.
- Initialize the database with python3 app/utils/init_db.py
- Build the project with docker build -t microauth .
- Run with docker run -p 8000:8000 -d microauth
Run test suite with pytest --cov=app tests/.
If you would like users to be able to verify their email address and reset their passwords, sign up for a Sendgrid Account and add your API Key to .env.
Credit for the email HTML templates
- Create sqlalchemy model in app/models/.
- Create database queries for the model in app/db/
- Create Pydantic "Schema" in app/schemas/ for API validation and documentation
- Import model in alembic/env.py and utils/init_db.py
Now you should be ready to apply a change to your existing database with alembic.
alembic revision -m "made some change" --autogenerate (generates migration plan in alembic/versions/)
alembic upgrade head (applies database changes)
Tests are always run against the local docker PostgreSQL instance. The database is re-initialized before each test, and after the last test is run.