Skip to content

avantifellows/reporting

Repository files navigation

Reporting Engine

Welcome to the Avanti Fellows Reporting Engine!

Setting up the Reporting Engine locally

  1. Install pre-commit hooks in the repo
pip install pre-commit
pre-commit install
  1. Get everything running with:
docker-compose up --build
  1. [ONLY FIRST TIME] Create an external docker volume to enable DynamoDB data to persist between sessions
docker volume create --name=dynamodb_data
  1. [ONLY FIRST TIME] Go into the shell of the app container and run:
python generate_table

This will create the the student_quiz_reports table.

Accessing things

DynamoDB Admin: localhost:8001

Reporting FastAPI Server: localhost:5050 (docs and API tryout at localhost:5050/docs)

DynamoDB server: localhost:8000 (we won't access this directly)

Connect with DynamoDB Server

  1. Install pre-commit hooks in the repo
pip install pre-commit
pre-commit install
  1. Create a .env.local file using .env.example.
cp .env.example .env.local
  1. Obtain credentials to replace local keys in the newly created .env.local file from repository owners.

  2. Run the following to get app at localhost:5050/docs

cd app; uvicorn main:app --port 5050 --reload

Deployment

We deploy our FastAPI instance on AWS Lambda which is triggered via an API Gateway. In order to automate the process, we use AWS SAM, which creates the stack required for deployment and updates it as needed with just a couple of commands and without having to do anything manually on the AWS GUI. Refer to this blog post for more details.

The actual deployment happens through Github Actions. Look at .github/workflows/deploy_to_staging.yml to understand the deployment to Staging and .github/workflows/deploy_to_prod.yml for Production.

The details of the AWS Lambda instances are described in templates/prod.yaml and templates/staging.yaml.