PulsePlay AI - Project Story
Inspiration
We've all been there—sitting at our desk, headphones on, trying to find the perfect focus music. You spend 20 minutes scrolling through playlists, but nothing quite matches your current energy. You're coding fast, but your lo-fi beats are too slow. You're deep in thought, but your energetic EDM is too distracting.
What if your music could adapt to you, instead of you adapting to your music?
PulsePlay AI was born from a simple observation: our work rhythm tells a story. Fast typing during a coding sprint. Thoughtful pauses during design work. Rapid mouse movements during research. Each pattern reveals something about our focus state—and deserves music that matches.
We wanted to create something more than just another music player. We wanted to build an intelligent companion that listens to how you work and responds in real-time, turning your keyboard into an instrument and your workflow into a symphony.
What it does
PulsePlay AI transforms your typing rhythm and mouse movements into personalized, adaptive focus music that evolves with your work patterns.
Core Features
🎹 Real-Time Audio Synthesis
Pure Web Audio API synthesis generates music on-the-fly—no pre-recorded samples, no downloads. Every note is synthesized in your browser, responding instantly to your input.
🎯 Intelligent Rhythm Detection
Advanced algorithms track your keyboard and mouse activity, calculating BPM, tempo variance, and activity patterns. The system identifies whether you're in a steady flow state, experiencing bursts of productivity, or taking contemplative pauses.
🎼 MIDI-Based Piano Songs
Choose from four beautiful piano pieces that adapt to your rhythm:
- A Thousand Years (Christina Perri) - 75 BPM, calm and romantic
- Kiss The Rain (Yiruma) - 58 BPM, gentle and contemplative
- River Flows In You (Yiruma) - 65 BPM, smooth and flowing
- Gurenge (LiSA) - 95 BPM, energetic anime theme
🧠 AI-Powered Mood Recommendations
After just 1 minute of activity, Gemini AI analyzes your focus patterns and suggests the perfect piano song for your current work state. Get personalized insights like: "Your steady rhythm suggests deep focus—try 'A Thousand Years' for sustained concentration."
🎨 Live Waveform Visualization
Watch your typing come to life with a 60fps Canvas animation that pulses, waves, and responds to every keystroke. The visualization adapts to your chosen piano song and activity intensity.
🎵 Adaptive Instruments
Select from Piano, Flute, Xylophone, or Kalimba. Each instrument responds dynamically to your typing rhythm, creating a unique auditory experience.
💾 Session Tracking & Analytics
Every focus session is automatically saved with detailed metrics: duration, keystrokes, clicks, mouse movements, scrolls, and detected rhythm patterns. Review your productivity history with 90-day data retention.
♿ Accessibility-First Design
WCAG 2.1 AA compliant with sensory-friendly options, keyboard navigation, and a clean interface that works for everyone.
How we built it
Architecture Overview
Frontend (React 18.3 + TypeScript 5.5 + Vite)
- Web Audio API: Pure synthesis with OscillatorNode, GainNode, and BiquadFilterNode for real-time audio generation
- MIDI Integration: @tonejs/midi library parses piano MIDI files and adapts playback to user typing rhythm
- Canvas API: Custom waveform renderer with 60fps animation loop synchronized to audio context
- Auth0 React SDK: Secure OAuth2 PKCE flow with JWT token management
- React Context: Theme system (light/dark) with localStorage persistence
Backend (Node.js + Express 5 + TypeScript 5.7)
- MongoDB Atlas: Mongoose ODM with three core models (FocusSession, WeeklySummary, AIMoodRecommendation)
- Gemini AI API: Intelligent mood analysis and personalized recommendations based on session patterns
- Auth0 JWT Middleware: Route protection with express-oauth2-jwt-bearer
- Rate Limiting: express-rate-limit prevents API abuse (100 requests/15 minutes)
- Structured Logging: Pino logger with request correlation IDs
Key Technical Innovations
Rhythm Detection Algorithm
Custom algorithm calculates BPM by analyzing time deltas between keystrokes. We identify patterns:- Steady rhythms: Low variance = sustained focus → "A Thousand Years"
- Burst patterns: High variance = rapid coding → "Gurenge"
- Pause-heavy: Longer gaps = contemplation → "Kiss The Rain"
- Smooth flow: Medium consistency = creative flow → "River Flows In You"
MIDI-Adaptive Playback
Piano melodies from MIDI files are synchronized to user typing. Each keystroke triggers the next note in the melody, creating a responsive musical experience where you become the performer.AI Mood Mapping
Gemini AI receives structured session data (BPM, variance, pause ratio, activity distribution) and returns contextual insights. The AI understands the musical character of each piano song and recommends based on work patterns.Audio Synthesis Pipeline
User Input → Rhythm Detection → BPM Calculation → MIDI Note Selection → Web Audio Synthesis → Visualization Update → Session Analytics
Technology Stack
- Frontend: React 18.3, TypeScript 5.5, Vite 5.4, TailwindCSS 3.4
- Backend: Express 5.1, TypeScript 5.7, MongoDB Atlas, Mongoose 8.19
- Audio: Web Audio API, @tonejs/midi 2.0
- Authentication: Auth0 (OAuth2 PKCE)
- AI: Google Gemini 1.5 Flash
- Deployment: Docker multi-stage builds, nginx reverse proxy
- Tools: Biome (linting), Vitest (testing), Pino (logging)
Challenges we ran into
1. Web Audio API Learning Curve
The Web Audio API is powerful but complex. Understanding the node graph architecture (AudioContext → OscillatorNode → GainNode → BiquadFilterNode → Destination) took significant experimentation. We learned to:
- Properly dispose of audio nodes to prevent memory leaks
- Synchronize multiple oscillators for richer sounds
- Handle browser autoplay policies (requires user interaction)
2. MIDI Timing Synchronization
Making MIDI melodies responsive to unpredictable typing patterns was challenging. Piano songs have specific timing, but users don't type at consistent intervals. Our solution:
- Extract note sequences from MIDI files
- Create a "next note" queue system
- Trigger notes on keystroke events (not time-based)
- Maintain musical coherence despite irregular input
3. Rhythm Detection Accuracy
Early versions struggled with false positives—detecting "steady rhythm" during random typing. We iterated through multiple approaches:
- v1: Simple BPM calculation (too noisy)
- v2: Moving average with outlier rejection (better, but still flawed)
- v3: Pattern analysis with variance thresholds and pause detection (current solution)
4. MongoDB Atlas Connection Issues
Deployment challenges with MongoDB Atlas connection pooling and timeouts. Learned to:
- Configure proper connection string parameters (
retryWrites=true&w=majority) - Implement connection retry logic with exponential backoff
- Set up proper indexes for query performance
- Handle MongoDB Atlas IP whitelist in Docker environments
5. TypeScript Type Safety Across Stack
Maintaining type safety between frontend and backend required discipline:
- Created shared type definitions (
Mood,FocusSession,AIMoodRecommendation) - Used strict TypeScript config (
strict: true,noImplicitAny: true) - Encountered type conflicts during mood system refactoring (removed 3 moods, kept 4)
- Fixed with systematic type updates across 8 backend files and 2 frontend files
6. AI Insights Tuning
Initial AI recommendations were too generic. We improved by:
- Adding musical context to prompts (BPM, key, song character)
- Reducing insight threshold from 10 minutes to 1 minute for faster feedback
- Structuring Gemini prompts with specific mood descriptions
- Providing session pattern examples for better AI understanding
7. Docker Multi-Stage Builds
Creating efficient Docker images while maintaining separate dev/prod environments required:
- Multi-stage Dockerfile (frontend builder → backend builder → production nginx)
- Environment variable injection at runtime (not build time)
- Proper .dockerignore configuration (reduced image size by 60%)
- nginx reverse proxy configuration for API routing
Accomplishments that we're proud of
Technical Achievements
✨ Zero-Latency Audio Synthesis
We achieved real-time audio generation with <10ms latency using pure Web Audio API. Every keystroke triggers immediate sound with no noticeable delay.
🎼 MIDI-Adaptive Algorithm
Built a unique system that makes piano melodies responsive to typing. Users aren't just listening to music—they're performing it with their keyboard.
🧠 1-Minute AI Insights
Reduced AI analysis threshold from 10 minutes to just 1 minute. Users get intelligent recommendations almost immediately after starting a session.
🎨 60fps Waveform Visualization
Created a smooth, responsive Canvas animation that renders at full 60fps even during intense typing bursts.
🐳 Production-Ready Docker Setup
Built a complete containerized deployment with multi-stage builds, nginx reverse proxy, and MongoDB Atlas integration. Deploy anywhere with docker-compose up.
User Experience Wins
♿ Accessibility-First Design
WCAG 2.1 AA compliant from day one. Keyboard navigation, sensory-friendly options, and clear visual hierarchy.
🌓 Light/Dark Theme System
Full theme support with localStorage persistence. Switch seamlessly without losing your preference.
📊 Rich Session Analytics
Users can review their productivity patterns with detailed metrics: rhythm detection, mood history, and AI recommendations.
🔒 Enterprise-Grade Security
Auth0 OAuth2 PKCE flow with JWT tokens. No passwords stored, secure by design.
Development Process
📚 Comprehensive Documentation
Created 11 documentation files covering user guides, developer docs, API reference, architecture, and deployment.
🧪 Type-Safe Codebase
Achieved 100% TypeScript coverage with strict type checking across frontend and backend.
🔄 Systematic Refactoring
Successfully refactored entire mood system (7 moods → 4 piano songs) across 10+ files with zero runtime errors.
What we learned
Technical Insights
Web Audio API is Powerful but Opinionated
The node graph architecture forces you to think about audio signal flow. Once you understand it, you can create incredibly rich sounds with minimal code.Real-Time Systems Need Careful Resource Management
Audio synthesis, Canvas rendering, and rhythm detection all run in tight loops. We learned to userequestAnimationFrame, debouncing, and proper cleanup to avoid memory leaks.AI Prompts Are Code
Treat AI prompts like any other code—version them, test them, and iterate. Adding musical context and specific examples dramatically improved Gemini's recommendations.TypeScript Strict Mode Saves Time
Strict TypeScript caught dozens of potential runtime errors during refactoring. The upfront investment in types paid massive dividends.MongoDB Indexes Matter
Adding proper indexes reduced query times from 500ms to 50ms. Always index fields used infindOne()andfind()queries.
Development Practices
Document as You Build
Writing documentation alongside code (not after) kept our docs accurate and comprehensive. Created 11 docs totaling 30KB.Small, Focused Commits
Breaking changes into small, testable units made debugging easier. "Add rhythm detection" is better than "Implement audio system."User Feedback Early
Showing the prototype early revealed that users cared more about music quality than fancy visualizations. We pivoted focus accordingly.Docker Simplifies Deployment
Investing time in proper Docker setup eliminated "works on my machine" issues and made deployment trivial.
Product Insights
Personalization Creates Engagement
Users loved seeing AI recommendations based on their work patterns. Generic advice would've been ignored.Simplicity Beats Features
We removed 3 abstract moods (deep-focus, melodic-flow, jazz-harmony) in favor of 4 real piano songs. Users preferred recognizable music over generic concepts.Accessibility is a Feature, Not an Afterthought
Building WCAG compliance from the start was easier than retrofitting. Plus, accessible design benefits everyone.
What's next for PulsePlay
Near-Term Features (v1.3)
🎵 Expanded Music Library
- Add 10+ more piano classics (Moonlight Sonata, Clair de Lune, Comptine d'un autre été)
- User-requested songs (voting system in session history)
- Genre expansion: Classical, Lo-fi, Ambient
🎸 Custom Instrument Packs
- Guitar melodies for rock/indie vibes
- Synth packs for electronic music fans
- User-uploadable MIDI files (play your own songs)
📈 Advanced Analytics Dashboard
- Weekly focus reports with insights
- Productivity heatmaps (time of day patterns)
- Mood effectiveness tracking (which songs help you focus most?)
🤝 Team Features
- Shared focus sessions (co-working mode)
- Team analytics (how's your team's rhythm?)
- Session sharing (send your focus music to a friend)
Mid-Term Goals (v2.0)
🧠 Smarter AI Recommendations
- Multi-session learning (AI remembers your preferences)
- Context-aware suggestions (time of day, day of week)
- Proactive mood switching (AI detects focus drop and suggests song change)
🎼 Dynamic Composition
- AI-generated melodies based on your typing patterns
- Unique music for each user (no two sessions sound the same)
- Real-time harmony generation
🌍 Cross-Platform Support
- VS Code extension (focus music in your IDE)
- Desktop app (Electron) for system-wide activity tracking
- Mobile app (ambient focus music on the go)
☁️ Cloud Sync & Backup
- Sync session history across devices
- Export focus reports (PDF, CSV)
- API access for third-party integrations
Long-Term Vision (v3.0+)
🎯 Focus State Prediction
- Machine learning model predicts optimal focus times
- Recommends break times based on activity patterns
- Integrates with calendar (suggest focus blocks)
🧘 Wellness Integration
- Breathing exercises between sessions
- Eye strain reminders with ambient audio cues
- Pomodoro timer integration
🔌 Third-Party Integrations
- Spotify/Apple Music sync (analyze your music taste)
- Notion/Obsidian integration (link sessions to notes)
- RescueTime/Toggl integration (unified productivity tracking)
🌐 Community Features
- Public mood boards (discover what others are listening to)
- Focus challenges (compete with friends)
- Music recommendations from the community
Join the Rhythm
PulsePlay AI is more than a focus music generator—it's a productivity companion that understands your work rhythm and responds with music that helps you do your best work.
We're excited to see how developers, writers, designers, and knowledge workers worldwide use PulsePlay to transform their workflow into a symphony.
Try it today → GitHub Repository
Built with ❤️ by developers who believe that great music shouldn't interrupt your flow—it should enhance it.
Version: 1.2.2
License: MIT
Status: Open Source & Production Ready
Built With
- auth0
- biomejs
- react
- vite
Log in or sign up for Devpost to join the conversation.