Skip to content

mike-engineering/atlas-python

Repository files navigation

Atlas Beacon App

Features

  • FastAPI with Python 3.8
  • Postgres
  • SqlAlchemy with Alembic for migrations
  • Pytest for backend tests
  • Docker compose for easier development

Development

The only dependencies for this project should be docker and docker-compose.

Quick Start

Starting the project with hot-reloading enabled (the first time it will take a while):

Copy .env.sample and paste it as .env in the root directory of the project.

docker-compose up -d

To run the alembic migrations (for the users table):

docker-compose run --rm backend alembic upgrade head

Auto-generated docs will be at http://localhost:8000/api/docs

Rebuilding containers:

docker-compose build

Restarting containers:

docker-compose restart

Bringing containers down:

docker-compose down

Delete every stopped containers, every network not used, every dangling images and every build cache:

docker-compose down

docker system prune -a --volumes

Migrations

Migrations are run using alembic. To run all migrations:

docker-compose run --rm backend alembic upgrade head

To create a new migration:

docker-compose exec backend bash

alembic upgrade head

alembic revision -m "create users table"

alembic upgrade head

And fill in upgrade and downgrade methods. For more information see Alembic's official documentation.

Testing

There is a helper script for backend tests:

./scripts/test.sh

Backend Tests

docker-compose run backend pytest

any arguments to pytest can also be passed after this command

Logging

docker-compose logs

Or for a specific service:

docker-compose logs -f name_of_service # frontend|backend|db

Project Layout

backend
└── app
    ├── alembic
    │   └── versions # where migrations are located
    ├── api
    │   └── api_v1
    │       └── endpoints
    ├── core    # config
    ├── db      # db models
    ├── tests   # pytest
    └── main.py # entrypoint to backend

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages