Message structure
Each message in GemAI follows a well-defined data model that tracks essential information:Message.kt
Message participants
Messages are categorized by participant type, which determines how they’re displayed in the UI:- User messages
- AI responses
User messages represent input from you. They’re created using the User messages start with
Message.send() factory method:MessageStatus.LOADING status while being processed.The
Participant enum has two values: USER and MODEL. Each participant has a corresponding role property that maps to Gemini API requirements ("user" or "model").Message status indicators
The interface provides visual feedback through four distinct message states:Message status types
Message status types
- LOADING - Displayed while your message is being sent to the AI
- SENT - Indicates your message was successfully delivered
- FAILED - Shows when message delivery encountered an error
- RECEIVED - Marks AI responses that have been successfully received
update() method:
Message composition
When you compose a new message, the application creates it with automatic timestamp generation:Example: Creating a user message
Message display patterns
The chat interface handles different message scenarios with specific patterns:Receiving streamed responses
When the AI responds, messages can be created incrementally as content streams in:Example: Receiving AI message
Foreign key relationships
Messages maintain referential integrity through foreign key constraints in the Room database:MessageEntity structure
When you delete a conversation, all associated messages are automatically removed through cascade deletion.
User interaction flow
The typical interaction pattern in the chat interface follows these steps:- Compose - You type a message in the input field
- Send - The message is created with
LOADINGstatus - Process - Your message is sent to the Gemini API via the repository layer
- Stream - AI response is received incrementally and displayed in real-time
- Complete - Both messages are marked with final status (
SENTandRECEIVED)
Error handling in the UI
When message delivery fails, the status is updated toFAILED, providing visual feedback:
SendMessageUseCase, which handles the complete message lifecycle.
Startup prompts
GemAI provides smart startup prompts to help you begin conversations quickly. These pre-built suggestions appear when you first launch the app or start a new conversation.Prompt structure
Each startup prompt includes text, an icon, and creation timestamp:StartUpPrompt.kt
Prompt categories
Prompts are organized by icon type to indicate their category:CODE
Coding-related prompts and programming questions
LITERATURE
Writing, poetry, and creative content prompts
TRANSLATION
Language translation and linguistic prompts
SCIENCE
Scientific and technical questions
View all prompt categories
View all prompt categories
GemAI supports 21 different prompt categories including:
- CODE - Programming and development
- LITERATURE - Writing and creative content
- TRANSLATION - Language and translation
- SCIENCE - Scientific topics
- ART - Design and artistic prompts
- EDUCATION - Learning and teaching
- HEALTH - Wellness and medical
- ENTERTAINMENT - Media and fun
- FINANCE - Business and money
- TRAVEL - Exploration and trips
- FOOD - Culinary and recipes
- FITNESS - Physical activity
- ENVIRONMENT - Sustainability
- HISTORY - Historical topics
- TECHNOLOGY - Gadgets and tech
- And more…
Default prompts
The app includes four default startup prompts:PromptEntity.kt
Retrieving prompts
Use theGetPromptsUseCase to fetch available prompts:
GetPromptsUseCase.kt
Prompts are stored in the Room database and can be customized by adding new entries to the
prompts table.