-
Notifications
You must be signed in to change notification settings - Fork 52
10. Codebase Overview
Language: English. Chinese version: 10. Codebase Overview (中文)
Trail Mate is no longer a repository with only a few .ino files and some UI pages. It now spans device firmware, protocol interoperability, offline maps, Team, HostLink, multi-hardware adaptation, and shared UI logic. Because of that, the repository structure is part of the system design rather than just an organizational convenience.
The goal of this page is not to walk through every file. It is to answer a more practical question: if you need to find a certain kind of logic, where should you look first.
The most important top-level directories in the current repository are:
apps/
boards/
docs/
modules/
platform/
tools/
variants/
src/
This directory holds application shells and entry points. Current subdirectories include:
esp_pio/
esp_idf/
gat562_mesh_evb_pro/
linux_sim/
linux_rpi/
linux_unoq/
The most useful ones to understand first are:
-
apps/esp_pio/: the Arduino and PlatformIO mainline shell -
apps/esp_idf/: the shared ESP-IDF shell root -
apps/gat562_mesh_evb_pro/: the independent nRF52 monochrome target shell
If you want to know where the program starts, when board initialization happens, or where AppContext is assembled, this is the first place to look.
This directory is where board truth and board runtime live, not just a list of configuration names. Current board directories include:
gat562_mesh_evb_pro/
tab5/
tdeck/
tdeck_pro/
tlora_pager/
twatchs3/
t_display_p4/
If you need:
- pin-level facts
- board initialization sequence
- GPS, LoRa, SD, or input-device bring-up
- an explanation of why one board behaves differently from another
start here before guessing from the shared UI or protocol layers.
This is the main home of shared logic. Current module families include:
core_chat/
core_gps/
core_hostlink/
core_sys/
core_team/
ui_mono_128x64/
ui_shared/
A useful shorthand is:
-
core_chat/: chat, contacts, shared protocol logic, node identity, and related flows -
core_gps/: GPS configuration, filters, status, and movement strategy -
core_hostlink/: HostLink protocol logic and shared models -
core_sys/: application configuration and system-level shared structures -
core_team/: Team domain model, protocol, and use cases -
ui_shared/: most shared pages and shared menu logic -
ui_mono_128x64/: runtime for the monochrome small-screen UI
If you are changing project-wide behavior, this directory is often more relevant than boards/.
This is the platform adaptation layer. Current branches include:
esp/
linux/
nrf52/
shared/
Its responsibility is not to define product behavior, but to connect shared logic to platform capabilities such as:
- BLE
- LoRa transport
- GPS hardware
- file systems
- clocks and timers
- display and input adaptation
When shared business logic starts depending directly on Arduino, ESP-IDF, or board-specific headers, the project boundary is usually being weakened.
This directory mainly serves the PlatformIO route. Many differences in build environments, screen size, radio variants, and debug macros are defined here rather than in the root platformio.ini.
If you need to find:
-
SCREEN_WIDTHorSCREEN_HEIGHT - which debug macros are enabled on a target
- whether a radio variant has a dedicated environment
this is often the right entry point.
This is not just a place for loose notes. It holds many of the project’s actual boundary facts and design intentions. Especially useful documents include:
ARCHITECTURE.mdMULTI_PROTOCOL_SUPPORT.mdTEAM.mdmap/SD_CARD_MAP_STRUCTURE_CN.mddevices/*
If you only read code and skip these documents, it is easy to mistake current implementation details for the intended long-term boundary.
This directory still exists, but the architecture notes make it clear that the project is continuing to move reusable logic toward modules/ and cleaner platform boundaries. So src/ should not automatically be treated as the repository’s only main battlefield.
Using the current PlatformIO path as an example, startup roughly looks like this:
-
apps/esp_pio/startup_runtime.cppbrings up serial and basic clock providers - board initialization enters a concrete board runtime through platform startup support
- display and LVGL initialization happens
-
AppContextbinds board, protocol, GPS, Team, background tasks, and related runtime pieces -
ui::startup_shellandapp_catalog_builderassemble the visible menu structure for the current device
This is important because it shows that the main menu is not a fixed hard-coded page list. It is assembled according to hardware capability, shell path, and runtime state.
Start with:
modules/core_chat/platform/esp/.../chat/infra/platform/nrf52/.../chat/infra/docs/MULTI_PROTOCOL_SUPPORT.md
Start with:
modules/core_gps/platform/esp/.../gps/- map-related UI under the platform and shared UI paths
docs/map/SD_CARD_MAP_STRUCTURE_CN.md
Start with:
modules/core_team/platform/esp/.../team/docs/TEAM.md
Start with:
boards/<target>/variants/<target>/- the device-specific documentation
Start with:
modules/ui_shared/modules/ui_mono_128x64/modules/ui_shared/src/ui/app_catalog_builder.cpp
The repository is not yet a finished post-refactor end state. docs/ARCHITECTURE.md already makes clear that the project is converging toward one shared core with multiple platform shells, while trying to avoid cloning full source trees again.
Because of that, the biggest maintenance risks are:
- putting shared business logic back into a board-specific shell
- letting platform details leak into shared modules
- cloning near-duplicate parallel implementations just to get one board working quickly
Those three mistakes matter more to the project’s future than the naming of any one function.
English
- Home
- 0. Why This Exists
- 1. Quick Start
- 2. Supported Hardware
- 3. Installation & Flashing
- 3.5 Configuration Guide
- 4. Protocols & Data
- 4.1 Reticulum, LXMF and RNode Bridge
- 5. Offline Maps
- 6. Trail Mate Center
- 7. Team Features
- 8. UI Overview
- 9. Build from Source
- 10. Codebase Overview
- 11. Architecture
- 12. Design Decisions
- 13. FAQ
- 14. Troubleshooting
- 15. Logging and Debugging
- 16. Roadmap
- 17. Contributing
- 18. License and Third-Party
- 19. GPS Setting Guide
中文
- Home (中文)
- 0. Why This Exists (中文)
- 1. Quick Start (中文)
- 2. Supported Hardware (中文)
- 3. Installation & Flashing (中文)
- 3.5 Configuration Guide (中文)
- 4. Protocols & Data (中文)
- 4.1 Reticulum, LXMF and RNode Bridge (中文)
- 5. Offline Maps (中文)
- 6. Trail Mate Center (中文)
- 7. Team Features (中文)
- 8. UI Overview (中文)
- 9. Build from Source (中文)
- 10. Codebase Overview (中文)
- 11. Architecture (中文)
- 12. Design Decisions (中文)
- 13. FAQ (中文)
- 14. Troubleshooting (中文)
- 15. Logging and Debugging (中文)
- 16. Roadmap (中文)
- 17. Contributing (中文)
- 18. License and Third-Party (中文)