How muhd-fahad/contacts-app works
Project type + purpose (from file tree + README)
This is a Flutter application (cross-platform) named “contacts”. The README is the default Flutter template, so the file tree is the main source of architectural truth.
From lib/ structure, the purpose is a local contacts manager:
• CRUD screens: add_contact_screen.dart, update_contact_screen.dart, detailed_screen.dart, home_screen.dart
• Local persistence: lib/db/db_helper.dart
• State management: lib/provider/contact_provider.dart, lib/provider/theme_provider.dart
• Domain model: lib/model/contact_model.dart
Targets include Android (android/) and Web (web/).
Key directories / files
• lib/main.dart: App entrypoint; wires up providers, theme, routes, and initial screen.
• lib/screens/*: UI layer (Flutter widgets) representing user flows.
• lib/provider/*: State management / business orchestration (Provider pattern).
• lib/db/db_helper.dart: Persistence layer abstraction (likely SQLite via sqflite or similar).
• lib/model/contact_model.dart: Data model (entity + mapping to/from DB rows).
• android/ and web/: Platform shells/build artifacts (important for deployment view).
This strongly suggests a layered client-only architecture:
UI (screens) → State/Logic (providers) → Data Access (DB helper) → Local DB (SQLite / local storage)
No backend service is evident.
User interacts with a Screen
2. Screen calls ContactProvider methods (e.g., addContact(), loadContacts(), updateContact(), deleteContact())
Screen rebuilds based on provider state
• Data returning from DB → Provider → UI
• Notifications from Provider → UI (reactive rebuild)
Theme flow
• Any Screen → ThemeProvider (toggle/set theme)
• ThemeProvider → MaterialApp theme config (in main.dart)
• ThemeProvider notifyListeners() → UI rebuild
Provider-based reactive architecture
• UI is reactive to provider changes (notifyListeners)
• Providers centralize state + coordinate data access
• Screens should be mostly “dumb” views (even if some logic exists)
Layer separation (client-only)
• Screens: presentation
• Providers: state + orchestration
• DBHelper: data access layer (DAL)
• Model: domain/data representation