A modern, full-stack AI therapist companion with journaling, mood tracking, and empathetic chat support.
- AI Chat: Free Groq-powered AI therapist conversations
- Journal: Daily journaling with entry history
- Mood Tracker: Log and track your emotional journey
- Notifications: Get reminders for wellness activities
- Crisis Detection: Automatic crisis resource support
- Authentication: Secure JWT-based login/registration
- Node.js (v14+)
- MongoDB Atlas account (free) or local MongoDB
- Groq API key (free from https://console.groq.com)
git clone <your-repo-url>
cd affinity-backend
npm install- Go to https://www.mongodb.com/cloud/atlas/register
- Create free account and cluster
- Create database user
- Get connection string
- Whitelist your IP in "Network Access"
- Visit https://console.groq.com
- Sign up with Google
- Go to "API Keys"
- Create new API key
- Copy the key (starts with
gsk_)
Create a .env file in the root directory:
MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/affinity?retryWrites=true&w=majority
GROQ_API_KEY=gsk_your_groq_api_key_here
JWT_SECRET=your-random-secret-key-here
PORT=3000Generate JWT secret:
openssl rand -base64 32node src/server.jsYou should see:
β
Groq client initialized successfully
MongoDB connected
Server is running on port 3000
Open a new terminal:
cd affinity-frontend
npm install
npm run devFrontend runs on: http://localhost:5173
affinity-backend/
βββ src/
β βββ config/ # Database and API configs
β βββ controllers/ # Route handlers
β βββ middlewares/ # Auth middleware
β βββ models/ # Mongoose schemas
β βββ routes/ # API routes
β βββ server.js # Entry point
βββ affinity-frontend/ # React frontend
βββ docs/ # API documentation
POST /auth/register- Create accountPOST /auth/login- Sign inGET /auth/me- Get profile
GET /journals- Get all entriesPOST /journals- Create entry
GET /moods- Get mood historyPOST /moods- Log mood
POST /chats/start- Start new chatPOST /chats/continue- Continue chatGET /chats/history- Get chat history
GET /notifications- Get notificationsPUT /notifications/:id/read- Mark as read
- Node.js & Express
- MongoDB with Mongoose
- JWT authentication
- Groq AI API
- React 18
- Vite
- Tailwind CSS
- React Router
- Axios
Required .env variables:
MONGO_URI=mongodb+srv://... # MongoDB connection string
GROQ_API_KEY=gsk_... # Groq API key
JWT_SECRET=... # JWT signing secret
PORT=3000 # Server portThe AI automatically detects crisis language and provides professional mental health resources from:
- Talk Suicide Canada (1-833-456-4566)
- Crisis Services Canada
- Kids Help Phone
- Various crisis helplines
- Emergency services (911)
ISC License
Affinity is not a substitute for professional therapy or medical care. The crisis detection feature directs users to professional mental health resources.
- Check MongoDB connection string
- Verify Groq API key is valid
- Ensure
.envfile exists
- Make sure backend is running on port 3000
- Check CORS settings
- Verify backend logs
- Verify Groq API key in
.env - Check Groq quota in console
- Review server logs for errors
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
For issues or questions:
- GitHub Issues
- Check documentation in
/docs - Review API contracts