Skip to content

Latest commit

Β 

History

History
429 lines (354 loc) Β· 6.99 KB

File metadata and controls

429 lines (354 loc) Β· 6.99 KB

API Documentation

Base URL

Development: http://localhost:5000
Production: [Your production URL]

Platform Features

πŸ€– Integrated AI Chatbot

The platform includes a Botpress-powered multilingual chatbot that provides:

  • 24/7 instant assistance to users
  • Support for multiple languages (English, Hindi, and other Indian languages)
  • Interactive menu options for common queries
  • Context-aware intelligent responses
  • Guided navigation and help
  • FAQ integration and quick answers

The chatbot is embedded directly in the frontend and requires no API calls from the backend.

Authentication

Most endpoints require JWT authentication. Include the token in the Authorization header:

Authorization: Bearer <your_jwt_token>

πŸ” Authentication Endpoints

Student Login

POST /api/auth/student-login

Request Body:

{
  "studentId": "202400000001",
  "password": "Password123!"
}

Success Response (200):

{
  "success": true,
  "message": "Login successful",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "student": {
    "id": "507f1f77bcf86cd799439011",
    "studentId": "202400000001",
    "studentName": "Aarav Mehta",
    "email": "aarav.mehta@example.com",
    "collegeName": "Vidyasetu College of Engineering",
    "deptName": "Computer Science",
    "deptId": "CSE01",
    "yearOfAdmission": "2024",
    "currentYear": "1"
  }
}

Error Response (401):

{
  "success": false,
  "message": "Invalid student ID or password"
}

Faculty Login

POST /api/auth/faculty-login

Request Body:

{
  "facultyId": "FAC001",
  "password": "SecurePass123"
}

Success Response (200):

{
  "success": true,
  "message": "Login successful",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "faculty": {
    "id": "507f1f77bcf86cd799439012",
    "facultyId": "FAC001",
    "name": {
      "full": "Dr. Arvind Sharma",
      "first": "Arvind",
      "last": "Sharma"
    },
    "email": "arvind.sharma@university.edu",
    "designation": "Professor",
    "department": "Computer Science"
  }
}

Admin Login

POST /api/auth/admin-login

Request Body:

{
  "email": "admin@vidyasetu.com",
  "password": "AdminPass123"
}

Success Response (200):

{
  "success": true,
  "message": "Login successful",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "admin": {
    "id": "507f1f77bcf86cd799439013",
    "name": "Administrator",
    "email": "admin@vidyasetu.com",
    "role": "superadmin"
  }
}

πŸ‘€ Profile Endpoints

Get Student Profile

GET /api/auth/student-profile
Authorization: Bearer <token>

Success Response (200):

{
  "success": true,
  "student": {
    "studentId": "202400000001",
    "studentName": "Aarav Mehta",
    "email": "aarav.mehta@example.com",
    "collegeName": "Vidyasetu College of Engineering",
    "deptName": "Computer Science",
    "deptId": "CSE01",
    "academicYear": "2024-2025",
    "semester": "5",
    "phoneNumber": "9876543210",
    "status": "active",
    "lastLogin": "2025-10-31T10:30:00.000Z"
  }
}

Get Faculty Profile

GET /api/auth/faculty-profile
Authorization: Bearer <token>

Success Response (200):

{
  "success": true,
  "faculty": {
    "facultyId": "FAC001",
    "name": {
      "full": "Dr. Arvind Sharma",
      "first": "Arvind",
      "last": "Sharma"
    },
    "email": "arvind.sharma@university.edu",
    "designation": "Professor",
    "department": "Computer Science",
    "roles": ["HOD", "Research Supervisor"],
    "expertise": ["Machine Learning", "Distributed Systems"],
    "status": "active"
  }
}

Get Admin Profile

GET /api/auth/admin-profile
Authorization: Bearer <token>

πŸ” Search Endpoints

Search Students/Faculty

GET /api/auth/search?query=<search_term>
Authorization: Bearer <token>

Query Parameters:

  • query (required): Search term

Success Response (200):

{
  "success": true,
  "results": [
    {
      "type": "student",
      "id": "202400000001",
      "name": "Aarav Mehta",
      "department": "Computer Science",
      "email": "aarav.mehta@example.com"
    }
  ]
}

✏️ Update Endpoints

Update Profile Details

PUT /api/auth/update-details
Authorization: Bearer <token>

Request Body:

{
  "email": "new.email@example.com",
  "phoneNumber": "9876543210",
  "address": "New Address"
}

πŸ”‘ Token Verification

Verify Token

GET /api/auth/verify-token
Authorization: Bearer <token>

Success Response (200):

{
  "success": true,
  "valid": true,
  "user": {
    "id": "507f1f77bcf86cd799439011",
    "role": "student"
  }
}

πŸ₯ Health Check

Health Check

GET /api/health

Success Response (200):

{
  "success": true,
  "message": "Server is running",
  "timestamp": "2025-10-31T10:30:00.000Z",
  "uptime": 12345.67,
  "memory": {
    "rss": 123456789,
    "heapTotal": 98765432,
    "heapUsed": 87654321,
    "external": 1234567
  },
  "mongoStatus": "Connected"
}

πŸ§ͺ Test Route

Test Endpoint

GET /api/test

Success Response (200):

{
  "success": true,
  "message": "Test route working",
  "environment": "development",
  "timestamp": "2025-10-31T10:30:00.000Z"
}

❌ Error Responses

Common Error Codes

400 Bad Request:

{
  "success": false,
  "message": "Invalid request parameters"
}

401 Unauthorized:

{
  "success": false,
  "message": "Access token required"
}

403 Forbidden:

{
  "success": false,
  "message": "Access denied"
}

404 Not Found:

{
  "success": false,
  "message": "Route not found",
  "requestedPath": "/api/unknown",
  "method": "GET"
}

500 Internal Server Error:

{
  "success": false,
  "message": "Internal server error"
}

πŸ“ Notes

Request Headers

All requests should include:

Content-Type: application/json

Token Expiration

JWT tokens expire after 24 hours. Client applications should handle token refresh or re-authentication.

Rate Limiting

(To be implemented) - Consider implementing rate limiting for production:

  • Login endpoints: 5 requests per minute
  • General API: 100 requests per minute

CORS

Allowed origins are configured in the backend .env file:

ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3001

πŸ”„ Pagination (Future Implementation)

For endpoints returning lists, pagination will follow this format:

GET /api/endpoint?page=1&limit=20

Response:

{
  "success": true,
  "data": [],
  "pagination": {
    "currentPage": 1,
    "totalPages": 5,
    "totalItems": 100,
    "itemsPerPage": 20
  }
}

πŸ“š Additional Resources

  • Postman Collection: [Link to be added]
  • OpenAPI Spec: [Link to be added]
  • Interactive API Docs: [Link to be added]

Last Updated: October 31, 2025