Skip to content

Implement Stellar Route Insights Exporter#672

Merged
mijinummi merged 2 commits into
MDTechLabs:mainfrom
Just-Bamford:feat/stellar-route-insights-exporter
Jun 27, 2026
Merged

Implement Stellar Route Insights Exporter#672
mijinummi merged 2 commits into
MDTechLabs:mainfrom
Just-Bamford:feat/stellar-route-insights-exporter

Conversation

@Just-Bamford

Copy link
Copy Markdown
Contributor

Description

This PR implements the Stellar Route Insights Exporter feature, enabling external consumption of route analytics and AI-generated recommendation insights.

this pr Closes #524

Problem Statement

Analytics data cannot be consumed externally. Users need a way to export route metrics and recommendation insights in portable formats for analysis, reporting, and integration with external systems.

Solution

Created a comprehensive export system that:

  • Exports route analytics (transfers, fees, slippage, settlement times, success rates)
  • Includes AI-generated recommendation scores and rankings
  • Supports multiple formats (CSV with configurable delimiters, JSON)
  • Provides advanced filtering and date range support
  • Handles both sync and async exports

Implementation Details

New Files

  • apps/api/src/exporters/routes/stellar/route-insights-exporter.module.ts - NestJS module definition
  • apps/api/src/exporters/routes/stellar/route-insights-exporter.service.ts - Core business logic with recommendation scoring
  • apps/api/src/exporters/stellar/route-insights-exporter.controller.ts - REST API endpoints
  • apps/api/src/exporters/routes/stellar/dto/route-insights-export.dto.ts - Request/response DTOs
  • apps/api/src/exporters/routes/stellar/route-insights-exporter.service.spec.ts - Unit tests

Modified Files

  • apps/api/src/app.module.ts - Registered RouteInsightsExporterModule

Features

Export Formats

  • CSV: Configurable delimiters (comma, semicolon, tab) with proper field escaping
  • JSON: Structured format with metadata

Route Metrics Exported

  • Total/successful/failed transfers
  • Success rate (%)
  • Average settlement time (ms)
  • Average fee
  • Average slippage (%)
  • Total volume transferred
  • Last updated timestamp

Recommendation Insights

  • Route ranking (1 = best)
  • Recommendation score (0-500+) based on:
    • Fee efficiency
    • Slippage minimization
    • Settlement time
    • Reliability score
    • Historical success rate

Filtering Options

  • Date range (ISO 8601, max 365 days)
  • Source/destination chain
  • Bridge name
  • Token symbol

API Endpoints

  • POST /exporters/routes/stellar/export - Generate export (CSV/JSON)
  • GET /exporters/routes/stellar/download/{exportId} - Download generated export
  • GET /exporters/routes/stellar/exports - List user's recent exports

Technical Details

Sync/Async Processing

  • Sync exports: Up to 5,000 rows (instant response)
  • Async exports: For larger datasets (future job queue support)

Integrations

  • Leverages StellarAnalyticsService for route metrics
  • Uses BridgeRecommendationEngine for scoring
  • Integrates with CsvBuilderUtil for format generation
  • Queries BridgeAnalytics repository

Error Handling

  • BadRequestException: Dataset too large for sync export, invalid date range
  • NotFoundException: No routes found matching criteria

Testing

  • Unit tests for service layer with mocked dependencies
  • Test cases cover:
    • Empty result handling
    • Large dataset validation
    • Export generation with recommendations
    • Error conditions

Acceptance Criteria Met

  • ✅ Insights exporter implemented with recommendation scoring
  • ✅ Export functionality operational with multiple formats
  • ✅ Common export formats supported (CSV, JSON)
  • ✅ Route metrics and recommendations properly exported
  • ✅ Integration with analytics module complete
  • ✅ Unit tests included

API Usage Example

curl -X POST http://localhost:3000/exporters/routes/stellar/export \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "format": "csv",
    "startDate": "2024-01-01",
    "endDate": "2024-01-31",
    "includeRecommendations": true,
    "includeRanking": true
  }'

- Add multi-format export functionality for Stellar route analytics
- Support CSV and JSON export formats with configurable options
- Integrate route metrics with recommendation engine scoring
- Implement filtering by date range, chain, bridge, and token
- Add sync/async export support with row limits
- Create REST API endpoints for export, download, and listing
- Include comprehensive unit tests and error handling
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Just-Bamford Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@mijinummi

Copy link
Copy Markdown
Collaborator

Hi @, kindly run build this fix this ci failures.

Thanks

… casting

- Fix import paths in analytics-record.interface.ts and export-options.interface.ts
- Fix import paths in csv-builder.util.ts
- Add type casting to support AnalyticsRecord to Record conversion
- All build checks now passing
@mijinummi mijinummi merged commit 4b5152c into MDTechLabs:main Jun 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Stellar Route Insights Exporter

2 participants