Skip to content

Latest commit

 

History

History
48 lines (28 loc) · 2.1 KB

File metadata and controls

48 lines (28 loc) · 2.1 KB

FARM-docker backend API

This directory contains the backend API app. It is built with FastAPI.

Requirements

  • Poetry for Python package and environment management.
  • A MongoDB database for persistence.

Install

The project uses poetry to manage dependencies and run the backend application. You can use an other tool to manage your virtual environment, such as pip or uv, but you'll need to extract the dependencies from the pyproject.toml file.

If using poetry, for convenience, run poetry config virtualenvs.in-project true before installing depencies. This will install the dependencies in the project directory and make it easier to manage in vscode.

You can then install the dependencies with poetry install --with dev.

Running the server

To start a development server, run

poetry run fastapi dev app/main.py

from the backend directory (remove the poetry run prefix if using another dependency management tool).

This will start a server running on http://127.0.0.1:8000. The API will be available on the API's base prefix, which by default is /api/v1.

Navigate to http://localhost:8000/api/v1/ to access the root API path. Navigate to http://localhost:8000/docs to access the API's documentation. Navigate to http://localhost:8000/redoc to access the API's alternative doc built with ReDoc.

Running the tests

Run

poetry run pytest

to run the unit tests for the backend app.

Configuration

The project uses Pydantic's settings management through FastAPI. Documentation on how the settings work is availabe here.

The configuration file is located in config/config.py. This file defines the setting properties, their types, and default values. The model_config attribute specifies where these properties are from, i.e. the .env file at the root of the project. Modify the values in the .env file to change the configuration.