Skip to content

Conversation

@SamuelRioTz
Copy link
Member

@SamuelRioTz SamuelRioTz commented Nov 27, 2025

Trufi Core v5 Architecture Plan

Reference: Issue #777


🏗️ Core Architecture

Monorepo & Workspace

  • Flutter workspace configured
  • Melos scripts (analyze, format, test, clean)

Routing

  • Go Router implementation

State Management

  • Bloc/Cubit migration

Dependency Injection

  • Get_It implementation

📦 Packages

trufi_core_maps

  • 3-Layer Architecture (Presentation/Domain/Data)
  • Multiple map providers (FlutterMap, MapLibre)

trufi_core_routing

  • OTP integration
  • GraphQL services
  • Route planning logic

trufi_core_location

  • Location search
  • Geocoding services
  • Place storage

trufi_core_feedback

  • Feedback functionality

trufi_core_settings

  • App settings management

🧹 Code Quality

  • Remove unused imports
  • Fix deprecated APIs

Progress: 3/12 ✅

- Added TrufiFlutterMap for rendering maps using flutter_map.
- Introduced TrufiMapLibreMap for rendering maps using maplibre_gl.
- Created ImageTool for converting SVG to PNG and widgets to bytes.
- Developed MarkersContainer and MarkerLayers for managing markers.
- Established TrufiMapController for handling camera positions and layers.
- Added utility functions for color decoding and geographical calculations.
- Updated pubspec.yaml with necessary dependencies and environment settings.
- Implemented weather stations layer with fetching and displaying weather data.
- Created WeatherFeature model to represent weather station data.
- Added WeatherMarkerModal for displaying weather information in a modal.
- Introduced TileGrid for managing tile-based data fetching and rendering.
- Added utility functions for tile calculations and conversions.
- Created GraphQL queries for fetching alerts, parking, patterns, and stops.
- Implemented SortedList for maintaining a sorted collection of weather features.
- Added SVG icons for weather markers.
- Updated pubspec.yaml with necessary dependencies for new features.
- Removed FlutterMap and MapLibreGL implementations from the route navigation maps.
- Deleted ImageTool class responsible for converting SVG to PNG and widget to bytes.
- Removed TrufiMapController and related classes for managing map state and layers.
- Updated route_navigation.dart to use new map packages: trufi_core_maps and trufi_core_map_layers.
- Adjusted imports across various files to reflect the new structure and removed obsolete references.
- Added workspace configuration for Melos to manage multiple packages.
- Updated pubspec.yaml to include new dependencies and workspace settings.
- Added TrufiCameraPosition model for managing camera state.
- Introduced TrufiLine model for line representation on the map.
- Created TrufiMarker model for marker representation with image support.
- Implemented MarkersContainer and MarkerIndex for efficient marker management.
- Developed TrufiFlutterMap and TrufiMapLibreMap for rendering maps using flutter_map and maplibre_gl respectively.
- Established TrufiMapRender as an abstract class for common rendering functionality.
- Removed deprecated TrufiMapController and related classes.
- Updated pubspec.yaml to include new dependencies and removed unused packages.
- Implemented MapControls widget for managing map layers and render types.
- Created example application demonstrating trufi_core_maps features.
- Added pubspec.yaml and pubspec.lock for example app dependencies.
- Included basic widget test for the example app.
- Added web support with necessary HTML and manifest files.
- Introduced userAgentPackageName parameter in TrufiFlutterMap for custom user agent handling.
…ionality

- Added TrufiMarker class to represent markers on the map with properties for position, widget, and rendering options.
- Introduced IFitCameraLayer and FitCameraLayer to manage camera fitting based on geographical bounds.
- Created LayerUtils for tile URL templating and extracting ZXY coordinates from URIs.
- Developed TrufiLayer as a base class for managing markers and lines on the map.
- Implemented TrufiFlutterMap and TrufiMapLibreMap for rendering maps using flutter_map and maplibre_gl respectively.
- Established TrufiMap as an abstract class for consistent map widget structure.
- Organized the codebase into a clear 3-layer architecture: Presentation, Domain, and Data layers.
@SamuelRioTz SamuelRioTz requested a review from md-weber November 28, 2025 09:14
@SamuelRioTz SamuelRioTz linked an issue Nov 28, 2025 that may be closed by this pull request
@md-weber
Copy link
Collaborator

I just had a quick glance, but one thing that stuck out was that the example should be in the apps/ folder. Also I would recommend moving the trufi_core into the app's folder, even if it is not an app but for this project it is the main app.

@md-weber
Copy link
Collaborator

Regarding the layers I would argue to fletch them out of the packages into the own packages, the reason is simple. If a 3rd Party customer wants to use its own backend for maps etc. We could allow that by replacing the internal package with one of his, so we would just need to maintain the Interfaces.

Instead of

trufi_map/data
trufi_map/presentation
trufi_map/domain

You would have general

data/trufi_map_api
domain/trufi_map_feature
presentation/trufi_homepage

With that the homepage could use different domain features and would be still extensible in the future. Wdyt?

@md-weber
Copy link
Collaborator

Another tricky part is the Get_it infrastructure. Which allows dependency injection. It would be great if trufi_core has some kind of "registerModules" function where it registers all get_it dependencies from the different packages.

But it is important that a parent application can overwrite and extend them and use their own get_it implementation. I will think about that a bit, but maybe you already have a solution.

- Add domain entities: Place, Plan, PlanLocation, RealtimeState, Route, RoutingLocation, Step, TransportMode, VertexType.
- Create repositories for plan and map route management.
- Develop routing service for trip planning and itinerary management.
- Introduce presentation layer components: RoutingMapLayer, RoutingMapController, LegMarkerFactory, and RoutingLocationAdapter.
- Establish GraphQL utilities for OTP data handling.
- Set up local storage for caching routing data.
- Update pubspec.yaml to include dependencies and package configuration.
- Added Otp27PlanRepository for handling OTP 2.7 plan queries.
- Introduced Otp28PlanRepository for OTP 2.8 with enhanced features.
- Created GraphQL queries for both OTP 2.7 and 2.8.
- Developed response parsers for OTP 2.7 and 2.8 to convert API responses into domain entities.
- Updated the otp_version.dart file to manage different OTP versions.
- Enhanced the Place entity to include bike rental station ID.
- Refactored the main routing library to export new OTP implementations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Proposal] Architecture for Trufi Core v5

3 participants