This is a POC project to demonstrate how to use NestJS microservices, using both RMQ only and RMQ + HTTP.
The goal is to get the geolocation (latitude and longitude) of a given address. This translation is done by the OSM API.
The project is composed of two microservices: geo-api
and geocoder
.
geo-api
is a NestJS microservice that accepts HTTP requests for addresses through a POST /geolocate endpoint, stores the request in a SQL database, and returns an id that will be used in the GET /geocode?id={id} endpoint to retrieve the coordinates.
geocoder
service is responsible for getting the coordinates from the OSM API and returning them back.
The communication between the services is done through RMQ
, using an event-based approach. The geo-api service publishes a geocode.request event, and the geocoder service listens for it and publishes a geocode.response event with the coordinates.
Both services have an .env.template file, you should copy it to .env and fill the variables with your own values.
For running it locally you can use:
yarn install
yarn start:dev # or yarn start
You should do the same for both services.
You can run the services using docker-compose:
cd infra
docker-compose up -d --build