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
uses Python3.6+, Docker, and Docker-compose
- Create a virtual environment for dependencies with
python3 -m venv .venv/. Activate it withsource .venv/bin/activate. - Dependencies are managed with Poetry. Install dependencies with
poetry install. - Run
pre-commit installto configure git commit hooks (forflake8checking andblackformatting). - Copy
default.envto a new file.env. - Run
docker-compose up -d databaseto 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
.envwith your credentials, and changeAPI_ENVtoPRODUCTION. - 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.pyandutils/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.
