Frontend Code of Vibio - https://github.com/abhinavtiwari77/Vibio_Frontend
Deployed Link - https://vibio-frontend.onrender.com
A comprehensive mental wellness platform backend built with Node.js, Express, MongoDB, and Socket.IO. This RESTful API provides authentication, user management, social features, real-time messaging, and community support functionality.
- User Authentication & Authorization - JWT-based authentication with secure password hashing
- User Profiles - Complete profile management with bio, interests, and profile pictures
- Social Features - Follow/unfollow users, like posts, and engage with content
- Posts Management - Create, edit, delete posts with media support (images/videos)
- Real-time Messaging - Socket.IO powered instant messaging between users
- Community System - Create and manage wellness communities with admin controls
- Comments System - Engage with posts through comments
- File Upload - Cloudinary integration for media storage
- Rate Limiting - Protection against abuse with configurable rate limits
- Input Validation - Express-validator for robust request validation
- Password hashing with bcrypt
- JWT token authentication
- Rate limiting on sensitive endpoints
- Input validation and sanitization
- Environment variable configuration
- Node.js (v14 or higher)
- MongoDB Atlas account or local MongoDB instance
- Cloudinary account for media storage
- npm or yarn package manager
-
Clone the repository
git clone https://github.com/abhinavtiwari77/HealWell_Backend.git cd HealWell_Backend -
Install dependencies
npm install
-
Configure environment variables
Create a
.envfile in the root directory:PORT=3000 MONGODB_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret_key JWT_EXPIRES_IN=7d CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name CLOUDINARY_API_KEY=your_cloudinary_api_key CLOUDINARY_API_SECRET=your_cloudinary_api_secret
-
Start the server
npm start
For development with auto-reload:
npm run dev
backend/
βββ config/
β βββ db.js # MongoDB connection configuration
βββ controllers/
β βββ authController.js # Authentication logic
β βββ commentController.js # Comments management
β βββ communityController.js # Community features
β βββ messageController.js # Real-time messaging
β βββ postController.js # Posts CRUD operations
β βββ uploadController.js # File upload handling
β βββ userController.js # User profile management
βββ middleware/
β βββ authMiddleware.js # JWT verification
β βββ errorMiddleware.js # Error handling
β βββ rateLimiter.js # Rate limiting configuration
β βββ validate.js # Validation middleware
βββ models/
β βββ Comment.js # Comment schema
β βββ Community.js # Community schema
β βββ Conversation.js # Conversation schema
β βββ Message.js # Message schema
β βββ Post.js # Post schema
β βββ User.js # User schema
βββ routes/
β βββ authRoutes.js # Authentication endpoints
β βββ CommentRoutes.js # Comment endpoints
β βββ communityRoutes.js # Community endpoints
β βββ messageRoutes.js # Messaging endpoints
β βββ postRoutes.js # Post endpoints
β βββ uploadRoutes.js # Upload endpoints
β βββ userRoutes.js # User endpoints
βββ utils/
β βββ upload.js # Cloudinary upload utilities
βββ validators/
β βββ authValidator.js # Auth request validation
β βββ commentValidator.js # Comment validation
β βββ postValidator.js # Post validation
βββ .env # Environment variables (not tracked)
βββ .gitignore # Git ignore rules
βββ package.json # Project dependencies
βββ server.js # Application entry point
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/auth/register |
Register new user | No |
| POST | /api/auth/login |
User login | No |
| GET | /api/auth/me |
Get current user | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/user/:id |
Get user by ID | No |
| GET | /api/user |
Search users | No |
| GET | /api/user/me |
Get my profile | Yes |
| PUT | /api/user/me |
Update my profile | Yes |
| POST | /api/user/:id/follow |
Toggle follow user | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/posts |
Get posts feed | No |
| GET | /api/posts/:id |
Get single post | No |
| POST | /api/posts |
Create new post | Yes |
| PUT | /api/posts/:id |
Edit post | Yes |
| DELETE | /api/posts/:id |
Delete post | Yes |
| POST | /api/posts/:id/like |
Toggle like post | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/communities |
Get all communities | No |
| GET | /api/communities/:slug |
Get community by slug | No |
| POST | /api/communities |
Create community | Yes |
| PUT | /api/communities/:slug |
Update community | Yes |
| DELETE | /api/communities/:slug |
Delete community | Yes |
| POST | /api/communities/:slug/join |
Join community | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/upload |
Upload media file | Yes |
The API uses JWT (JSON Web Tokens) for authentication. Include the token in the Authorization header:
Authorization: Bearer <your_jwt_token>
- Authentication endpoints: 10 requests per 15 minutes
- Write operations: 5 requests per 10 seconds
- Name, email, password (hashed)
- Bio, profile picture, interests
- Followers/following lists
- Admin status
- Timestamps
- Author reference
- Content, media URLs
- Community reference
- Likes array
- Comments count
- Timestamps
- Name, slug, description
- Privacy settings
- Members, admins lists
- Pending requests
- Timestamps
- Sender, receiver references
- Content, attachments
- Read status
- Timestamps
- Email verification for new users
- Password reset functionality
- Advanced search with filters
- Post reporting and moderation
- Notifications system
- User blocking functionality
- Comment replies and threading
- Post bookmarking/saving
- Video call integration
- Professional therapist matching
- Mental health assessment tools
- Mood tracking and analytics
- Resource library (articles, videos)
- Anonymous posting option
- Multi-language support
- Mobile app API optimization
- Advanced analytics dashboard
- AI-powered content recommendations
# Run tests (to be implemented)
npm testThe API returns consistent error responses:
{
"msg": "Error message description"
}HTTP Status Codes:
200- Success201- Created400- Bad Request401- Unauthorized403- Forbidden404- Not Found500- Internal Server Error
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
| Variable | Description | Required |
|---|---|---|
| PORT | Server port number | Yes |
| MONGODB_URI | MongoDB connection string | Yes |
| JWT_SECRET | Secret key for JWT signing | Yes |
| JWT_EXPIRES_IN | JWT expiration time | No (default: 7d) |
| CLOUDINARY_CLOUD_NAME | Cloudinary cloud name | Yes |
| CLOUDINARY_API_KEY | Cloudinary API key | Yes |
| CLOUDINARY_API_SECRET | Cloudinary API secret | Yes |
- Never commit
.envfiles to version control - Use strong JWT secrets in production
- Implement HTTPS in production
- Regularly update dependencies
- Monitor rate limit violations
- Implement proper CORS configuration
- Sanitize user inputs
- Use prepared statements/parameterized queries
Abhinav Tiwari - @abhinavtiwari77
- Express.js team for the robust framework
- MongoDB team for the excellent database
- Socket.IO for real-time capabilities
- Cloudinary for media management
- All contributors and supporters
Note: This is an active project under development. Features and documentation are subject to change.