How thunder-app/thunder works
Overall Project Type and Purpose
• Thunder is a Flutter client built primarily for mobile (iOS/Android) with additional support on web, Linux, macOS, and Windows.
• Its role is to consume and display content from Lemmy instances while managing user sessions, local preferences, and caching (via Drift for SQLite).
Major Components
a. Platform-Specific Shells/Builds:
• These components provide the required platform wrappers and build configurations.
b. Presentation/UI Layer:
• Flutter UI layer located mostly in the “lib” directory.
• Modular structure – for example, separate feature areas such as account, comment, community, feed, post, search, settings, and notification. Each of these is organized with a “pages”, “widgets”, and often “bloc” subdirectory.
• That the UI is built using Flutter’s widget system, Material design principles, and custom theming (supported by components under lib/core/theme).
c. Business Logic / State Management Layer:
• Extensive use of the BLoC and Cubit patterns across the project (e.g., lib/account/bloc, lib/feed/bloc, lib/moderator/bloc, lib/user/bloc, etc.).
d. Data Access & Persistence Layer:
• Local database component that uses Drift (a wrapper around SQLite) as found in lib/core/database and its associated migrations, schema versions, and type converters.
• How this layer interacts with the business logic layer to cache account information, posts, favorites, settings, etc.
• To include the migration/update process (documented in the README) for schema evolution.
e. Network/API Integration:
• Although not directly visible as “network” directories, note that there are helper files (such as in lib/core/auth/helpers and lib/instance/utils) which likely manage RESTful API calls and server integrations with Lemmy.
• Directional flows for fetching posts, communities, notifications, etc. from Lemmy instances, and pushing user actions (like votes, post creation) back to the server.
f. Shared Components & Utilities:
• A component for shared utilities (lib/shared, lib/utils) responsible for common functionality such as navigation, error handling, theming, media, and language support.
• These typically intersect both the UI and business logic layers.
g. Build & Deployment Pipeline:
Relationships and Data Flows
• From the business logic layer, show calls to the Data Access layer (for local caching and database read/write operations) and to external API integrations (for network operations).
• Return paths where data or state updates propagate back to the UI.
• Configuration and settings flows (e.g., the theme, localization, and app settings available via lib/settings).
Additional Details
• Don’t overcomplicate by adding every file—focus instead on major directories and modules to provide a high-level view that still conveys the essential architecture.