The API Gateway provides a unified entry point to the Ninja Tech marketplace challenge system. It manages:
- Routing requests to appropriate backend services.
- Authentication and session management.
- Project Setup (Docker)
- Alternative Project Setup (Without Docker)
- Access Endpoints
- Related Repositories
This project setup requires you to have docker installed. If you prefer to run ninja and ninjaGateway services manually, refer to the Alternative Project Setup section.
Clone both the ninja and ninjaGateway repositories into a directory:
git clone https://github.com/caiomarinello/ninja.git
git clone https://github.com/caiomarinello/ninjaGateway.gitAdd the following setup files to the root directory:
Ensure that these files are placed in the root directory of your project, alongside the cloned ninja and ninjaGateway repositories.
The .env should contain the following variables:
MYSQL_ROOT_PASSWORD="root_password_here"
MYSQL_DATABASE="database_name"
MYSQL_USER="database_username"
MYSQL_PASSWORD="database_password"A .env.example file is provided in both projects. Ensure that the Database configuration variables match with the.env variables in the previous step.
In the root directory where all repositories are cloned, run the following command to build and start the services:
docker-compose up --buildThis will set up the environment, build the Docker containers, and start the services as defined in the docker-compose.yml file.
If you prefer to run the project without Docker, you can follow the steps below to set up and run both the ninja and ninjaGateway services manually. This setup requires you to have Go and MySQL installed on your local machine.
Clone both the ninja and ninjaGateway repositories to your local machine:
git clone https://github.com/caiomarinello/ninja.git
git clone https://github.com/caiomarinello/ninjaGateway.gitRefer to steps 2 and 3 of Project setup with docker.
Run init.sql file to Set Up the Database. You can execute this file using the MySQL command line or a database management tool like MySQL Workbench.
Example command to run init.sql via MySQL command line:
mysql -u user -p < path/to/init.sqlNavigate to the ninja directory and run it using:
go run main.goNavigate to the ninjaGateway directory and run it using:
go run main.go| Method | Endpoint | Description | Access | Status |
|---|---|---|---|---|
| POST | /register |
Register a new user. | User | 🟢 Implemented |
| POST | /login |
Authenticate a user in a session. | User | 🟢 Implemented |
| POST | /logout |
Log out the authenticated user. | User | 🟢 Implemented |
More endpoints can be accessed via the ninja service, refer to the following README:
- Backend API: Ninja Backend API