Health & fitness

Build a meditation app with AI

A native meditation timer build brief covering saved data, purposeful screens and a repeatable real-input acceptance journey.

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

This meditation timer build brief is for people timing self-directed quiet sessions without needing an audio catalogue. Its first version should prove one concrete loop: start, pause, resume and finish a session while preserving the actual active duration. Keep session durations, pause and resume controls, history and optional completion alerts connected to the same saved records before adding more ambitious integrations.

Screens

  • Home: Choose a user-defined session duration and review recent practice
  • Timer: Start, pause, resume or end the current session
  • Sessions: Review available duration presets and session details
  • History: Inspect saved completions and partial sessions

Data model

TableKey fieldsPurpose
sessionsid (uuid), started_at (timestamptz), ended_at (timestamptz nullable), target_seconds (int), active_seconds (int), status (text)One practice attempt with an explicit lifecycle
session_segmentsid (uuid), session_id (uuid), started_at (timestamptz), ended_at (timestamptz nullable)Active intervals that exclude paused time
duration_presetsid (uuid), label (text), duration_seconds (int)User-approved choices without therapeutic promises

Local-only session history is sufficient for a private practice timer. If synchronized accounts are requested, session attempts, segments and personal presets need authenticated ownership with server-side row-level security. Public duration suggestions may be readable separately, but they must not reveal another person’s practice history. Keep the distinction between an active attempt and a finished record intact during any later synchronization.

Native features for the meditation app

Calculate active segments rather than trusting an animation frame count; a paused interval must never become practice time. If licensed guidance is added, keep lock-screen controls and session pause state aligned; the first release may remain a silent timer.

FeatureAndroid (Kotlin)iPhone (SwiftUI)Notes
Timed quiet practiceMonotonic elapsed-time accountingElapsed-time session modelCalculate active segments rather than trusting an animation frame count; a paused interval must never become practice time.
Optional guided background audioMedia3 MediaSession and playback serviceAVAudioSession playback with configured background audioIf licensed guidance is added, keep lock-screen controls and session pause state aligned; the first release may remain a silent timer.
Optional mindful practice exportHealth Connect mindfulness record when supportedHealthKit mindful-session write authorizationRequest a separate opt-in for completed practice records, check platform support, and avoid exporting abandoned or duplicate sessions.

Android notes (Kotlin and Jetpack Compose)

Use a Compose timer face backed by a ViewModel and persisted session segments in Room. Recomposition should only update the display; start, pause and finish events must change the session model exactly once, even if a user taps quickly.

  • For the optional guided-audio version, place playback ownership in a MediaSession service rather than in the timer composable. Handle audio focus loss and headphone removal with a stated pause policy, while the silent timer remains usable without playback permissions.
  • Keep Health Connect export separate from local completion. Check feature availability before offering a mindfulness write, request only the relevant access, and retain an export identifier to prevent the same finished session being written again after retry.
  • On Android hardware, begin three minutes of practice, pause for thirty seconds, and resume with the display locked. Interrupt optional guidance with another audio source. Compare active seconds in History with the actual unpaused intervals, and deny health access to verify that practice still saves locally.

iPhone notes (Swift and SwiftUI)

Represent the timer as a SwiftUI view of a session state machine, not as the source of elapsed time. Save segment boundaries with SwiftData and use scenePhase only to reconcile display state; returning to the foreground should not create a second practice attempt.

  • When optional owned audio is requested, configure AVAudioSession and background playback deliberately. Keep the pause control in the app consistent with remote playback controls, and document whether an interruption pauses the practice clock as well as the recording.
  • Write an HKCategorySample for a completed mindful session only after HealthKit authorization is requested for that purpose. Track the local session’s export state; refusing permission should leave History intact and should not repeatedly force the authorization screen.
  • On an actual iPhone, start a short session, receive an interruption, and finish after resuming. Inspect the active duration and any exported mindful interval. Repeat the finish action after relaunch to check that neither History nor HealthKit receives an extra completion.

Copy-paste prompt

Build this yourself 188 words · Android
Build a meditation app for Android using native screens and a deliberately small first release. The core scope is session durations, pause and resume controls, history and optional completion alerts. Include these destinations: Home, Timer, Sessions, History. Use these persisted entities: sessions, session_segments, duration_presets; retain stable identifiers and explicit relationships rather than maintaining independent screen totals.
Ask me these owner decisions before implementing ambiguous behavior: whether screen-off time counts, how interrupted sessions appear, and whether a manually ended session is marked complete or partial. Do not invent a policy or add an unrequested external integration. Start local-only unless I explicitly choose account storage; if I choose a backend, enforce ownership on the server with row-level security.
Show loading, empty and recoverable error states, plus permission-denied handling wherever a native capability requests access. Keep incomplete input recoverable and distinguish it from saved data. For acceptance, start, pause, resume and finish a session while preserving the actual active duration. Also exercise the invalid-input or denied-permission path and reopen the app to inspect the persisted result. Explain any remaining device-only checks rather than equating a successful build with a passing journey.

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

Acceptance test

  1. Choose a one-minute session, start it, and let approximately ten seconds of active practice pass.
  2. Pause for several seconds and verify the paused interval does not increase active duration.
  3. Resume and finish once; inspect the recorded active seconds and the complete-or-partial label.
  4. Reopen the app and verify History contains one saved attempt with the same timing values.
  5. Deny notification access and rapidly press Finish; the session must still save once without promising an alert.

Lock the phone during a running attempt and reopen it before the target duration ends. The displayed time should follow the chosen screen-off policy, not the number of frames the timer happened to render. Repeat while paused and confirm that the pause contributes no active seconds even if the scheduled completion time passes.

History should distinguish an unused timer from a failed history read; the latter needs retry rather than a false message that no practice exists. Keep an interrupted attempt recoverable until the user resumes or explicitly discards it. If completed sessions can be deleted, define whether their active segments are also removed and recompute descriptive streaks from remaining completions instead of retaining an inaccurate cached achievement.

Frequently asked questions

Must a silent meditation timer request audio or health access?

No. Quiet practice and local history can work without either integration. Guided background playback and a mindful-session export are separate optional additions, each needing its own device checks, configuration and clear user choice.

Will meditation results be presented as treatment?

The app should record practice, not promise a health outcome or provide medical treatment claims. Session history and streaks are descriptive records rather than evidence of a clinical benefit.

How should a force-closed session be counted?

Choose whether it is recoverable, interrupted or partial, then show that label in History. Do not award a full completion simply because the originally scheduled end time passed.

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.