How sudeep-ps/chatbond works
Purpose and entry points
ChatBond is a cross-platform Flutter chat application with authentication, chat, profile/media, and settings flows. Flutter starts at lib/main.dart; application navigation and visual configuration are centralized in lib/config/router.dart and lib/config/theme.dart. Native hosts package the same Dart application for Android, iOS, desktop, and web, e.g. android/app/src/main/kotlin/com/example/chatbond/MainActivity.kt and ios/Runner/AppDelegate.swift.
Application composition
The app is organized by feature with a Clean Architecture-style separation:
• Presentation: pages, widgets, and state providers.
• Domain: entities, repository contracts, and use cases.
• Data: remote/local data sources and repository implementations.
This boundary is consistently represented by lib/features/auth/, lib/features/chat/, and lib/features/profile/. UI providers should invoke domain use cases/contracts rather than directly own transport or persistence details.
Authentication lifecycle
Authentication includes login, registration, forgot/reset-password, and OTP verification screens. The presentation state controller is lib/features/auth/presentation/providers/auth_provider.dart; user and OTP response models live in lib/features/auth/domain/entities/auth_user.dart and lib/features/auth/domain/entities/verify_otp_response.dart. Requests flow through lib/features/auth/data/datasources/auth_remote_data_source_impl.dart and lib/features/auth/data/repositories/auth_repository_impl.dart, behind the contract at lib/features/auth/domain/repositories/auth_repository.dart.
Chat and realtime flow
Chat is the primary interactive feature. lib/features/chat/presentation/pages/chat_page.dart renders conversations using state from lib/features/chat/presentation/providers/chat_provider.dart. Provider actions pass through chat use cases/repository boundaries to lib/features/chat/data/datasources/chat_remote_data_source_impl.dart. Domain models in lib/features/chat/domain/entities/chat.dart and lib/features/chat/domain/entities/message.dart define the shared business representation. Realtime socket connectivity is isolated in lib/core/websocket/socket_service.dart, separating event transport from chat UI and repository logic.
Profile and media pipeline
Profile UI and settings are rooted at lib/features/profile/presentation/pages/profile_page.dart and managed by lib/features/profile/presentation/providers/profile_provider.dart. Media selection/local handling is abstracted through lib/features/profile/data/datasources/media_local_data_source_impl.dart; remote asset upload/storage is separately abstracted in lib/features/profile/data/datasources/storage_remote_data_source_impl.dart. Corresponding repository contracts keep device-media and remote-storage concerns distinct.
Shared infrastructure and persistence
lib/core/network/api_client.dart is the common HTTP/API boundary used by remote data sources. Authentication/session persistence is isolated in lib/core/storage/auth_session.dart and lib/core/storage/token_storage.dart, allowing authenticated API behavior to be decoupled from feature screens. Shared exception types and Firebase helpers reside in lib/core/exceptions/exceptions.dart and lib/core/utils/firebase_utils.dart.
External platforms and services
The runtime is Flutter/Dart, targeting Android, iOS, web, Linux, macOS, and Windows. Firebase is configured via lib/firebase_options.dart with project deployment/configuration in firebase.json; Firebase utilities indicate Firebase-backed app capabilities. The app also depends on an external HTTP backend and a socket/WebSocket service, represented by the API client and socket boundary. Platform launch/build integration remains in the generated native projects, notably android/, ios/, web/, linux/, macos/, and windows/.
Main entry points: api_client.dart API client · router.dart Router & theme · auth_provider.dart Auth UI state · chat_provider.dart Chat state
Components 19
App shell
- Flutter entry
lib/main.dart - Router & theme
lib/config/router.dart - Native and web hosts · Packages the shared Flutter application for supported platforms.
android/app/src/main/kotlin/com/example/chatbond/MainActivity.kt
Authentication
- Auth UI state
lib/features/auth/presentation/providers/auth_provider.dart - Auth contract & models
lib/features/auth/domain/repositories/auth_repository.dart - Auth repository & remote
lib/features/auth/data/repositories/auth_repository_impl.dart
Chat
- Chat page
lib/features/chat/presentation/pages/chat_page.dart - Chat state
lib/features/chat/presentation/providers/chat_provider.dart - Chat domain
lib/features/chat/domain/entities/chat.dart - Chat remote source
lib/features/chat/data/datasources/chat_remote_data_source_impl.dart
Profile & media
- Profile UI state
lib/features/profile/presentation/pages/profile_page.dart - Local media source
lib/features/profile/data/datasources/media_local_data_source_impl.dart - Remote storage source
lib/features/profile/data/datasources/storage_remote_data_source_impl.dart
Core infrastructure
- API client
lib/core/network/api_client.dart - Session & token storage
lib/core/storage/auth_session.dart - Socket service
lib/core/websocket/socket_service.dart - Firebase integration
lib/firebase_options.dart
Other components
- HTTP backend
- WebSocket service
Connections 21
- Native and web hosts → Flutter entry: launches
- Flutter entry → Router & theme: initializes
- Router & theme → Auth UI state: routes to
- Router & theme → Chat page: routes to
- Router & theme → Profile UI state: routes to
- Chat page → Chat state: renders state from
- Auth UI state → Auth contract & models: uses contract
- Auth contract & models → Auth repository & remote: implemented by
- Auth repository & remote → API client: requests through
- Auth UI state → Session & token storage: persists session
- Chat state → Chat domain: uses domain boundary
- Chat domain → Chat remote source: loads via
- Chat remote source → API client: requests through
- Chat state → Socket service: realtime events
- Profile UI state → Local media source: selects media via
- Profile UI state → Remote storage source: uploads assets via
- Remote storage source → API client: uses API boundary
- API client → Session & token storage: uses auth token
- API client → HTTP backend: HTTP requests
- Socket service → WebSocket service: socket connection
- Firebase integration → HTTP backend: Firebase-backed capabilities