Skip to content

Happiffy/Happify-FE

Repository files navigation

🌱 Happify-Frontend β€” Web Client

Detect Early. Support Meaningfully. Grow for Life.

Framework Language Build Tool Styling Auth Realtime License Hackathon


The web client of Happify β€” an AI-powered mental wellness platform that helps people track their mood, journal safely with AI-assisted reflection, connect anonymously with a caring community, and reach real professional support when it matters most.

🌐 Frontend Β· ☁️ Backend Β· 🧠 AI Β· πŸ“± Mobile Β· πŸ”Œ IoT


πŸ“Œ Overview

Happify-Frontend is the primary web surface of the Happify ecosystem. It's where a person signs up, tells the app what kind of support they're looking for, checks in with their mood, writes a private journal entry that gets an AI-generated reflection, browses an anonymous community feed, and β€” when it matters β€” reaches a real, verified psychologist through a live chat.

Happify-Frontend's role in the ecosystem: "The front door β€” the calm, encouraging surface where every wellbeing signal a user shares gets captured, visualized, and, when it matters, routed to a human."

The frontend never talks to the AI layer directly. Every request β€” mood entries, journals, community posts, referrals, chat messages β€” flows through Happify Backend, which handles auth verification, persistence, AI orchestration, and real-time fan-out over WebSockets.

Framework React 19 + Vite 8
Language TypeScript ~6.0
Styling Tailwind CSS v4 + a Duolingo-inspired "playful but safe" design system
Auth Firebase Authentication (Email/Password + Google)
Realtime Native WebSocket for community, care, and chat channels
Charts / Maps Recharts (mood trend, risk summary) Β· MapLibre GL (anonymous heatmap)

🌐 Happify Ecosystem

Happify-Frontend is the user-facing dashboard of the platform β€” every wellbeing signal a person shares here flows through the backend, gets enriched by the AI layer, and can surface again on mobile or through the companion IoT device.

Repository Role Link
🌐 Happify-FE Web dashboard β€” mood, journal, community, care (this repo) Happiffy/Happify-FE
☁️ Happify-BE Node.js API, PostgreSQL, Firebase, WebSocket hub, safety workflows Happiffy/Happify-BE
🧠 Happify-AI FastAPI service β€” journal reflection, risk detection, voice processing Happiffy/Happify-AI
πŸ“± Happify-Mobile Flutter app for mood tracking, journaling, and care access on the go Happiffy/Happify-Mobile
πŸ”Œ Happify-IOT Optional companion-device integration for opt-in wellbeing support Happiffy/Happify-IOT

System architecture:

graph TD
    A["🌐 Happify-Frontend (this repo)"] -->|REST + WebSocket| B["☁️ Happify-BE"]
    M["πŸ“± Happify-Mobile"] -->|REST + WebSocket| B
    B --> C[("πŸ—„οΈ PostgreSQL")]
    B --> D["πŸ”₯ Firebase Auth"]
    B --> E["🧠 Happify-AI"]
    E -->|risk score + reflection| B
    B --> F["πŸ”Œ Happify-IOT (optional)"]

    style A fill:#58CC02,color:#fff,stroke:#46A302
    style B fill:#1CB0F6,color:#fff,stroke:#168CC7
    style E fill:#CE82FF,color:#fff,stroke:#A760D2
Loading

Principles this frontend is built around:

  • Privacy by design β€” Community posts show an alias, not an identity; the heatmap only ever renders coarse regions built from at least three anonymous contributions.
  • Safety first β€” The AI companion supports, it does not diagnose. Referrals and care chat are an explicit, human-reviewed escalation path.
  • Human support matters β€” A user can request a professional referral anytime; a verified psychologist can accept it and open a live chat.
  • Accessible by default β€” Responsive layouts, with accessibility and tone preferences captured during onboarding.
  • Secure operations β€” Firebase ID tokens are attached per request and auto-refreshed; no credentials are ever hard-coded or committed.

✨ Features

  • πŸ” Authentication β€” Firebase email/password and Google sign-in, synced into a Happify backend session via POST /auth/verify.
  • 🧭 Guided Onboarding β€” A 4-step questionnaire capturing the user's goal, mood triggers, preferred companion tone, and crisis coping preference.
  • πŸ“Š Wellbeing Dashboard β€” Totals at a glance, a mood-intensity trend chart, and a journal risk-level breakdown.
  • πŸ““ Rich-Text Journaling β€” A Tiptap editor for daily reflections with optional images and AI-generated reflections/risk levels.
  • πŸ«‚ Anonymous Community β€” Alias-based posts, image attachments, support reactions, and threaded replies β€” all live via WebSocket.
  • πŸ—ΊοΈ Anonymous Mood Heatmap β€” A MapLibre GL map of k-anonymous regional mood blocks with a custom date-range filter.
  • 🀝 Referrals & Care Chat β€” Users request professional support; psychologists review, accept, and land in a live 1:1 chat.
  • πŸ’¬ Real-Time Chat β€” Typing indicators, read receipts, presence, optimistic sends, and image attachments over WebSocket.
  • πŸ§‘β€βš•οΈ Psychologist Role β€” A dedicated role with scoped navigation and a certificate/license verification flow.
  • πŸ‘€ Profile Management β€” Display name and password updates, including linking a password onto a Google-only account.
  • πŸ“± Responsive, Playful UI β€” A warm green/blue gradient, rounded "duo" cards, and Phosphor/Fluent-emoji iconography throughout.

πŸ› οΈ Tech Stack

Layer Technology Purpose
Framework React 19.2 Component-driven UI
Build Tool Vite 8 + @vitejs/plugin-react Dev server, HMR, chunked production bundling
Language TypeScript ~6.0 Type-safe components, API contracts, hooks
Routing React Router 7 Client-side routing, nested dashboard sections, protected routes
Styling Tailwind CSS v4 (@tailwindcss/vite) Utility-first styling, driven from src/index.css
Component System shadcn/ui (base-nova style) Reusable UI primitives under @/components/ui
HTTP Client Axios Typed API calls with auth interceptors
Authentication Firebase Authentication Email/password + Google OAuth, ID-token issuance
Realtime Native WebSocket API Community, care, and per-session chat channels
Charts Recharts Mood intensity trend, risk-level donut chart
Maps MapLibre GL + @mapcn registry Anonymous heatmap rendering
Rich Text Tiptap Journal and community post editor
Animation GSAP 3 (ScrollTrigger) Landing page scroll-triggered reveals
Icons Phosphor Icons + Iconify (fluent-emoji-flat) UI icons and colorful emoji-style icons
Testing Vitest Unit tests (e.g. auth.service.test.ts)
Linting Oxlint + vite-plugin-checker Fast linting and build-time type safety

πŸ“ Project Structure

Happify-FE/
β”œβ”€β”€ public/
β”‚   └── mascot-quokka.png        # Happify's quokka mascot
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ App.tsx                  # Route table + ProtectedRoute (Firebase auth gate)
β”‚   β”œβ”€β”€ main.tsx                 # React entry point
β”‚   β”‚
β”‚   β”œβ”€β”€ api/dashboard/           # Typed Axios calls: profile, mood, journal, community,
β”‚   β”‚                             # referral, care chat, heatmap, uploads
β”‚   β”œβ”€β”€ config/                  # api-client.ts (auth interceptor), firebase.ts
β”‚   β”œβ”€β”€ constants/                # api.ts (endpoint map), emoji.ts, api-service.ts
β”‚   β”œβ”€β”€ hooks/dashboard/          # useDashboardData β€” central data + pagination hook
β”‚   β”‚
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ ui/                  # Shared primitives (map.tsx, theme.ts, index.tsx)
β”‚   β”‚   β”œβ”€β”€ dashboard/           # Confirm modals, dashboard panels
β”‚   β”‚   β”œβ”€β”€ journal-journey/     # Journal entry timeline
β”‚   β”‚   β”œβ”€β”€ rich-text-editor/    # Tiptap wrapper (getText / getHTML / clear)
β”‚   β”‚   β”œβ”€β”€ colored-icon/        # Rounded, tinted icon chip
β”‚   β”‚   └── community-heatmap.tsx # MapLibre GL region renderer
β”‚   β”‚
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ landing/              # Public marketing page
β”‚   β”‚   β”œβ”€β”€ auth/                 # Login/Register + auth.service.ts
β”‚   β”‚   β”œβ”€β”€ onboarding/           # 4-step preference questionnaire
β”‚   β”‚   └── dashboard/            # Main app: overview, records, community, care, chat, profile
β”‚   β”‚
β”‚   β”œβ”€β”€ types/                    # Shared TypeScript types
β”‚   └── assets/                   # Hero illustration, mascot artwork
β”‚
β”œβ”€β”€ vite.config.ts                # @ alias, Tailwind + checker plugins, dev proxy
β”œβ”€β”€ components.json               # shadcn/ui config
β”œβ”€β”€ .env.example                  # Required environment variables
└── package.json

βš™οΈ How the App Works

End-to-end user journey:

sequenceDiagram
    participant U as User
    participant FE as Happify-Frontend
    participant BE as Happify-BE
    participant AI as Happify-AI

    U->>FE: Sign up (email or Google)
    FE->>BE: POST /auth/verify (Firebase ID token)
    BE-->>FE: userId + role
    FE->>U: Redirect to /onboarding
    U->>FE: Answer 4 preference questions
    FE->>BE: POST /preferences
    FE->>U: Redirect to /dashboard
    FE->>BE: Fetch profile, analytics, community, referrals, chats
    FE->>BE: Open WebSocket channels (community, care, user:id:care)

    U->>FE: Write journal entry
    FE->>BE: POST /journal
    BE->>AI: Analyze content
    AI-->>BE: riskLevel + aiReflection
    BE-->>FE: Saved journal with reflection

    U->>FE: Request professional support
    FE->>BE: POST /referral
    BE-->>FE: Referral (PENDING)
    Note over BE,FE: Psychologist reviews & accepts
    BE-->>FE: WebSocket push β†’ open live care chat
Loading

Authentication & request flow:

flowchart LR
    A[Firebase Auth SDK] -->|sign in| B[apiClient / Axios]
    B -->|attaches Bearer idToken| C[Happify Backend API]
    C -->|200 OK| D[Response returned]
    C -->|401| E{Retry once with refreshed token?}
    E -->|success| C
    E -->|fails again| F[Sign out + clear session + redirect to /login]

    style A fill:#FFCA28,color:#000
    style C fill:#1CB0F6,color:#fff
    style F fill:#FF4B4B,color:#fff
Loading

🎨 Design System

A warm, "playful but safe" visual language (Duolingo-inspired), defined centrally in src/components/ui/theme.ts:

Token Role Appearance
page App background Soft green/blue radial gradient over near-white
primaryBtn Main CTAs Happify green (#58CC02), solid drop shadow, lifts on hover
secondaryBtn Secondary actions Sky blue (#1CB0F6) pill buttons
card Content containers Rounded 28px corners, 2px border, flat drop shadow
tones.* Status & mood accents green / blue / gold / red / purple / peach

Mood palette (shared across dashboard, journal risk chart, and the heatmap):

Mood Color Meaning
HAPPY 🟒 #58CC02 Positive check-ins
CALM πŸ”΅ #1CB0F6 Calm check-ins
NEUTRAL 🟑 #FFC800 Neutral check-ins
ANXIOUS 🟠 #FF9600 Elevated-concern check-ins
SAD 🟣 #CE82FF Low-mood check-ins
DISTRESSED πŸ”΄ #FF4B4B Highest-concern check-ins, CRISIS risk level

Iconography: Phosphor Icons for interface chrome; Fluent flat emoji (via Iconify) for warm, human touches on cards and mood states.


πŸ”Œ API Surface

All requests go through the shared apiClient against endpoints in src/constants/api.ts (built from VITE_API_URL):

Endpoint Purpose
POST /auth/verify Exchange a Firebase ID token for a Happify session
GET/PATCH /profile Read/update the signed-in user's profile
POST /profile/psychologist-applications Submit psychologist verification
GET/POST /preferences Onboarding preferences
GET /analytics/dashboard Totals, mood trend, risk summary, recent journals
POST /mood Save a mood check-in
GET/POST /journal List/create journal entries (AI reflection + risk level)
GET/POST /community, /community/:id/comments, /community/:id/support Community feed, replies, support reactions
GET /heatmap Coarse, k-anonymous mood regions for a date range
POST/GET/PATCH /referral Request, list, and review professional referrals
GET /care-chat, POST /care-chat/:id/messages, PATCH /care-chat/:id Live care chat sessions and messages
POST /media/images Upload a base64 image, receive a hosted URL
WS /ws?channel=... Realtime updates for community, care, user:<id>:care, care-chat:<sessionId>

The frontend never calls the AI service directly β€” reflections and risk scoring are computed by Happify-AI, orchestrated through Happify-BE.


πŸ—ΊοΈ Routes

Path Access Description
/ Public Landing page
/login Β· /register Public Sign in / create an account
/onboarding Public (post-register) 4-step preference questionnaire
/dashboard πŸ”’ Protected Overview β€” stats, trends, heatmap, recent activity
/dashboard/records πŸ”’ Protected Mood check-ins and journal entries
/dashboard/community πŸ”’ Protected Anonymous community feed and heatmap
/dashboard/care πŸ”’ Protected Referral requests / review queue (role-aware)
/dashboard/chat πŸ”’ Protected Real-time care chat
/dashboard/history πŸ”’ Protected Closed care chat history
/dashboard/profile πŸ”’ Protected Profile, password, psychologist application

ProtectedRoute waits for auth.authStateReady() before redirecting, avoiding a flash of the wrong screen on refresh.


πŸ” Environment Variables

Create .env from .env.example:

VITE_API_URL=http://localhost:4000
VITE_FIREBASE_API_KEY=
VITE_FIREBASE_AUTH_DOMAIN=
VITE_FIREBASE_PROJECT_ID=
VITE_FIREBASE_APP_ID=
VITE_FIREBASE_MEASUREMENT_ID=
Variable Description
VITE_API_URL Base URL of the Happify Backend (also used to derive the WebSocket URL)
VITE_FIREBASE_API_KEY Firebase Web API key
VITE_FIREBASE_AUTH_DOMAIN Firebase authentication domain
VITE_FIREBASE_PROJECT_ID Firebase project identifier
VITE_FIREBASE_APP_ID Firebase Web application identifier
VITE_FIREBASE_MEASUREMENT_ID Firebase Analytics measurement ID (optional)

⚠️ The app throws immediately if apiKey, authDomain, projectId, or appId are missing β€” it will not boot without a valid Firebase configuration.


πŸš€ Getting Started

Prerequisites

  • Node.js 22.x
  • npm 10.9.4 or later
  • A running Happify Backend instance reachable at VITE_API_URL
  • A Firebase Web app with Email/Password and Google sign-in enabled

Installation

git clone https://github.com/Happiffy/Happify-FE.git
cd Happify-FE
npm ci
cp .env.example .env   # then fill in your Firebase project credentials

Development

npm run dev

The app starts at http://localhost:5173. Requests to /api are proxied to http://localhost:4000 in development.

Build & Preview

npm run build      # tsc -b && vite build
npm run preview     # serve the production build locally

Quality Checks

npm run lint    # Oxlint
npm test        # Vitest
npm run build   # Type-check + production build

πŸ–ΌοΈ App Screens

Landing Page Feature Section
Landing Page Feature Section
Overview Dashboard Anonymous Heatmap
Dashboard WorkPrint Detail
Records Page Community Page
Reflect My WorkPrint
Chat Page Profile Page
Reflect My WorkPrint

πŸŽ“ Project Context

Built for

Garuda Hacks 7.0 β€” International Hackathon Competition

AI-Powered Mental Wellness Platform

Happify-Frontend is the web dashboard of Happify, a privacy-aware digital wellbeing ecosystem built around early detection, meaningful support, and lifelong emotional growth:

Layer Component Role
🌐 Web Happify-FE (this repo) Mood tracking, journaling, anonymous community, care workflows
☁️ Backend Happify-BE API, PostgreSQL, Firebase, WebSocket hub, safety & moderation
🧠 AI Happify-AI Journal reflection, risk detection, voice processing
πŸ“± Mobile Happify-Mobile Flutter app for on-the-go mood tracking and care access
πŸ”Œ IoT Happify-IOT Optional companion-device integration

πŸ‘₯ Team

Outstanding BINUSIAN Team β€” Garuda Hacks 7.0

Name Role
Andrian Pratama Full-stack Developer
Khalisa Amanda Sifa Ghaizani IoT Engineer
Michella Arlene Wijaya Radika Product Developer
Stanley Nathanael Wijaya Product Developer

πŸ“„ License

This project is licensed under the MIT License β€” free to use, modify, and distribute.

MIT License

Copyright (c) 2026 Happify β€” Garuda Hacks 7.0

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software.

"Detect early. Support meaningfully. Grow for life."


Garuda Hacks


Made with 🌱 for Garuda Hacks 7.0

Releases

Packages

Contributors

Languages