Skip to content

helabenkhalfallah/treasure-map-game

Repository files navigation

Treasure Map Adventure

Project presentation

The Peruvian government has authorized adventurers seeking treasures to explore the 85,182 km2 of the Madre de Dios department. Treasure Map Game is used to track the movements and collections of treasures made by adventurers.

Here is the map to be displayed by the Frontend: alt text

  • Mountain are colored with yellow.
  • Treasure are colored with green.
  • Adventurers are colored with blue.
  • Clicking to "download" button, will download the output as a txt file.

The application consists of:

  • a frontend to display and download the movements and collections of treasures made by adventurers.
  • a GraphQL BFF to manage required output for all supported devices (mobile, web, etc.).
  • a CMS module that exposes required static data.
  • a commons module that holds all transversal commons utils and core.

🔴 Note that for a primary need (static data display), no BFB module is added and no database is configured.

🔴 An LRUCache is configured to replace a database.

Software architecture

The chosen architecture is a microservice architecture.

The efficient and lightweight nature of Node.js makes it the ideal platform for developing microservices.

What we gain from such an architecture is:

  • low coupling between modules.
  • flexibility of evolution (evolutionary architecture).
  • resilience.
  • independence in updates, maintenance and deployments.
  • handle unexpected challenges and changes.

Our current architecture is modeled as follows: alt text

This architecture accepts and tolerates updates, for example: alt text

The main idea is to protect the frontend domain as much as possible and avoid structural change and regressions if a new service has been added to the pipeline:

alt text

The graphql opens several ports to attach other data sources: microservices, databases, CMS, etc. The coupling between graphql and data sources is weak, which allows for easy swappable data sources.

Technical stack

Global project

Frontend

Backend

How to install?

Install dependencies

From the root folder:

pnpm install

This will install all needed dependencies for main and sub modules.

Start all microservices in local mode:

From the root folder:

pnpm start:dev

This will use NX to call all start:dev scripts.

In local mode, BFF and CMS module will use nodemon.

API documentation is accessible through this link:

http://localhost:5001/treasure-map/graphql

Other available routes:

http://localhost:5001/treasure-map/graphql
http://localhost:5000/treasure-map/cms/monitoring
http://localhost:5000/treasure-map/cms/health-checks
http://localhost:5000/treasure-map/cms/data-store/treasure-map

Start all microservices in production mode:

From the root folder:

pnpm start

This will use NX to call all start scripts.

In production mode, BFF and CMS module will use pm2.

Lintify all modules

From the root folder:

pnpm lint
pnpm lint:fix

This will use NX to call all lint or lint:fix scripts.

Testify all modules

From the root folder:

pnpm test
pnpm test:update

This will use NX to call all test or test:update scripts.

Health checks

All 'health check' routes are exposed through:

baseUrl/health-checks

Monitoring

It's possible to monitor each microservice through an exposed route or pm2:

baseUrl/monitoring

// or
pnpm monitor
pnpm info
pnpm logs