Social & community

Build a chat app with AI

A native chat build brief covering screens, data, access rules and a practical acceptance journey.

Apirex TeamUpdated AndroidiOS
On this page
  1. Screens
  2. Data model
  3. Native features
  4. Android notes (Kotlin and Jetpack Compose)
  5. iPhone notes (Swift and SwiftUI)
  6. Copy-paste prompt
  7. Acceptance test
  8. Frequently asked questions
5screens
6data tables
144word prompt
2platforms: Android, iOS

Two people exchanging a message is a stronger chat test than an animated conversation full of sample bubbles. This brief requires persisted messages, participant-scoped access and a real remote delivery path. Begin with one-to-one text and explicitly permitted images; settle blocking, reports and retention before expanding into group administration. A sent label should reflect server acknowledgement, not a decorative delay.

Screens

  • Chats: List only conversations the signed-in person currently belongs to.
  • Conversation: Read persisted messages and send text or an allowed camera attachment.
  • New chat: Choose an eligible recipient under the contact policy.
  • Profile: Manage identity, blocked contacts and notification preferences.
  • Sign in: Bind every message and device token to an authenticated account.

Data model

Chat records and relationships
TableKey fieldsPurpose
usersid (uuid), display_name (text), status (text)Expose minimal recipient identity rather than an unrestricted contact database.
conversationsid (uuid), created_at (timestamptz), kind (text)Identify the shared thread independently of its visible title.
membershipsconversation_id (uuid), user_id (uuid), joined_at (timestamptz), left_at (timestamptz)Provide the authoritative participant boundary for reads and sends.
messagesid (uuid), conversation_id (uuid), sender_id (uuid), client_key (uuid), body (text), created_at (timestamptz)Persist server-accepted messages and deduplicate retried submissions.
attachmentsid (uuid), message_id (uuid), storage_path (text), content_type (text)Keep media references behind the same participant policies as the parent message.
safety_recordsid (uuid), actor_id (uuid), target_id (uuid), action (text), status (text)Support protected abuse reports, blocks and moderator decisions.

Check active participation on the server for conversation queries, real-time subscriptions, attachment downloads and message inserts. Apply row-level security when connecting a backend and verify the sender is the authenticated user, not a client-provided identity. Restrict report evidence to authorized reviewers; define what blocking does to existing threads and enforce it beyond the composer. Store device tokens in a private account-scoped delivery registry with revocation on sign-out. Do not imply end-to-end encryption unless a separately specified implementation actually provides it.

Native features

Chat needs remote push for new messages, a system image picker for attachments, and careful keyboard behavior in the conversation screen. Use a configured FCM delivery path for Android and APNs with UserNotifications for iPhone; a socket update in an open thread is not a background notification. Prefer the platform photo picker over requesting an entire photo library. Keep upload progress and a failed attachment visible next to its draft. Default lock-screen alerts should identify the app without exposing private message contents, and tapping one must recheck that the recipient still belongs to that conversation.

Android notes (Kotlin and Jetpack Compose)

Compose the timeline as a LazyColumn keyed by message UUID, with a separate client key linking an outgoing draft to its server acknowledgement. Apply imePadding to the composer so the send button stays above the keyboard; do not scroll a reader away from older messages whenever a new one arrives. Launch the Android photo picker with rememberLauncherForActivityResult and retain a safe upload reference across rotation. Room can hold account-scoped pending sends, while WorkManager retries eligible uploads using the same client key. Test with two Android phones: attach an image, lose connectivity mid-upload, resume, and verify one message and one private attachment result.

iPhone notes (Swift and SwiftUI)

Use NavigationStack for conversation routes and a scrollable message collection with stable identities. PhotosPicker should feed an explicit attachment draft rather than immediately sending every selected image. Manage composer focus with FocusState, retaining the draft when a sheet closes and keeping the last bubble above the software keyboard. Store pending sends separately from accepted history so reconnects can merge by identifier. On an iPhone, background the recipient, send from another account, and tap the resulting push after removing that recipient from the thread. Access must be refused; repeat an ordinary permitted notification and confirm it opens the correct conversation.

Copy-paste prompt

Build this yourself 142 words · Android
Create a chat app for Android with Chats, Conversation, New chat, Profile and Sign in. Ask whether strangers may initiate contact, what blocking changes, who reviews reports and how long messages and attachments remain. Model users, conversations, memberships, messages, attachments and safety records. Enforce participant-scoped reads and writes on the server and private media storage. Use real-time updates plus persisted history, with client-generated deduplication keys for retried sends. Configure actual push delivery with server-held credentials and account-bound device tokens, never local mock message notifications. Support camera attachments only after permission and a successful authorized upload. Show loading, no chats, offline send failure, expired membership and permission denied clearly. Accept only after two real accounts exchange messages across restarts, an unrelated account cannot fetch thread or media, a block prevents the specified contact and a backgrounded recipient phone receives a genuine server-triggered alert.

Opens Apirex with this prompt in the box. Pick the Android · Kotlin tab before you send.

Acceptance test

Test the delivery boundary by accepting a message on the server and dropping the response before the sender receives it. Retrying with the original client key must recover the accepted message rather than create another copy. Distinguish sent from read: do not show a read receipt without an implemented recipient acknowledgement. Define message and report-evidence retention separately, including what a participant’s deletion request removes. Expired attachment links should be renewed only after a fresh membership check, never converted into public links to avoid an error.

  1. Sign in on two actual phones using accounts A and B, start an allowed conversation and send a uniquely worded text from A.
  2. Observe B receive the persisted message, reply with a camera photograph and verify both devices display one copy of each item.
  3. Background B and send another message through the configured backend; verify genuine remote push, then test visible-alert permission denial.
  4. Reopen both clients and confirm history remains intact; retry a failed send with the same client key and check it is not duplicated.
  5. Use account C to request the thread and photo directly, expecting denial; report and block A from B and verify the declared contact restriction server-side.

Frequently asked questions

Does real-time sync replace push delivery?

No: an active connection updates an open conversation, while remote push uses a configured delivery service to reach a backgrounded recipient. Test both paths rather than treating an in-app banner as proof of remote delivery.

Can a blocked sender still fetch old photos?

Specify whether past history remains readable after a block or membership removal. Apply that decision to private attachment download authorization as well as message queries.

May moderators read every conversation?

Do not grant unrestricted access by default. Define a narrowly authorized report-review process, explain it to participants and keep a record of moderator access to submitted evidence.

Build this blueprint

The blueprint prompt, ready for your platform. Edit anything before you send it.

AndroidKotlin · Jetpack ComposeReal source on your computer

Opens Apirex with this prompt. Pick the Android · Kotlin tab before you send. The Free plan includes 5 Rex Credits a day.