- FastAPI
- PostgreSQL
- Elasticsearch
- Redis
- Pytest & aiohttp
The project follows a microservice architecture. This particular service (Movies Service) is responsible for implementing API endpoints to access data from the data warehouse. It utilizes Elasticsearch as the data source and Redis as a caching.
The ETL data warehouse service is a separate service. It is responsible for continuously extracting, transforming and loading data from PostgreSQL
into the Elasticsearch
DB.
Auth Service is an implicit dependency for this service, as some API endpoints may require authentication. The authentication is based on JWT
tokens. Instead of constantly querying the authentication service for each user access attempt, the service validates the provided JWT
token using a shared secret with the authentication service. This approach allows the service to authenticate users without needing to interact with the authentication service every time.
Services interaction scheme:
-
Before running this service, start the dependent services specified in the requirements.
-
Configure & activate virtual environment using provided
requirements.txt
orPipfile
. -
Configure environment in
./fastapi-solutions/.env
- Use
.env.sample
to set expected environment in.env
- Use
-
Use
docker-compose
to launch project:docker-compose up
-
The service is available on
localhost: 80
.
Tests are written using pytest
and aiohttp
libraries.
-
Configure & activate virtual environment using provided
requirements.txt
.pip install -r ./fastapi-solution/tests/functional/requirements.txt
-
Setup environment in the file
fastapi-solution/tests/.env
- Use
fastapi-solution/tests/.env.sample
to set expected environment in.env
- Use
-
Build & Run Test docker-compose
docker-compose.test.yaml
docker-compose -f docker-compose.test.yaml up --build
-
Run tests:
pytest fastapi-solution/tests --docker-compose=docker-compose.test.yaml --docker-compose-no-build --use-running-containers -v
-
Configure launcher
.vscode\launch.json
{ "version": "0.2.0", "configurations": [ { "name": "Python: Remote Attach", "type": "python", "request": "attach", "port": 5678, "host": "localhost", "pathMappings": [ { "localRoot": "${workspaceFolder}/fastapi-solution", "remoteRoot": "/opt/app" } ] } ] }
-
Launch debugging docker-compose
docker-compose.debug.yaml
docker-compose -f docker-compose.debug.yaml up --build
-
Launch the before configured launcher (remote attach)
-
The service is available on
localhost:8000
-
Setup configuration in VsCode Settings:
{ "python.testing.pytestArgs": [ "--rootdir", "fastapi-solution/tests", "--docker-compose=docker-compose.test.yaml", "--docker-compose-no-build", "--use-running-containers", "-v" ], "python.analysis.extraPaths": ["fastapi-solution/src/"], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, }