Backend architecture is constructed by microservices written in Django and Ruby on Rails. The entrypoint to each of them is authentication-api which provides authentication and proxy service. The API is wrriten in Open API format and documented using Swagger.
- To access resources, the user (student) has to be authenticated.
- To add resources, the user (teacher) has to have is_teacher flag set to
is_teacher=True
in authentication-api.
- docker
- docker-compose
In the main directory montelearn
run make run
to start docker-compose.
Microservices with API documenentation provided by Swagger can be found on:
- authentication-api:
http://0.0.0.0:8080/swagger/
- lesson-api:
http://0.0.0.0:8000/swagger/
- tests-api:
http://0.0.0.0:3000/swagger/
Register your email address using POST authentication-api endpoint /auth/email/register/
via Swagger.
Copy token and use it to authorize your request, using Bearer <token>
Route each request to microservice through authentication-api
.
- In the main directory
montelearn
runmake lesson_load_data
- In the main directory
montelearn
runmake auth_api_superuser
- Register your email address using POST authentication-api endpoint
/auth/email/register/
via Swagger. Log in (via Swaggerhttp://0.0.0.0:8080/swagger/
) and use obtained credentials to GET lessons and tests.
- Register your email address using POST authentication-api endpoint
/auth/email/register/
via Swagger. Use developer account to login to developer admin pagehttp://0.0.0.0:8080/admin/
. Navigate toUsers
, choose the previously registered account and assign the teacher rights markingis_teacher
as True. Log out and log in using teacher's credentials (via Swaggerhttp://0.0.0.0:8080/swagger
). Right now you are able to add/update lessons and tests.
- In the main directory
montelearn
runmake cleanup
Each BE microservice can be run and tested separately, please refer to README.md in the microservice directory.
Changes to microservices are automatically deployed to Heroku (Github Actions) after a pull request is merged to master
branch. It's worth pointing out that changes not related to particular microservice source code does not trigger a new deployment.
Lesson-api and tests-api have open, public APIs which can be hidden on production using IP whitelisting, which is currently implemented only in lesson-api.
In local environment all of the IPs are being allowed (BASIC_AUTH_WHITELISTED_IP_NETWORKS=0.0.0.0/0
).
To whitelist IP on production set up an environment variable BASIC_AUTH_WHITELISTED_IP_NETWORKS
and assign it range of allowed IP addresses.
To add multiple network ranges separate them by comma ex. ``BASIC_AUTH_WHITELISTED_IP_NETWORKS=127.0.0.0/8,10.0.0.0/8
In local environment all of the IPs are being allowed.
To whitelist IP on production add IP addresses go to /tests-api/config/initializers/whitelist.rb
in WHITELIST = [].freeze,
add IP addresses as a in the middle of [], separated by comma for example: ["1.1.1.1", "0.0.0.0"]