How carlossousa2001/chat-ia works
Project Type and Purpose
• This is an Android mobile application (“Chat-IA”) written in Kotlin.
• Its purpose is to provide a chat interface that communicates with the external Gemini AI service to generate intelligent, natural-language responses.
• It follows Clean Architecture principles, separating the codebase into Data, Domain, and Presentation layers.
Main Architectural Components
a. Presentation Layer (app/src/main/java/com/rocketseat/rocketia)
– UI screens and view‐models/fragments (e.g., MainActivity, WelcomeFragment, UiState)
– Material Design 3 components, state management with Kotlin Flow/Coroutines
b. Domain Layer
– Business use cases (e.g., “SendMessageUseCase”, “ReceiveResponseUseCase”)
– Domain models defining chat messages, session state
c. Data Layer
– Repository implementations that fulfill domain contracts
– Network data sources calling Gemini AI API via Retrofit/HttpClient
– (Optional) Local data sources or caching mechanisms
d. External Services
– Gemini AI REST/HTTP interface
– Google Play Services or backup rules (XML in res/xml)
e. Android Framework & Build
– Gradle/Kotlin DSL scripts (build.gradle.kts, settings.gradle.kts)
– ProGuard rules, resource directories, manifest
Component Relationships and Data Flow
1. User taps “Send” in the UI →
2. Presentation Layer dispatches to a ViewModel or Controller →
3. ViewModel invokes a Domain Use Case →
4. Use Case calls the Data Layer’s ChatRepository →
5. ChatRepository issues an HTTP request to Gemini AI →
6. Gemini responds with a JSON payload →
7. Repository maps JSON to Domain Models →
8. Domain Use Case returns the result to the Presentation Layer →
9. UI State is updated and the new message appears on screen
Architectural Patterns & Design Principles
• Clean Architecture: strict separation of concerns, dependency inversion (domain independent of data/framework).
• Reactive streams: Kotlin Coroutines & Flow for asynchronous calls and state updates.
• Single-Activity / multiple Fragments pattern for navigation.
• Material Design 3 for UI consistency.