Monorepo containing all code and documentation for the A3Data Back-end Software Engineer code challenge.
This project is a monorepo actually containing three modular applications.
- Nuvie Backend is the main back-end server, implementing RESTful APIs with FastAPI, letting us login as users or super-users to view, create, update or delete patient data. It has OAuth2 authentication.
- Nuvie Ingestor is a script for importing patient data from external sources. Only synthetic data from the Synthea dataset can be imported, but it is implemented modularly so that other sources can be added later on. By default, it downloads the 1K Sample Synthetic Patient Records, CSV (9 MB). It is implemented with multithreading, so imports should be very quick!
- Nuvie SDK is a python package containing all data models and use cases for interacting with the DB directly. It is used by both Nuvie Backend and Nuvie Ingestor. Using this helps keep code repetition to a mininum, and is really useful if extending the ecosystem with other applications and microsservices.
Auto-generated by Swagger. Can be accessed at localhost:8000/docs by default when running the project locally.
Credentials for the first superuser that is auto-created are defined by environment variables. Refer to the .env-sample for more information.
The project can be ran locally very easily, as it's entirely containerized with Docker.
- Docker;
- Python 3.12.x — uv recommended for managing multiple versions and dependencies;
- A valid
.envfile at the root of the repository folder, with all required variables defined. Refer to the.env-samplefile for more information.- The same must be done for each one of the projects in this repo (nuvie-backend, nuvie-ingestor and nuvie-sdk).
After installing all the requirements and setting up the .env file, start the back-end server plus the Postgres DB by simply running the command below from the root folder of the repository:
sudo docker compose up --buildOn first start the database will get created with the credentials provided by the environment variables.
After a successful start for both the backend and postgers services, you must apply the Alembic migrations to auto-create all tables and fields in the database, by running the command below from anywhere:
sudo docker exec -it a3data-backend-se-challenge-nuvie-backend-1 bash -c 'cd /nuvie-sdk/nuvie_sdk && POSTGRES_SERVER="postgres" alembic upgrade head'This will run Alembic inside the back-end docker container, auto-creating everything needed in the DB.
Note: the name of the container,
a3data-backend-se-challenge-nuvie-backend-1, might be different in your machine. Check the correct name with the command:sudo docker ps
After this, stop and restart the docker compose by pressing ctrl + c and then running the first command again.
Now a first superuser should be created successfully, according to the the environment variables, and you are ready to authenticate yourself and test all routes by visiting localhost:8000/docs in your machine.
After you get the back-end server + postgres DB running, you can then import patient data from the Synthea Dataset easily with the Nuvie Ingestor script!
Running it is easy when using uv to manage python versions and dependencies.
cd ./nuvie-ingestor
uv python install
uv sync --all-groups
uv run python src/main.py --workers 8Of course, as a standalone script, it can be ran with any other method to manage python versions and dependencies. Using python's built in environments, you can run it with:
cd ./nuvie-ingestor
## After installing Python 3.12...
python -m venv ./.venv
pip install -r requirements.txt
python src/main.py --workers 8