Files
satellite-provider/_docs/02_document/modules/common_interfaces.md
T
Oleksandr Bezdieniezhnykh 23ab05766d [AZ-370] Refactor C17: status / point-type enums + AC RT2 update
Replaces bare strings with two enums in Common/Enums/:
  RegionStatus { Queued, Processing, Completed, Failed }
  RoutePointType { Start, End, Action, Intermediate }

Adds a Dapper EnumStringTypeHandler<T> (DataAccess/TypeHandlers/)
that round-trips enums to/from lowercase strings, registered once
at startup via DapperEnumTypeHandlers.RegisterAll(). DataAccess now
references Common (project ref) so entities can carry the enum types.

Sites converted: RegionService (5), RouteProcessingService (3),
RoutePointGraphBuilder (4), entity Status/PointType columns. Log
message and summary file format preserved via .ToLowerInvariant().

API JSON contract preserved by adding JsonStringEnumConverter with
JsonNamingPolicy.CamelCase to the http JSON options — single-word
enum members serialize to the same lowercase strings as before.

DTO renamed: Common.DTO.RegionStatus -> RegionStatusResponse to
free the RegionStatus name for the new enum (forced by the task's
explicit enum name); the renamed DTO has no public-API impact at
the JSON wire level. Stale doc references updated.

AC RT2 in _docs/00_problem/acceptance_criteria.md now lists all 4
point types (start/end/action/intermediate).

Tests: 171 / 171 unit + 5 / 5 smoke green (was 141 + 5; +30 new tests
covering type handler round-trip, set/parse, unknown-value rejection,
idempotent registration, and the AC RT2 doc check).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 03:55:22 +03:00

3.2 KiB

Module: Common/Interfaces

Purpose

Service contracts defining the application's core operations. Implementations live in the per-component service projects (SatelliteProvider.Services.TileDownloader, SatelliteProvider.Services.RegionProcessing, SatelliteProvider.Services.RouteManagement). Cross-component runtime calls between Layer-3 components flow exclusively through these interfaces — there are no compile-time ProjectReference entries between the three sibling service projects.

Public Interface

ITileService

  • DownloadAndStoreTilesAsync(double lat, double lon, double sizeMeters, int zoomLevel, CancellationToken) → Task<List<TileMetadata>>: downloads missing tiles for a region and returns all tile metadata (existing + new)
  • GetTileAsync(Guid id) → Task<TileMetadata?>: retrieve a single tile by ID
  • GetTilesByRegionAsync(double lat, double lon, double sizeMeters, int zoomLevel) → Task<IEnumerable<TileMetadata>>: query tiles within a geographic region
  • GetOrDownloadTileAsync(int z, int x, int y, CancellationToken) → Task<TileBytes>: serve a tile by Z/X/Y, hitting cache, then repository, then downloader (added in AZ-310)
  • DownloadAndStoreSingleTileAsync(double latitude, double longitude, int zoomLevel, CancellationToken) → Task<TileMetadata>: download one tile by lat/lon and persist (added in AZ-311)

IRegionService

  • RequestRegionAsync(Guid id, double lat, double lon, double sizeMeters, int zoomLevel, bool stitchTiles) → Task<RegionStatusResponse>: creates a region record and enqueues for async processing
  • GetRegionStatusAsync(Guid id) → Task<RegionStatusResponse?>: retrieves current status of a region request
  • ProcessRegionAsync(Guid id, CancellationToken) → Task: executes tile downloading, CSV/summary generation, optional stitching

IRouteService

  • CreateRouteAsync(CreateRouteRequest request) → Task<RouteResponse>: validates input, calculates intermediate points, persists route + points, optionally creates geofence regions
  • GetRouteAsync(Guid id) → Task<RouteResponse?>: retrieves route with all points

ISatelliteDownloader

  • GetTiles(GeoPoint geoPoint, double radiusM, int zoomLevel, CancellationToken) → Task: legacy interface for tile downloading (not directly implemented by GoogleMapsDownloaderV2)

IRegionRequestQueue

  • EnqueueAsync(RegionRequest request, CancellationToken) → ValueTask: add region request to the bounded queue
  • DequeueAsync(CancellationToken) → ValueTask<RegionRequest?>: consume next request (blocks until available)
  • Count (int): current queue depth

Internal Logic

Pure interface definitions — no logic.

Dependencies

  • All interfaces reference DTOs from SatelliteProvider.Common.DTO

Consumers

  • Program.cs — DI registration of implementations
  • RegionProcessingService — consumes IRegionRequestQueue and IRegionService
  • RouteService — consumes IRegionService (for geofence region creation)
  • RouteProcessingService — consumes IRegionService via service provider scope
  • API endpoints — consume ITileService, IRegionService, IRouteService

Data Models

None defined here.

Configuration

None.

External Integrations

None.

Security

None.

Tests

No dedicated interface tests.