Overview
The Invenicum project follows Flutter conventions with a well-organized structure that separates concerns and promotes maintainability.Root Directory Structure
lib/ Directory Breakdown
High-Level Organization
Detailed Structure
1. Entry Point
lib/main.dart
The application bootstraps here:
- Provider hierarchy setup (
lib/main.dart:64-261) - Router configuration
- Theme initialization
- Localization configuration
2. Configuration Layer
lib/config/
Centralized configuration management:
3. Core Infrastructure
lib/core/
Core utilities shared across the application:
app_router.dart: Defines all routes, auth guards, deep-link handlingsdk_plugin_parser.dart: Custom action parser for the plugin system
4. Data Layer
lib/data/
Contains all data-related code:
Models (lib/data/models/)
Data Transfer Objects (DTOs) representing API responses and business entities:
fromJson() and toJson() for serialization.
Services (lib/data/services/)
API integration layer:
- All services receive
ApiServicevia constructor - Use
diofromApiServicefor HTTP calls - Transform JSON to models using
Model.fromJson() - Throw exceptions for error handling
5. State Management Layer
lib/providers/
All application state is managed through ChangeNotifier providers:
- Manage domain-specific state (loading, data, errors)
- Call services for data operations
- Implement caching strategies
- Notify listeners on state changes
- Handle filtering, sorting, pagination (client-side)
6. Presentation Layer
lib/screens/
Full-page screens organized by feature:
- Each feature has its own directory
- Main screens at the top level
local_widgets/for screen-specific components (not reusable)- CRUD pattern: List, Detail, Create, Edit screens
7. Reusable Widgets
lib/widgets/
Shared widgets used across multiple screens:
main_layout.dart: Wraps all authenticated routes, provides header, sidebar, and plugin slotssidebar_layout.dart: Hierarchical navigation (containers, asset types, locations)stac_slot.dart: Dynamic widget slot for plugin UI injection
8. Localization
lib/l10n/
Internationalization files:
pubspec.yaml:89 enables generate: true for l10n.
Assets Organization
assets/
pubspec.yaml:92-93
Dependencies
pubspec.yaml
Key dependencies:
File Naming Conventions
-
Dart files:
snake_case.dart- Example:
inventory_item_provider.dart
- Example:
-
Screens:
{feature}_{action}_screen.dart- Example:
asset_create_screen.dart
- Example:
-
Widgets:
{name}_widget.dart- Example:
search_bar_widget.dart
- Example:
-
Models:
{entity}_model.dartor{entity}.dart- Example:
user_data_model.dart,loan.dart
- Example:
-
Services:
{domain}_service.dart- Example:
inventory_item_service.dart
- Example:
-
Providers:
{domain}_provider.dart- Example:
auth_provider.dart
- Example:
Code Organization Best Practices
Import Ordering
Follow this order in import statements:Directory Depth
- Keep nesting to maximum 3 levels when possible
- Use
local_widgets/to avoid cluttering screen directories - Group related screens in feature directories
Module Boundaries
- Screens should NOT import from other screen directories
- Widgets should be truly reusable (no business logic)
- Providers should NOT import screens or widgets
- Services should be pure (no Flutter dependencies except
debugPrint)
Navigation Patterns
Route Paths
Routes follow REST-like patterns:lib/core/routing/app_router.dart
Next Steps
- Architecture Overview - Understand the high-level design
- State Management - Learn the Provider patterns
- Contributing Guide - Guide to extending the app
