Skip to content

melodia-grupo09/metrics

Repository files navigation

Melodía Metrics Service

CI/CD Status Coverage Status Node.js Version NestJS Version TypeScript Version MongoDB Version RabbitMQ Version

Metrics microservice built with NestJS for the Melodía platform.

Live Deployment

The application is deployed on Heroku and accessible at: https://melodia-metrics-e9ca6dea743b.herokuapp.com/

Overview

This Metrics Service provides comprehensive analytics and tracking for the Melodía platform, offering:

  • Real-time Metrics Collection: Track user interactions, song plays, likes, and shares
  • RabbitMQ Integration: Asynchronous message processing for scalable metrics collection
  • MongoDB Storage: Efficient storage and querying of metrics data
  • RESTful API: Comprehensive endpoints for metrics retrieval and analysis

Architecture

The metrics service follows a microservices architecture pattern with event-driven communication:

  • Metrics Collection Layer: Captures user interactions and system events
  • RabbitMQ Integration: Asynchronous message processing for scalable data ingestion
  • Data Storage Layer: MongoDB for efficient metrics storage and querying

RabbitMQ Message Routing

This project uses one queue with one exchange, with one topic and multiple routing keys, the benefits of this approach are:

  • Native RabbitMQ Routing: Leverages RabbitMQ's built-in routing capabilities rather than application-level logic
  • Better Performance: Message routing happens at the broker level, which is more efficient
  • Semantic Routing Keys: Keys like metrics.song.play clearly express intent and message type

Routing Key Structure

Format: metrics.<entity>.<action>

Examples
  • Song metrics: metrics.song.play, metrics.song.like, metrics.song.share
  • Album metrics: metrics.album.like, metrics.album.share
  • User metrics: metrics.user.registration, metrics.user.activity

Getting Started

Prerequisites

  • Node.js (>=18.0.0)
  • npm or yarn
  • MongoDB
  • RabbitMQ

Environment Variables

PORT=3000
MONGODB_URI=mongodb://admin:admin@localhost:27017/metrics?authSource=admin
RABBITMQ_URL=amqp://localhost:5672
# Or for CloudAMQP
CLOUDAMQP_URL=...

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

API Documentation

For comprehensive API documentation, including all endpoints, request/response schemas, and interactive testing, visit our Swagger documentation:

Interactive API Documentation

Code Coverage

Comprehensive test coverage tracked automatically via Codecov:

Test Coverage

View Detailed Coverage Report & Interactive Graphs

Graph

Dependencies

Core Framework

  • NestJS: Modern Node.js framework with TypeScript support
  • MongoDB: NoSQL database for scalable metrics storage
  • RabbitMQ: Message broker for asynchronous event processing
  • Mongoose: MongoDB object modeling for Node.js

Development & Testing

  • Jest: Testing framework with mocking capabilities
  • ESLint: Code quality and style enforcement
  • TypeScript: Type safety and enhanced developer experience

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages