How saranmk1924/saran-ai-chat-assistant works
Saran AI is a Flutter chat assistant whose app streams Gemini responses through a Cloudflare Worker, keeping Gemini credentials and model selection server-side. The main flow is user input through ChatPage and ChatBloc, the send use case and repository, then the remote datasource and Worker to Gemini; streamed text returns to the bloc and the conversation is saved locally when the turn ends. History restore/clear, context limits, error handling, and presentation polish are separate capabilities. Unsampled Dart modules are represented by paths from the tree; their internal calls are not inferred.
Main entry points: chat_bloc.dart Chat BLoC · chat_remote_datasource.dart Remote datasource · chat_repository_impl.dart Repository implementation · index.js Worker proxy
Components 20
Chat presentation
- Chat page
ai_chat_assistant/lib/feature/chat/presentation/pages/chat_page.dart - Chat widgets
ai_chat_assistant/lib/feature/chat/presentation/widgets - Chat BLoC
ai_chat_assistant/lib/feature/chat/presentation/bloc/chat_bloc.dart - Typewriter effect
ai_chat_assistant/lib/core/utils/typewriter.dart
Chat domain
- Send message
ai_chat_assistant/lib/feature/chat/domain/usecase/send_message_usecase.dart - History actions
ai_chat_assistant/lib/feature/chat/domain/usecase - Context window
ai_chat_assistant/lib/feature/chat/domain/policy/context_window.dart - Repository contract
ai_chat_assistant/lib/feature/chat/domain/repository/chat_repository.dart - Message entity
ai_chat_assistant/lib/feature/chat/domain/entity/message_entity.dart - Chat errors
ai_chat_assistant/lib/feature/chat/domain/failure/chat_exception.dart
Chat data
- Repository implementation
ai_chat_assistant/lib/feature/chat/data/repository/chat_repository_impl.dart - Message model
ai_chat_assistant/lib/feature/chat/data/model/message_model.dart - Remote datasource
ai_chat_assistant/lib/feature/chat/data/datasource/chat_remote_datasource.dart - Local datasource
ai_chat_assistant/lib/feature/chat/data/datasource/chat_local_datasource.dart
App platform
- App configuration
ai_chat_assistant/lib/core/config/app_config.dart - Proxy client
ai_chat_assistant/lib/core/network/proxy_client.dart
AI backend
- Worker proxy
backend/src/index.js
Other components
- User
- Device preferences
- Gemini API
Connections 23
- User → Chat page: enters message
README.md - Chat page → Chat BLoC: dispatches events
README.md - Chat page → Chat widgets: renders
- Chat BLoC → Send message: calls
README.md - Chat BLoC → History actions: loads and saves
- Chat BLoC → Chat widgets: emits updates
README.md - Chat BLoC → Typewriter effect: uses pacing
- Send message → Repository contract: calls
README.md - History actions → Repository contract: uses contract
- Repository implementation → Repository contract: implements
README.md - Repository implementation → Remote datasource: requests replies
README.md - Repository implementation → Local datasource: persists history
README.md - Repository implementation → Message model: converts messages
README.md - Remote datasource → Proxy client: sends request
- Remote datasource → Worker proxy: posts messages
README.md - Worker proxy → Gemini API: requests stream
README.md - Gemini API → Worker proxy: streams events
README.md - Worker proxy → Remote datasource: passes stream
README.md - Remote datasource → Chat BLoC: yields fragments
README.md - Local datasource → Device preferences: reads and writes
README.md - App configuration → Proxy client: configures proxy
- Chat BLoC → Chat errors: handles typed errors
README.md - Chat BLoC → Context window: applies limits