How mctop4ik/yamapapp works
Purpose and Entry Point
This is a C++ thread-planning service/CLI that retrieves station and search data, maps responses into domain flights/threads, and produces planned travel threads. The executable starts at bin/main.cc; build composition is defined in CMakeLists.txt.
Domain Model
Core business objects represent flights and candidate travel threads:
• lib/domain/flight.hpp
• lib/domain/thread.hpp
The repository abstraction separates planning logic from the data source:
• lib/domain/repository-interface.hpp
Application Layer
The application layer coordinates data retrieval and thread planning:
• lib/application/thread-planner-service.hpp
• lib/application/repository.hpp
• lib/application/json-to-thread-vector-mapper.hpp
thread-planner-service is the primary use-case boundary: it consumes repository-provided data and constructs/returns thread-oriented results. The mapper adapts stored or received JSON into domain thread vectors.
Presentation Boundary
A controller exposes the planning use case to the executable-facing layer:
• lib/presentation/thread-controller.hpp
• bin/main.cc
Control likely flows from main through the controller into ThreadPlannerService, keeping command/input handling outside domain and application logic.
Infrastructure Request Pipeline
Infrastructure implements endpoint access as middleware/request chains:
• lib/infrastructure/search-request-chain.hpp
• lib/infrastructure/all-stations-request-chain.hpp
• lib/infrastructure/base-middleware.hpp
Search and station retrieval are separate pipelines. Middleware supports cross-cutting stages including cached data, JSON acquisition, and prefetching:
• lib/infrastructure/cache-middleware.hpp
• lib/infrastructure/json-provider-middleware.hpp
• lib/infrastructure/prefetch-data-middleware.hpp
External Data, Mapping, and Storage
The system integrates with an HTTP-style external station/search API through endpoint abstractions:
• lib/infrastructure/endpoint-interface.hpp
• lib/infrastructure/search-endpoint.hpp
• lib/infrastructure/all-stations-endpoint.hpp
Request/response boundaries are explicit:
• lib/infrastructure/http-request-dto.hpp
• lib/infrastructure/search-response-mapper.hpp
• lib/infrastructure/all-stations-mapper.hpp
JSON persistence/caching is encapsulated in lib/infrastructure/json-storage.hpp and lib/infrastructure/lru-cache.hpp. API-token absence is modeled as a dedicated infrastructure failure in lib/infrastructure/no-api-token-exception.hpp.
Runtime Concerns
The runtime is a native C++ executable built with CMake. Logging and date handling are infrastructure services:
• lib/infrastructure/logger.hpp
• lib/infrastructure/date-utils.hpp
• lib/application/config.hpp
The key architectural boundary is domain/application code depending on repository and endpoint interfaces, while concrete HTTP, JSON, cache, and API-token concerns remain in infrastructure.
Main entry points: repository.hpp Application repository · search-endpoint.hpp Search endpoint · thread-planner-service.hpp Thread planner service · all-stations-endpoint.hpp Stations endpoint
Components 22
Runtime
- CLI executable
bin/main.cc - CMake build
CMakeLists.txt
Presentation
- Thread controller
lib/presentation/thread-controller.hpp
Application
- Thread planner service · Coordinates retrieval and planned-thread construction.
lib/application/thread-planner-service.hpp - Application repository
lib/application/repository.hpp - JSON thread mapper
lib/application/json-to-thread-vector-mapper.hpp - Application config
lib/application/config.hpp
Domain
- Flight
lib/domain/flight.hpp - Travel thread
lib/domain/thread.hpp - Repository interface · Separates planning from data-source implementation.
lib/domain/repository-interface.hpp
Infrastructure
- Search request chain
lib/infrastructure/search-request-chain.hpp - Stations request chain
lib/infrastructure/all-stations-request-chain.hpp - Base middleware
lib/infrastructure/base-middleware.hpp - Cache, JSON & prefetch · Cross-cutting cached-data, JSON-acquisition, and prefetch stages.
lib/infrastructure/cache-middleware.hpp - Endpoint interface
lib/infrastructure/endpoint-interface.hpp - Search endpoint
lib/infrastructure/search-endpoint.hpp - Stations endpoint
lib/infrastructure/all-stations-endpoint.hpp - Response mappers · Maps search and station API responses.
lib/infrastructure/search-response-mapper.hpp - JSON storage
lib/infrastructure/json-storage.hpp - LRU cache
lib/infrastructure/lru-cache.hpp - HTTP request DTO
lib/infrastructure/http-request-dto.hpp - Logging, dates & token failure · Provides logging/date utilities and models missing API-token failure.
lib/infrastructure/logger.hpp
Connections 26
- CMake build → CLI executable: builds
- CLI executable → Thread controller: invokes
- Thread controller → Thread planner service: plans threads
- Thread planner service → Repository interface: retrieves through
- Thread planner service → Travel thread: returns
- Thread planner service → Flight: plans from
- Application repository → Repository interface: implements
- Application repository → Search request chain: requests search data
- Application repository → Stations request chain: requests station data
- Application repository → JSON thread mapper: maps JSON
- JSON thread mapper → Travel thread: creates vectors of
- Search request chain → Base middleware: composes
- Stations request chain → Base middleware: composes
- Base middleware → Cache, JSON & prefetch: base for
- Cache, JSON & prefetch → JSON storage: persists JSON
- Cache, JSON & prefetch → LRU cache: uses
- Search request chain → Search endpoint: calls
- Stations request chain → Stations endpoint: calls
- Search endpoint → Endpoint interface: implements
- Stations endpoint → Endpoint interface: implements
- Search endpoint → HTTP request DTO: uses
- Stations endpoint → HTTP request DTO: uses
- Search endpoint → Response mappers: maps response
- Stations endpoint → Response mappers: maps response
- Application repository → Application config: reads
- Search endpoint → Logging, dates & token failure: uses