This repository contains a microservices architecture developed using gRPC and Protobuf. The architecture restricts all microservices from direct external access and are only available via the API Gateway. Inter-microservice communication is handled through gRPC.
- Docker (installation page)
- Terraform (installation page)
- Ansible (installation page)
- Protobuf compiler (installation page)
- sqlc (installation page)
- Clone the repository
- Run the command:
make tf-up
in theapi-gateway
directory. This will launch the infrastructure with the API Gateway and all the microservices on Scaleway. - Then run the command:
infra/ansible/scripts/run-all-playbooks.sh -pkp "<your_private_key_path>"
in theapi-gateway
directory. This will install all the dependencies and start all the microservices. - Once the commands above are finished, you should have an
instance_ip
as a Terraform output (you can access it, by going in the directoryinfra/terraform
and run the command:terraform output
to get it). You can use this IP to access the API Gateway. - To test the API Gateway, you can use Postman or any other REST client. The API Gateway URL is available at
<your_instance_ip>:8080
.
To create a new user, send a POST request to <your_instance_ip>:8080/v1/users
with the following body:
{
"email": "<your_email>",
"password": "<your_password>"
}
If the user is successfully created, you should get a response like this:
{
"auth_token": "<your_auth_token>"
}
To log in, send a POST request to <your_instance_ip>:8080/v1/users/login
with the following body:
{
"email": "<your_email>",
"password": "<your_password>"
}
If the user is successfully logged in, you should get a response like this:
{
"auth_token": "<your_auth_token>"
}
To create a new note, send a POST request to <your_instance_ip>:8080/v1/notes/create
with a header Authorization
with the value <your_auth_token>
and the following body:
{
"title": "<your_note_title>",
"content": "<your_note_content>"
}
If the note is successfully created, you should get a response like this:
{}
To get all notes, send a GET request to <your_instance_ip>:8080/v1/notes
with a header Authorization
with the value <your_auth_token>
.
If the notes are successfully retrieved, you should get a response like this:
{
"notes": [
{
"id": "<note_id>",
"title": "<note_title>",
"content": "<note_content>"
},
{
"id": "<note_id>",
"title": "<note_title>",
"content": "<note_content>"
},
]
}
make buf
in the api-gateway
directory.
make sqlc
in the api-gateway
directory.
- Protobuf compiler (installation page)
- sqlc (installation page)
- Clone the repository
- Make changes
- Run the command:
make run
in theapi-gateway
directory. This will start the API Gateway and all the microservices. - To test the API Gateway, you can use Postman or any other REST client. The API Gateway is available at
localhost:8080
.
- Go - Programming language
- gRPC - RPC framework
- Protobuf - Interface definition language
- PostgreSQL - Database
- sqlc - Generate type safe Go code from SQL
- Docker - Containerization platform
- Make - Build automation tool
Made with ❤️ by Réda Maizate @ Seoul 🇰🇷 & Paris 🇫🇷