Urgent.News

What's breaking now, across thousands of outlets.

AI

I Built a Voice-First AI Sports Journal (And Why I Didn't Over-Engineer It)

There is a fundamental problem with fitness tracking apps today: friction. After a grueling workout, when your hands are sweaty, your heart rate is 160 BPM, and you are trying to catch your breath, the absolute last thing you want to do is open an app, navigate through five different dropdown menus, search for the exact exercise variant you did, and type out how you felt on a tiny mobile…

Fitness tracking applications often suffer from friction that prevents users from engaging with their workouts. Trainlog, a voice-first sports reflection journal, aims to eliminate this friction by utilizing AI to understand training through natural speech. After a workout, users simply hit record, speak about their session for about 15 seconds, and the app transcribes the audio, extracts structured metrics, and builds a persistent calendar history.

The author found building AI applications in 2024 relatively easy, but ensuring the application is production-ready, respects user privacy, and remains functional despite potential LLM hallucinations posed significant challenges. Instead of incorporating complex AI components like vector databases and multi-agent orchestrators, the author adopted a straightforward stack: React 19, Firebase, Tailwind, Zod, and Groq's Whisper model powered by Llama 3.

The article outlines seven technical lessons learned while building Trainlog without over-engineering it. Here are the key points:

1. Voice-based user interfaces (UI) are effective, but they require safeguards against noise and errors. Using the browser-native MediaRecorder API to capture audio, the app utilizes Vercel Serverless Functions to process audio through Groq's Whisper model. However, raw transcription may produce errors, hence the need for a human-in-the-loop approach where users can edit the transcription before analyzing it.

2. A heavy agent framework is not necessary for structuring data. Trainlog relies on strict schema validation using TypeScript interfaces and Zod schema to guide Llama 3 in outputting raw JSON matching the specified format. This ensures accuracy and prevents crashes when the AI hallucinates data.

3. Progressive Web Apps (PWAs) offer an excellent shortcut for developers seeking a native app experience on iOS and Android without rewriting the codebase in React Native or Swift. By implementing a PWA, Trainlog achieves full-screen installation, offline capabilities, and mobile-first UI patterns, providing an immersive user experience similar to a native app.

4. Web push notifications have become viable for engagement. Trainlog incorporates Firebase Cloud Messaging (FCM) and the Web Push API to send daily reminders to users, encouraging them to log their workouts. The implementation involves requesting notification permissions during onboarding, securely storing the FCM token in Firestore, and scheduling regular pings for users who haven't logged a session.

5. Rate limiting is crucial when exposing endpoints that call LLMs. To prevent abuse and avoid API bills from skyrocketing, the author implemented a sliding window rate limiter using Upstash Redis. The server responds with a 429 Too Many Requests error if an IP or User ID exceeds a specified limit, providing a simple yet effective solution to potential security threats.

6. Gamification should focus on milestones and exploration rather than strict consistency. Rather than relying on streaks that can cause anxiety when users break them, Trainlog includes milestones and exploration-based achievements like emotional resilience (logging after a bad day) and trying new activities. This approach keeps users engaged without causing negative psychological impacts.

7. Privacy is a fundamental feature, not an afterthought. Given the sensitive nature of health data, sleep metrics, and personal reflections, Trainlog prioritizes data privacy from the start. The app utilizes Firebase and Firestore to securely store user data while ensuring compliance with relevant privacy regulations.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

More from Friday 28 August →