Skip to content

Latest commit

 

History

History
80 lines (57 loc) · 4.3 KB

ARCHITECTURE.md

File metadata and controls

80 lines (57 loc) · 4.3 KB

OTP Architecture

OTP is developed over more than 10 years, and most of the design documentation is in the code as comments and JavaDoc. Over the years the complexity have increased, and the natural developer turnover creates a demand for more architecture and design documentation. The new OTP2 documentation is put together with the source; hopefully making it easier to maintain. Instead of documenting modules in old style package-info.java files we use package.md files. This document should serve as an index to all existing top-level documented components.

This document is far from complete - hopefully it can evolve over time and become a good introduction to OTP architecture. The OTP project GitHub issues are a good place to look for detailed discussions on many design decisions.

Be sure to also read the developer documentation.

Modules/Components

Below is a list of documented components in OTP. Not every component is documented at a high level, but this is a start and we would like to expand this list in the future.

The Configuration module is responsible for loading and parsing OTP configuration files and map them into Plan Old Java Objects (POJOs). These POJOs are injected into the other components.

Short introduction to the REST API.

Used to import GTFS transit data files.

Used to import NeTEx transit data files.

Transit Routing

This is the OTP2 new transit routing engine implemented using the Raptor algorithm. It explains how Raptor works, the important concepts and the design. It might be worth reading even if you are not a developer - just to understand how the transit routing works.

The Raptor functionality is quite complex, so we want to isolate it from the remaining code. Therefore, the raptor component is designed to have as few dependencies as possible. In fact there are no dependencies from Raptor to other parts of OTP code, only to utility classes not found in the JDK. Also, the code follows a stricter object-oriented design, than most other parts of OTP. The Raptor implementation is highly critical code, hence we set the bar higher with respect to code quality.

OTP provides transit data to Raptor by implementing the raptor/api/transit model. The RoutingService is responsible for mapping from the OTP context to a RaptorRequest and then map the result, Raptor Path, back to the OTP internal domain. This might seem like a lot of unnecessary mapping, but mapping is simple - routing is not.

The performance of Raptor is important, and we care about every millisecond. All changes to the existing Raptor coded should be tested with the SpeedTest and compared with an earlier version of the code to make sure the performance is NOT degraded.

Describes the transfer functionality, the design and the implementation. The logic for finding the best transfer is distributed to the Raptor and the OptimizeTransferService .

Describes the itinerary list filter chain, used to post-process the itineraries returned from the routers in RoutingWorker, in order to sort and reduce the number of returned itineraries. It can also be used to decorate the returned itineraries, especially if it requires more complex calculations, which would be unfeasible to do during the routing process.