Skip to content

Qionar/odds-microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This solution demonstrates my approach to microservices architecture and API integration. While designed as a recruitment task, I've focused on clean architecture and demonstrability over production-ready features.

The following production considerations were intentionally simplified but would be essential for live deployment:

  1. Documentation (OpenAPI)
  2. Rate Limitation, API provider limits verification
  3. Caching for odds microservice
  4. Health check endpoints
  5. CI/CD
  6. Tests - unit tests would require extensive mocking of external APIs and database calls
  7. Better logging + eg. graylog
  8. Error tracker eg. Sentry
  9. Better error handling - for both microservices, especially in places with external API usage
  10. Scheduler for refetching odds from API, I'd use Bull Queues with its dashboard
  11. Separate each microservice to independent git repository

Quick architecture overview

  • Odds Provider – fetches odds from an external API and stores them in a local PostgreSQL database.
  • Sheets Publisher – publishes data to Google Sheets.
  • API Gateway – aggregates and exposes a unified API for the frontend or other consumers.

Architecture

  • NestJS – backend framework for all services.
  • PostgreSQL – database for storing odds.
  • Google Sheets API – for presenting data to users.
  • Docker Compose – for local development and orchestration.

Installation

Clone repository

Create corresponding .env for projects

cd odds-provider && cp .env.example .env

cd sheets-publisher && cp .env.example .env

cd api-gateway && cp .env.example .env

Add missing variables

Odds Provider:

Sheets Publisher:

  • GOOGLE_CLIENT_EMAIL and GOOGLE_PRIVATE_KEY - Enable Google Sheets API and Google Drive API in Google Cloud Console, generate service account credentials and extract values from the JSON file.

Create local database

docker compose up -d --build

Available endpoints (API Gateway)

Refetch odds from external data provider
curl --location --request POST 'localhost:4000/api/odds-sync/force-refresh-odds' \
--header 'Content-Type: application/json'
Insert odds to Google Sheet
curl --location --request POST 'localhost:4000/api/odds-sync' \
--header 'Content-Type: application/json' \
--data-raw '{
    "emailsToInvite": ["<YOUR_EMAIL_HERE>"]
}'

In response you'll receive:

{
  "spreadsheetId": "exampleId",
  "spreadsheetUrl": "https://docs.google.com/spreadsheets/d/exampleId/edit",
  "insertedRows": 100,
  "emailsWithAccess": [
    // invited emails
  ]
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published