Track your sobriety streak, understand your relapse patterns, connect with a supportive community, and get real-time support from an AI coach β all in one private, judgment-free space.
- Community Chat β Join addiction-specific communities and chat with others on the same journey in real-time via WebSocket
- Milestone Celebrations β Receive automated congratulations when you hit 7, 30, 90, 180, or 365 days of sobriety
- Content Moderation β Automated tiered moderation flags harmful content (self-harm, hate speech, drug references) and allows user flagging
- Streak Tracking β Visualize your sobriety streak in real time with gamified milestones
- Daily Check-ins β Log your mood every day and monitor emotional patterns over time
- Relapse Logging β Record relapses with context (trigger, mood, intensity) for self-awareness
- AI Coach β Chat with a Gemini-powered coach for real-time personalized support (with HuggingFace fallback)
- Urge Intervention β Hit the urge button mid-craving and get instant AI-guided coping strategies
- Pattern Insights β AI analyzes your relapse history and surfaces actionable behavioral insights
- Mood Chart β Visualize your emotional journey over time with an interactive Recharts graph
- Multi-addiction support β Track multiple habits simultaneously (smoking, alcohol, social media, gambling, and more)
- Auto-join Communities β Automatically joined to the relevant support community when you create an active addiction
| Technology | Purpose |
|---|---|
| Next.js 16 (App Router) | React framework with server-side rendering |
| TypeScript | Type safety throughout |
| Tailwind CSS v4 | Utility-first styling |
| Framer Motion | Animations and page transitions |
| Recharts | Mood trend charts |
| Axios | HTTP client with interceptors |
| React Hot Toast | Notifications |
| socket.io-client | Real-time community chat |
| js-cookie | Client-side cookie management |
| lucide-react | Icon library |
| clsx + tailwind-merge | Conditional class utilities |
| Technology | Purpose |
|---|---|
| Node.js + Express | REST API server |
| TypeScript | Type safety throughout |
| Prisma ORM | Database access and migrations |
| PostgreSQL | Primary database |
| Upstash Redis | Caching and rate limiting |
| IORedis | Redis client for BullMQ job queues |
| BullMQ | Background job queues (moderation, milestones, notifications) |
| Socket.io | WebSocket server for real-time community messaging |
| Google Gemini | Primary AI model (via LangChain) |
| HuggingFace | AI fallback model |
| LangChain | AI orchestration layer |
| JWT + Cookies | Authentication |
| Helmet + CORS | Security headers |
| Service | Purpose |
|---|---|
| Vercel | Frontend hosting |
| Render | Backend hosting |
| Upstash | Managed Redis (caching & rate limiting) |
| Redis (self-hosted / Docker) | BullMQ job queue backend |
| PostgreSQL | Managed database (Render / Neon / Supabase) |
| Docker | Containerized backend with Redis |
quit-it/
βββ frontend/ # Next.js app
β βββ app/
β β βββ (auth)/ # Sign-in, Sign-up pages
β β βββ (dashboard)/ # Protected app pages
β β βββ page.tsx # Dashboard home
β β βββ checkin/ # Daily check-in
β β βββ coach/ # AI coach chat
β β βββ community/ # Community chat page
β β βββ insights/ # AI pattern analysis
β β βββ settings/ # User settings
β β βββ onboarding/ # First-time setup
β βββ components/
β β βββ coach/ # ChatWindow, MessageBubble
β β βββ community/ # CommunityHeader, MessageBubble, FlagMenu, MessageInput, MilestoneToast
β β βββ dashboard/ # StreakCard, MoodChart, UrgeButton
β β βββ ui/ # Button, Card, Modal
β βββ context/ # AuthContext
β βββ hooks/ # useCoach, useCheckin, useStreak, useCommunity, useSocket
β βββ services/ # API service layer
β βββ lib/ # Axios instance, utils, request wrapper
β βββ types/ # TypeScript types
β βββ middleware.ts # Route protection
β
βββ backend/ # Express API
βββ src/
β βββ modules/ # Feature modules
β β βββ auth/ # Register, login, logout
β β βββ user/ # Profile
β β βββ addiction/ # Addiction CRUD
β β βββ checkin/ # Daily check-ins
β β βββ relapse/ # Relapse logging
β β βββ ai/ # Coach, urge, insights
β β βββ community/ # Community list, join/leave, messages
β βββ queues/ # BullMQ queue definitions (notification, milestone, moderation)
β βββ workers/ # BullMQ workers (milestone broadcasts, moderation scanning)
β βββ events/ # Event emitter for community lifecycle events
β βββ config/ # DB, Redis, BullMQ Redis, Socket.io, env, constants
β βββ middlewares/ # Auth, validate, rate limit
β βββ services/ # Streak, AI service, Gemini, HuggingFace, cache
β βββ utils/ # Errors, response helper, prompt builder, asyncHandler, seed
βββ prisma/
βββ schema.prisma # Database schema (incl. Community, CommunityMessage, CommunityMember, ModerationFlag)
- Node.js 18+
- PostgreSQL database
- Upstash Redis account (caching + rate limiting)
- Redis instance for BullMQ (or use Docker Compose)
- Google Gemini API key
- HuggingFace API key (fallback)
git clone https://github.com/Puspak29/quit-it.git
cd quit-itcd backend
npm installCreate a .env file:
PORT=8080
NODE_ENV=development
DATABASE_URL=<YOUR_POSTGRES_CONNECTION_STRING>
FRONTEND_URL=http://localhost:3000
# JWT
JWT_SECRET=your-super-secret-jwt-key
JWT_EXPIRES_IN=7d
# Redis (Upstash β caching & rate limiting)
UPSTASH_REDIS_REST_URL=<YOUR_UPSTASH_URL>
UPSTASH_REDIS_REST_TOKEN=<YOUR_UPSTASH_TOKEN>
# Redis (direct β BullMQ job queues)
REDIS_QUEUE_URL=redis://localhost:6379
# AI β Primary
GEMINI_API_KEY=<YOUR_GEMINI_API_KEY>
# AI β Fallback
HF_API_KEY=<YOUR_HUGGINGFACE_API_KEY>
# Firebase Cloud Messaging (optional β for push notifications)
FIREBASE_PROJECT_ID=<YOUR_FIREBASE_PROJECT_ID>
FIREBASE_CLIENT_EMAIL=<YOUR_FIREBASE_CLIENT_EMAIL>
FIREBASE_PRIVATE_KEY=<YOUR_FIREBASE_PRIVATE_KEY>Install and run Redis locally on port 6379, or use Docker Compose:
docker compose up -d redisdocker compose up --buildThis starts both the backend (port 8080) and a Redis instance for BullMQ.
Then run database migrations and seed communities:
npm run db:generate
npm run db:migrate
npm run db:seed
npm run devcd frontend
npm installCreate a .env.local file:
NEXT_PUBLIC_API_URL=http://localhost:8080Start the development server:
npm run devOpen http://localhost:3000 in your browser.
- Create a new Web Service on Render
- Connect your GitHub repo, set root directory to
backend - Set build command:
npm install && npm run build && npm run db:generate - Set start command:
npm start - Add all environment variables from
.env(use a managed Redis provider for BullMQ, e.g., Redis Cloud)
- Import your GitHub repo on Vercel
- Set root directory to
frontend - Add environment variable:
NEXT_PUBLIC_API_URL=https://your-backend.onrender.com - Deploy
Note: The frontend proxies all
/api/*requests to the backend via theNEXT_PUBLIC_API_URLenv var. Authentication uses a bearer token stored in a cookie (frontend-token), and Next.js middleware redirects unauthenticated users to/sign-in.
The community feature provides real-time, addiction-specific support groups:
- Pre-seeded Communities β One community per addiction type is created at startup via
npm run db:seed - Auto-join β When you create an active addiction, you're automatically added to the corresponding community
- Real-time Chat β Messages are sent and received via WebSocket (Socket.io) β no page refresh needed
- Live Indicators β Shows connection status and live member count
- Automated Scanning β Every message passes through a BullMQ worker that checks against tiered keyword lists
SELF_HARMβ message hidden immediatelyHATE_SPEECH/AUTO_KEYWORDβ message flagged for review
- User Flagging β Members can flag messages as spam, hate speech, or self-harm
- Flagged messages are hidden from other users but still visible to the sender
When a user posts a message and their streak matches a milestone (7, 30, 90, 180, or 365 days), a BullMQ job broadcasts a congratulatory toast to the entire community in real-time.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Create account |
| POST | /api/auth/login |
Sign in |
| POST | /api/auth/logout |
Sign out |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/user/me |
Get current user |
| PATCH | /api/user/profile |
Update profile |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/addiction |
Create addiction |
| GET | /api/addiction |
List addictions |
| PATCH | /api/addiction/:id |
Update addiction |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/checkin |
Submit daily check-in |
| GET | /api/checkin |
Get check-in history |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/relapse |
Log a relapse |
| GET | /api/relapse |
Get relapse history |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/ai/chat |
Send message to AI coach |
| GET | /api/ai/history |
Get chat history |
| POST | /api/ai/urge |
Trigger urge intervention |
| GET | /api/ai/insight |
Get AI pattern insight |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/communities |
List all communities (with membership status) |
| GET | /api/communities/:id |
Get community details |
| POST | /api/communities/:id/join |
Join a community |
| DELETE | /api/communities/:id/leave |
Leave a community |
| GET | /api/communities/:id/messages |
Paginated message history (cursor-based) |
| Event | Direction | Description |
|---|---|---|
community:join |
Client β Server | Join a community room |
community:send |
Client β Server | Send a chat message |
community:flag |
Client β Server | Report a message |
community:message |
Server β Client | New message broadcast |
community:milestone |
Server β Client | Milestone achievement broadcast |
community:message:hidden |
Server β Client | Message removed by moderation |
- Passwords hashed with bcrypt (10 rounds)
- Auth via bearer token stored in httpOnly cookie β not accessible via JavaScript
- All routes protected by JWT middleware
- Helmet security headers on all responses
- CORS restricted to frontend origin
- Rate limiting on AI and community endpoints via Redis
- Generic error messages on login to prevent user enumeration
- Content moderation β Tiered keyword filtering with automated flagging/hiding
- Community message length capped at 1000 characters
ISC Β© Puspak29
