Backend API for Mbale Innovators Hub platform
# Mbale Innovators Hub - Backend API
## Overview
This is the backend API for the Mbale Innovators Hub platform, built with Node.js, Express, and MongoDB.
## Technologies Used
- Node.js
- Express.js
- MongoDB with Mongoose
- JWT for authentication
- Multer for file uploads
- bcryptjs for password hashing
## Installation
1. Clone the repository
2. Install dependencies: `npm install`
3. Create a `.env` file with the following variables:
```
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
```
4. Start the server: `npm start` or `npm run dev` for development
## API Endpoints
### Authentication
- `POST /api/auth/register` - Register a new user
- `POST /api/auth/login` - Login user
- `GET /api/auth/me` - Get current user data (requires auth)
### Projects
- `GET /api/projects/public` - Get all approved projects (public)
- `GET /api/projects` - Get all projects (supervisors only)
- `GET /api/projects/myprojects` - Get user's own projects
- `POST /api/projects` - Create a new project (with file upload)
- `PUT /api/projects/:id` - Update a project
- `PUT /api/projects/:id/approve` - Approve a project (supervisors only)
- `PUT /api/projects/:id/reject` - Reject a project (supervisors only)
- `POST /api/projects/:id/comments` - Add a comment to a project
- `GET /api/projects/analytics` - Get analytics data (admins only)
## User Roles
- **Student**: Can submit projects, view their own projects
- **Supervisor**: Can view all projects, approve/reject submissions
- **Admin**: Can view analytics and manage the platform
## File Upload
- Projects can include PDF documents (max 10MB)
- Files are stored in the `uploads/` directory
- Accessible via `/uploads/filename`
## Data Models
### User
```javascript
{
name: String,
email: String,
password: String, // hashed
role: String, // 'student', 'supervisor', 'admin'
faculty: String,
createdAt: Date
}
```
### Project
```javascript
{
title: String,
description: String,
category: String,
technologies …