Engineering Thesis Project — University of Rzeszów, Faculty of Exact and Technical Sciences
- MoodTracker
- AI-Powered Mobile App for Mood Monitoring & Personalized Wellness Recommendations
- Table of Contents
- About the Project
- Key Features
- System Architecture
- Tech Stack
- Machine Learning Pipeline
- Recommendation Algorithm
- Database Design
- Screenshots
- Project Structure
- Getting Started
- Testing
- Challenges & Solutions
- Future Roadmap
- Project Status & Academic Context
MoodTracker is a full-stack mobile application designed to monitor and improve mental well-being through systematic emotional state tracking and advanced machine learning analysis. Unlike existing solutions on the market (Daylio, Moodfit) which offer only basic mood logging or static exercise sets, MoodTracker goes further by providing:
- Automated emotion classification from free-text journal entries using BiLSTM neural networks
- Predictive mood analysis leveraging LSTM time-series forecasting
- Intelligent exercise recommendations via a Content-Based Filtering algorithm with 5-dimensional scoring
This project was developed as an engineering thesis: "Mobile Application for Mood Monitoring and Recommending Relaxation Exercises Using an LSTM Network and Content-Based Filtering Algorithm" at the University of Rzeszów.
The research-backed approach draws on published studies (Boghrati et al. 2023, Schueller et al. 2021, Toussaint et al. 2021) confirming that emotion tracking applications can sustain positive moods, and that users expect personalized, actionable recommendations — not just retrospective data visualization.
| Feature | Description |
|---|---|
| 🎭 Smart Mood Logging | 5-point mood scale with emotion tags, influence factors, and free-text descriptions |
| 🤖 AI Emotion Analysis | BiLSTM model automatically detects top 3 emotions from journal text with confidence scores |
| 📈 Mood Prediction | LSTM network predicts tomorrow's mood based on 14-day history with trend analysis |
| 🎯 Personalized Recommendations | Content-Based Filtering algorithm scores exercises across 5 dimensions (emotion match, location, affinity, rating, popularity) |
| 🏋️ Training Sessions | Create, schedule, execute, and rate guided relaxation sessions with timer/rep tracking |
| 📓 Personal Journal | Dedicated diary module with emotion analysis integration |
| 🔔 Smart Notifications | 6 types of scheduled notifications (mood care, predictions, session reminders, retry logic) |
| 🌙 Dark Mode | Full Material Design 3 light/dark theme support |
| 🛡️ Admin Panel | Web dashboard for exercise management, algorithm weight tuning, and system analytics |
The system follows a microservices architecture with 5 independent layers communicating via well-defined REST API interfaces:
| Layer | Technology | Port | Responsibility |
|---|---|---|---|
| Presentation | React Native (Expo SDK 54) + React (Vite) | — / 3001 | Mobile app & Admin panel |
| Application | Spring Boot 3.5.5 (Java 21) | 8080 | Central REST API, business logic, JWT auth, orchestration |
| Machine Learning | Flask + TensorFlow 2.10 (Python 3.10) | 5000 | BiLSTM emotion classification & LSTM mood prediction |
| Database | PostgreSQL 17 | 5432 | Persistent storage with Flyway migrations, PL/pgSQL triggers |
| Cache | Redis 7 | 6379 | ML inference caching (24h TTL), session data, recommendation weights |
- Separated ML microservice — TensorFlow's Python-specific ecosystem is incompatible with the JVM; independent scaling of compute-heavy inference operations
- Stateless JWT authentication — BCrypt password hashing, token blacklist in Redis, role-based access control (USER/ADMIN)
- Docker Network isolation — Backend-to-ML communication happens within a private Docker network; ML API port is not exposed to the host in production
- Multi-layer caching — Redis DB 1 with prefix
ml_api_for ML results, default DB withspring_cache_for backend data (recommendation weights, etc.)
| Component | Technology |
|---|---|
| Framework | Spring Boot 3.5.5, Spring WebMVC, Spring Security |
| ORM | Spring Data JPA / Hibernate with JPA Specifications |
| Auth | JWT (JJWT library), BCrypt hashing |
| Database | PostgreSQL 17 with Flyway migrations |
| Cache | Spring Data Redis (Lettuce client) |
| Code Generation | MapStruct (DTO ↔ Entity mapping), Lombok |
| API Documentation | OpenAPI / Swagger |
| Build | Maven |
| Component | Technology |
|---|---|
| Framework | Flask 2.3 + Gunicorn (production WSGI) |
| Deep Learning | TensorFlow 2.10, Keras |
| Data Processing | NumPy 1.23, Pickle (tokenizer serialization) |
| Caching | Flask-Caching with Redis backend |
| Component | Technology |
|---|---|
| Framework | React Native with Expo SDK 54 |
| Language | TypeScript |
| UI Library | React Native Paper (Material Design 3) |
| Navigation | Expo Router 6.0 (file-based routing) |
| HTTP Client | Axios with JWT interceptors |
| Secure Storage | expo-secure-store (encrypted credentials) |
| Notifications | expo-notifications (push + local scheduling) |
| Component | Technology |
|---|---|
| Framework | React (Vite) |
| UI | Material-UI |
| Language | TypeScript |
| Component | Technology |
|---|---|
| Containerization | Docker & Docker Compose |
| Web Server | Nginx (Admin Panel) |
| Version Control | Git + GitHub |
| Project Management | Jira |
A Bidirectional LSTM model trained on the dair-ai/emotion dataset (~20,000 samples) to classify text into 6 emotion categories: Joy, Sadness, Anger, Fear, Love, Excitement.
Input Text → TextVectorization (100 tokens) → Embedding (128d) → SpatialDropout1D (0.2)
→ Bidirectional LSTM (192 units, L2 reg.) → Dense (64, ReLU) → Dropout (0.4)
→ Softmax (6 classes) → Top 3 emotions with confidence scores
Architecture highlights:
- Bidirectional processing captures both forward and backward context (384-dimensional hidden states)
- Dual regularization: L2 weight penalty (0.001) + Dropout (0.3 recurrent, 0.4 dense)
- 70%+ accuracy on 6-class classification task
- Custom model serialization: HDF5 for BiLSTM weights + Pickle for TextVectorization layer (due to TF serialization limitations)
A regression LSTM model that predicts tomorrow's mood from the last 14 days of entries.
14-day mood sequence → Min-Max normalization [0,1] → LSTM (32 units)
→ Dropout (0.2) → Dense (16, ReLU) → Dropout (0.2)
→ Sigmoid → Denormalization → Predicted mood (1-5 scale)
Output includes: predicted value, confidence score, and trend direction (improving/declining/stable).
- Models are eager-loaded at Flask startup using
app.extensionsmechanism - Each prediction function is compiled to a TensorFlow graph via
@tf.functionfor optimized execution - Results are cached in Redis (24h TTL) — identical queries served in <1ms vs. 50–200ms for full inference
- Single-worker Gunicorn configuration ensures TensorFlow thread safety and prevents model duplication in RAM
The exercise recommendation engine uses Content-Based Filtering with a 5-dimensional weighted scoring system:
| Dimension | Weight | Description |
|---|---|---|
| M₁ — Emotion Match | 0.35 | Maps user's detected emotions to exercise tags via emotion_tag_mapping table. Aggregates relevance scores + coverage bonus (max 20%) |
| M₂ — Affinity Score | 0.15 | User's exercise history: completion rate (60%) + log frequency bonus (20%) + recency bonus (20%) |
| M₃ — Rating Score | 0.25 | User's effectiveness/rating normalized to 0–1 (neutral 0.6 for unseen exercises) |
| M₄ — Location Match | 0.15 | Soft scoring (0–1) based on user's current location vs. exercise location tags (home, office, outdoors, etc.) |
| M₅ — Popularity Score | 0.10 | Global logarithmic completion count (base 0.3 for new exercises, ~0.7 at 100 completions) |
Key implementation details:
- No hard filtering — every exercise receives a score, ensuring diversity
- Weights are dynamically configurable via admin panel (stored in DB, cached with
@Cacheable, instantly invalidated via@CacheEvict) - Emotion-free fallback mode: 50% affinity, 20% location, 20% rating, 10% popularity
- Affinity data is automatically maintained by PostgreSQL triggers (PL/pgSQL) after exercise completions/ratings
PostgreSQL schema normalized to 3NF with 28+ tables organized in 4 functional modules:
| Module | Key Tables | Purpose |
|---|---|---|
| User Profile | users, user_preferences, user_statistics |
Auth, personalization, analytics |
| System Dictionaries | moods, emotions, mood_influences, tags |
Seeded via Flyway migrations |
| Mood Analytics | mood_entries, journal_entries, mood_predictions, association tables |
Mood/emotion tracking with ML predictions |
| Training Content | exercises, training_sessions, session_exercises, session_history, exercise_ratings |
Exercise library, session management, user feedback |
| Infrastructure | notification_queue, recommendation_weights, user_exercise_affinity |
Async notifications, algorithm config, auto-updated affinity |
Notable design patterns:
- Soft delete pattern (
deleted_attimestamps) for data preservation - PL/pgSQL triggers for automatic affinity score updates
- Native ENUM types for type safety (
emotion_category,session_status) - B-tree composite indexes on frequently queried columns (
user_idin transactional tables)
🏋️ Training Sessions
| Session List | Exercise Filters | Session Details | Exercise Details |
|---|---|---|---|
| Active Session | Session Screen | Exercise Timer | Session History |
|---|---|---|---|
🎯 Recommendations & Ratings
| Recommendation Form | Recommended Exercises | Exercise Rating | Rating Overview |
|---|---|---|---|
mood-tracking-app/
├── MoodTrackerPaper/ # 📱 Mobile App (React Native / Expo SDK 54 / TypeScript)
│ ├── app/ # Expo Router file-based routes
│ ├── components/ # Reusable UI components
│ ├── src/
│ │ ├── hooks/ # Custom hooks (useMoodEntries, useActiveSession, etc.)
│ │ ├── contexts/ # AuthProvider, ThemeProvider, NotificationProvider
│ │ └── services/ # API client with Axios interceptors
│ └── assets/ # Static resources
│
├── mood-tracker-backend/ # ⚙️ Backend API (Spring Boot 3.5.5 / Java 21)
│ └── src/main/java/
│ └── com/moodtracker/
│ ├── controller/ # REST controllers (12+ endpoints)
│ ├── service/ # Business logic & recommendation engine
│ ├── entity/ # JPA entities with complex relationships
│ ├── repository/ # Spring Data JPA repositories
│ ├── specification/ # Dynamic query builders (Criteria API)
│ ├── dto/ # Request/Response DTOs with validation
│ ├── mapper/ # MapStruct entity ↔ DTO converters
│ ├── security/ # JWT filter chain, BCrypt config
│ ├── scheduler/ # 6 background jobs (notifications, cleanup)
│ ├── config/ # Spring Security, Redis, OpenAPI configs
│ └── exception/ # Global exception handler hierarchy
│
├── ml-api/ # 🤖 ML Service (Flask / TensorFlow 2.10)
│ ├── app/
│ │ ├── core/ # Redis cache, Flask app factory
│ │ ├── models/ # Model loaders (eager loading at startup)
│ │ ├── routes/ # REST endpoints (/analyze, /predict-mood)
│ │ └── services/ # Preprocessing, inference, postprocessing
│ ├── *.h5 # Trained model weights (BiLSTM + LSTM)
│ └── vectorization.pkl # Serialized tokenizer
│
├── admin-panel/ # 🖥️ Admin Panel (React / Vite / Material-UI)
│
├── tools/ # 🔧 ML Training Scripts
│ ├── LSTM_Emotion_analyze/ # BiLSTM emotion classifier training
│ └── LSTM_Mood_analyze/ # LSTM mood predictor training
│
├── docs/media/ # 📸 Architecture diagrams & screenshots
├── prod-docs/ # 📄 Engineering thesis (LaTeX source)
└── docker-compose.yml # 🐳 Full stack orchestration (6 services)
- Docker & Docker Compose (for backend, ML API, database, cache, admin panel)
- Node.js 18+ & npm (for mobile app development)
- Android Emulator or physical device with Expo Go
git clone https://github.com/g00staw/mood-tracking-app.git
cd mood-tracking-app
docker-compose up --buildThis starts 6 containers:
| Service | URL / Port | Notes |
|---|---|---|
| PostgreSQL | localhost:5432 |
Auto-migrated schema via Flyway |
| Redis | localhost:6379 |
Persistent append-only file |
| Spring Boot API | http://localhost:8080 |
With Actuator health checks |
| Flask ML API | http://localhost:5000 |
Models loaded at startup (~10s) |
| Admin Panel | http://localhost:3001 |
Served via Nginx |
| Redis Commander | http://localhost:8081 |
GUI for Redis inspection |
cd MoodTrackerPaper
npm install
npx expo startScan the QR code with Expo Go (Android/iOS) or press a to launch on an Android emulator.
Drag and drop the provided
.apkfile onto your Android Emulator for instant setup. The app is pre-configured to connect to backend services via the emulator's network loopback (10.0.2.2).
67 automated tests (100% pass rate) covering controllers and services:
| Test Class | Tests | Time |
|---|---|---|
MoodEntryControllerTest |
9 | 5.3s |
MoodStatisticsControllerTest |
3 | 1.6s |
AuthServiceTest |
13 | 0.4s |
EmotionAnalysisServiceTest |
6 | 0.2s |
MoodEntryServiceTest |
8 | 0.3s |
MoodStatisticsServiceTest |
8 | 0.1s |
NotificationServiceTest |
10 | 0.2s |
TrainingSessionServiceTest |
10 | 0.3s |
| Total | 67 | 8.5s |
Test architecture:
- Controller tests —
@WebMvcTestwith MockMvc for HTTP endpoint validation, request validation, and auth checks - Service tests — Unit tests with Mockito mocks for isolated business logic verification
- Manual + functional testing — Comprehensive E2E testing by non-technical users with no critical issues reported
cd mood-tracker-backend
./mvnw test| Challenge | Solution |
|---|---|
TensorFlow serialization — TextVectorization layer can't be saved in HDF5 |
Hybrid approach: BiLSTM weights in .h5 + tokenizer in .pkl via Pickle, reconstructed programmatically at load time |
| TensorFlow thread safety — Multi-worker Gunicorn crashes with TF models | Single-worker config + Redis caching to compensate for reduced concurrency |
| Emotion dataset selection — GoEmotions (28 classes) had severe class imbalance | Switched to dair-ai/emotion (6 balanced classes), improving accuracy and model simplicity |
| Dynamic query explosion — Combinatorial filter methods in repositories | JPA Specification pattern with CriteriaBuilder for composable, runtime-built queries |
| React Native re-render storms — Filter changes causing cascading re-renders | useRef for filter state (no re-render trigger) + useCallback memoization for fetch functions |
| UI framework breaking change — Expo SDK 54 broke Gluestack UI | Migrated to React Native Paper (Material Design 3) — gained stability and theme consistency |
- LLM Integration — Replace LSTM models with BERT/GPT-based architectures for deeper semantic analysis
- AI Chatbot — CBT-based virtual assistant for 24/7 emotional support
- Wearable Integration — Connect with Apple Health / Google Fit / Samsung Health for physiological data (heart rate, stress levels)
- Web Application — Cross-platform web version for broader accessibility
- Educational Content — Mental health articles and evidence-based wellness guides
- Multimedia Exercises — Rich exercise instructions with video and audio guidance
This project was developed as my Engineering Thesis at University of Rzeszów. The project was successfully defended in February, 2026.
The source code is shared here for portfolio purposes to demonstrate my technical skills and problem-solving approach.