Skip to content

Latest commit

Β 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Frontend Code of Vibio - https://github.com/abhinavtiwari77/Vibio_Frontend

Deployed Link - https://vibio-frontend.onrender.com

Vibio Backend API

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.

πŸš€ Features

Core 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

Security Features

  • Password hashing with bcrypt
  • JWT token authentication
  • Rate limiting on sensitive endpoints
  • Input validation and sanitization
  • Environment variable configuration

πŸ“‹ Prerequisites

  • Node.js (v14 or higher)
  • MongoDB Atlas account or local MongoDB instance
  • Cloudinary account for media storage
  • npm or yarn package manager

πŸ› οΈ Installation

  1. Clone the repository

    git clone https://github.com/abhinavtiwari77/HealWell_Backend.git
    cd HealWell_Backend
  2. Install dependencies

    npm install
  3. Configure environment variables

    Create a .env file 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
  4. Start the server

    npm start

    For development with auto-reload:

    npm run dev

πŸ“ Project Structure

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

πŸ”Œ API Endpoints

Authentication

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

Users

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

Posts

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

Communities

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

Upload

Method Endpoint Description Auth Required
POST /api/upload Upload media file Yes

πŸ” Authentication

The API uses JWT (JSON Web Tokens) for authentication. Include the token in the Authorization header:

Authorization: Bearer <your_jwt_token>

⚑ Rate Limiting

  • Authentication endpoints: 10 requests per 15 minutes
  • Write operations: 5 requests per 10 seconds

πŸ—„οΈ Database Schema

User Model

  • Name, email, password (hashed)
  • Bio, profile picture, interests
  • Followers/following lists
  • Admin status
  • Timestamps

Post Model

  • Author reference
  • Content, media URLs
  • Community reference
  • Likes array
  • Comments count
  • Timestamps

Community Model

  • Name, slug, description
  • Privacy settings
  • Members, admins lists
  • Pending requests
  • Timestamps

Message Model

  • Sender, receiver references
  • Content, attachments
  • Read status
  • Timestamps

🚧 Planned Features

Short-term Roadmap

  • 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

Long-term Roadmap

  • 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

πŸ§ͺ Testing

# Run tests (to be implemented)
npm test

πŸ“Š Error Handling

The API returns consistent error responses:

{
  "msg": "Error message description"
}

HTTP Status Codes:

  • 200 - Success
  • 201 - Created
  • 400 - Bad Request
  • 401 - Unauthorized
  • 403 - Forbidden
  • 404 - Not Found
  • 500 - Internal Server Error

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ Environment Variables

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

πŸ›‘οΈ Security Considerations

  • Never commit .env files 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

πŸ‘¨β€πŸ’» Author

Abhinav Tiwari - @abhinavtiwari77

πŸ™ Acknowledgments

  • 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.

About

Vibio backend built with Node.js, Express, and MongoDB, powering authentication, posts, messaging, follow workflows, and realtime notifications via Socket.IO

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages