These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. The architecture of the project is microservices monorepo. Each service is in its own directory with its own dependencies.
- Clone the repo
- Start SurrealDB using the command:
surreal start --log debug --user <username> --pass <password> file://./services/<service_directory>/db-file
in the root directory of the project.
e.g.surreal start --log debug --user root --pass root123 file://./services/acl-service/db-file
will start the ACL service database. - Ask the Lead Engineer for the
.env
file and place it in the root directory of the project. N/B: The.env
file is not committed to the repository for security reasons. It has the database credentials and other sensitive information. - Run any service using the command:
cargo watch -x run --workdir services/<directory_of_the_service>
in the root directory. This will start the server and restart it whenever you make changes to the code.
e.g.cargo watch -x run --workdir services/acl-service
will start the ACL service.
Cargo will automatically install any dependencies that are missing.
We are using GraphQL for our API. You can use any GraphQL client to test the endpoints.
By default, there is a GraphQL playground available at http://localhost:<PORT>
for each service.
e.g. http://localhost:3001
for the ACL service.
- Clone the repo
- Install Docker
- Install Docker Compose
- Ask the Lead Engineer for the
.env
file and place it in the root directory of the project. N/B: The.env
file is not committed to the repository for security reasons. It has the database credentials and other sensitive information. - Run
docker-compose -f docker-compose.yml [-f docker-compose.<other_service>.yml] up --build
.
e.g.docker-compose -f docker-compose.yml -f docker-compose.acl-service.yml up --build
will build and start a multi-container setup that includes the API gateway, the ACL service and its database.
ORdocker-compose -f docker-compose.yml -f docker-compose.acl-service.yml -f docker-compose.shared-service.yml up --build
will build and start a multi-container setup with the ACL service, the Shared service and their respective databases.
N/B: The order of the files in the command is important. The first file is the main file and the other files are overrides. The overrides are used to add more services to the main file. So you can spin up as many services as you want by adding their respective override files to the command.
We are using GraphQL for our API. You can use any GraphQL client to test the endpoints.
By default, there is a GraphQL playground available at http://localhost/<upstream_service>
for each service.
e.g. http://localhost/acl-service
for the ACL service.
This is because we are using an API gateway. The API gateway is the entry point to the system. It routes requests to the respective services. You can find the upstream services in the nginx/nginx.conf
file.
N/B: http://localhost:<PORT>
also works on local but will not work with SSL termination in the API gateway in production. We will then use https://example.com/<upstream_service>
.
Every authorized contributor is allowed to contribute to the repository whether by adding features, bug fixing or participating in code reviews. All code reviews are done on GitHub by the Lead Engineer.
-
The
main
branch is the default branch and is protected. No one is allowed to push directly to themain
branch. -
The
dev
branch is the development branch. All work should be done on thedev
branch. Thedev
branch is protected. No one is allowed to push directly to thedev
branch. -
All work should be done on a separate branch. The branch name should be in the format:
feature/<feature_name>
orbug/<bug_name>
-
When you are done with your work, create a pull request to the
dev
branch. The pull request should be in the format:feature/<feature_name>
orbug/<bug_name>
-
The Lead Engineer will review the pull request and merge it to the
dev
branch if it is approved. N/B: This might change in future because of automated code reviews or streamlined pipelines. -
The Lead Engineer will merge the
dev
branch to themain
branch when a new release is ready.
This project is licensed under the MIT License - see the LICENSE file for details.