Technical assignment to build the REST API (see requirements)
For development purpose, please follow the local setup guide.
- This project uses
docker
anddocker-compose
- Thus Installation of Docker Engine is required
This project depends on few runtime variables.
- Create
.env
file in the project root folder - Refer to
.env_example
for required values & expected format
- Simply run
docker-compose build
from the root folder
POSTGRES_USER
,POSTGRES_PASSWORD
env var are required at container runtime- Run the following command:
# username and password in the command should match the ones in `.env` file
POSTGRES_USER=your_pg_usr POSTGRES_PASSWORD=your_pg_pwd docker-compose up
- Check the Swagger doc at
http://127.0.0.1:8000/docs
- Call the API from your browser or via the Postman
This project loosely follows the Clean Architecture.
-
Important classes of the project are
Interactor
andEpisodeRepo
:Interactor
:- Provide CRUD logic to the framework layer, which is currently FAST API
- If additional interface needs to be added (e.g. CLI), it can just call the instance of Interactor
EpisodeRepo
:- Database access layer, hide the DB-access related details and provide abstractions
- Depends on SQLAlchemy, also injected at runtime (No ORM, using SqlAlchemy core)
-
Core data structures (Pydantic models) are defined at
/src/domain/episode.py
- Classes in the module are sporadically used for typing & parse the data to object
-
Dependencies are injected at
/src/dependency.py
test_interactor.py
: Unit tests for the interactor. DB-access layer is mocked.test_storage.py
: Integration tests, it actually callsPostgres
to test all DB-access methods.
- Add CI via Github Action
- Add test suits for the REST endpoints
- Introduce logging
- Polish up the generated SwaggerDocs
- Add database init script (currently database init is implemented in the codebase -
/src/infra/db.py
) - Add
alembic
to the project