This documentation explains how the Celestial mood tracking app works, written in simple terms to help with future development and understanding.
The app's user interface is built with React and lives in the client/ folder.
client/src/App.tsx- Main app component that handles navigation between pagesclient/src/pages/- Individual pages users can visitclient/src/components/- Reusable UI piecesclient/src/hooks/- Custom functions for common tasksclient/src/lib/- Helper functions and utilities
The server handles data storage and API requests, located in the server/ folder.
server/index.ts- Main server file that starts everythingserver/routes.ts- Defines what happens when users make requestsserver/storage.ts- Handles saving and loading data
shared/schema.ts- Defines what data looks like (types and validation)
When a user clicks something or fills out a form:
- React components handle the interaction
- Forms use
react-hook-formfor validation - Data gets sent to the backend via API calls
The frontend talks to the backend through API endpoints:
GET /api/moods- Gets all mood entriesPOST /api/moods- Saves a new mood entryGET /api/mission-logs- Gets all journal entriesPOST /api/mission-logs- Saves a new journal entryGET /api/analytics- Gets statistics and trends
The backend processes requests and saves/loads data:
- Uses in-memory storage for development (data resets when server restarts)
- Can be configured to use PostgreSQL database for production
- All data operations go through the storage interface
Data flows back to update the user interface:
- Backend fetches data from storage
- Sends JSON response to frontend
- React Query automatically updates the UI
File: client/src/pages/mood-tracker.tsx
How it works:
- User sees planet buttons representing different moods
- Clicking a planet selects that mood
- User sets intensity level (1-10) with a slider
- Optional note can be added
- Form submission sends data to
/api/moods - Backend saves mood with current date and "stardate"
Important parts:
- Planet selector uses CSS hover effects and animations
- Form validation ensures required fields are filled
- Success message appears after saving
File: client/src/pages/mission-log.tsx
How it works:
- User can write text entries or record voice memos
- Voice recording uses browser's microphone API
- Audio gets converted to base64 text for storage
- Entries are saved with timestamps and status
- Users can edit or delete existing entries
Voice Recording Process:
use-voice-recorder.tshook handles microphone access- Records audio using MediaRecorder API
- Converts audio blob to base64 string
- Saves to database along with duration
File: client/src/pages/analytics.tsx
How it works:
- Backend calculates statistics from all mood entries
- Shows mood distribution (which moods are most common)
- Calculates streak (consecutive days with entries)
- Displays average mood and trends
- Charts and progress bars visualize the data
Statistics calculated:
- Total entries and mission logs
- Current streak of consecutive days
- Average mood intensity
- Most common mood (predominant mood)
- Percentage breakdown of all moods
File: client/src/pages/dashboard.tsx
How it works:
- Shows quick stats (streak, total entries, top mood)
- Displays recent mission log entries
- Quick mood entry form for easy logging
- Links to detailed pages
- React Query handles server data (fetching, caching, updates)
- useState for local component state
- No global state management needed
- Tailwind CSS for all styling
- Custom Y2K/cyberpunk theme with pinks, purples, and cyans
- Animated backgrounds and glow effects
- Responsive design for mobile and desktop
users: id, username, password
moods: id, userId, mood, intensity, note, date, stardate
mission_logs: id, userId, title, content, status, entryType, audioData, audioDuration, stardate, createdAt
voice_recordings: id, missionLogId, audioData, duration, createdAt
All endpoints return JSON and follow REST conventions:
- GET requests fetch data
- POST requests create new data
- PUT requests update existing data
- DELETE requests remove data
- Define data structure in
shared/schema.tsfirst - Add storage methods in
server/storage.ts - Create API routes in
server/routes.ts - Build frontend components in
client/src/ - Test with real user interactions
- Keep components small and focused
- Use TypeScript for type safety
- Follow existing naming conventions
- Add comments for complex logic
- Forms: Use
react-hook-formwith Zod validation - API calls: Use React Query with proper error handling
- UI components: Use shadcn/ui components when possible
- Styling: Use Tailwind classes, avoid custom CSS
- Check browser console for errors
- Use React Developer Tools
- Verify API calls in Network tab
- Check if data is loading correctly
- Look at server logs in terminal
- Test API endpoints with curl or Postman
- Verify data is being saved correctly
- Check database connections
- CORS errors: Make sure frontend and backend URLs match
- Data not updating: Check React Query cache invalidation
- Forms not submitting: Verify form validation and error handling
- Styling issues: Check Tailwind classes and responsive breakpoints
- User authentication and accounts
- Data export functionality
- Mood prediction based on patterns
- Social sharing of insights
- Calendar view of mood history
- Reminder notifications
- Add proper database migrations
- Implement caching strategies
- Add comprehensive testing
- Optimize for performance
- Add offline functionality
client/src/App.tsx- App structure and routingserver/routes.ts- All API endpointsshared/schema.ts- Data types and validationclient/src/pages/mood-tracker.tsx- Main mood entry featureserver/storage.ts- Data persistence layer
package.json- Dependencies and scriptstailwind.config.ts- Styling configurationvite.config.ts- Build tool settingstsconfig.json- TypeScript settings
client/src/index.css- Global styles and theme- Individual component styles using Tailwind classes
This documentation should help anyone understand how the Celestial app works and how to continue developing it. The code is organized in a way that makes it easy to add new features while maintaining the existing functionality.