Projects/niwa
Professional / Company project
NIWA
Anonymous community + AI mood check-ins, with a full operator console.
NIWA is a wellness and community platform: twice-daily AI mood check-ins, anonymous group discussions, badges, and push notifications. This repo is the NestJS API and React Super Admin that the mobile app and operators run against.
- React
- Vite
- TypeScript
- NestJS
- Node.js
- PostgreSQL
- TypeORM
- REST APIs
- Socket.IO
- OpenAI
- FCM
- JWT
Wellness · Community · AI · NestJS · RBAC · Mobile API
Overview
A NestJS + PostgreSQL monolith serving a mobile wellness/community app and a Vite Super Admin. Users check in with OpenAI-guided conversations, post in groups under a word-pair identity, and earn credits, badges, and tiers. JWT, RBAC, FCM, Socket.IO, and an OpenAI content gate sit in front of TypeORM migrations.
Problem
People need a private place to track how they feel and a separate, identity-hidden place to talk — without a public feed, and with real moderation and admin control.
Solution
Split the product into group-scoped anonymous discussions and timezone-aware AI check-ins, then run both through one API: credit limits, report/block, AI moderation, cron reminders, and a permissioned Super Admin for users, content, and safety.
Key features
- Email, Google, and Apple sign-in with a Terms gate on social login
- Anonymous word-pair usernames (set once)
- Group-scoped questions, threaded comments, and votes
- Monthly question credits (3/month UTC, earn back via comments)
- Twice-daily AI mood check-ins (4 turns + insight, SSE optional)
- Mood-linked blog suggestions and public blog API
- Configurable onboarding survey
- In-app + FCM/APNs notifications with per-type preferences
- Achievement badges and community tier ladder with inactivity demotion
- Report, block, admin review, and OpenAI pre-save content gate
- Account pause / deactivate / suspend / ban with force-logout
- Super Admin: users, groups, blogs, moods, achievements, surveys, moderation, RBAC
Technical challenges
Problem
Wellness 'today' and reminders must follow the user's local day, not the server clock.
Approach
Store IANA timezones and UTC timestamps; compute check-in dates and cron windows in the user timezone; run Node and Postgres as UTC.
Problem
Community identity must never leak email or legal name to peers.
Approach
Class-serializer Exclude on PII; public handle from a word-pair dictionary; membership and vote checks use user id only on the server.
Problem
UGC and reflective text can be abusive or self-harm related.
Approach
OpenAI Moderation on community writes and check-in turns; user report/block; admin remove/suspend/ban; Apple-style notification copy.
Problem
Question spam vs. a living discussion.
Approach
Lazy monthly credit budget of 3; comments earn credits back; votes and AI gate add extra friction.
Problem
Operators need page-level access, not a single admin boolean.
Approach
Primary role gates the admin client; RBAC page.* permissions drive API guards and a DB-backed sidebar.
Problem
Check-in reminders, badges, and tiers must stay consistent with multiple API instances.
Approach
Nest cron plus Postgres advisory locks so only one instance runs each job.
What this demonstrates
A production-shaped wellness + UGC platform: dual clients (mobile API + admin SPA), AI conversation, anonymous community, credits, push, cron, and RBAC — not a CRUD demo.