Skip to content

Latest commit

 

History

40 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Virtual Physics Lab - Backend API

Backend server for the Virtual Physics Lab application, providing authentication, user management, and progress tracking services.

Live API

Technology Stack

  • Runtime: Node.js serverless functions
  • Database: MongoDB Atlas
  • Authentication: JWT tokens with bcrypt hashing
  • Deployment: Vercel serverless functions
  • CORS: Configured for cross-origin requests

Setup

  1. Install dependencies:
cd backend
npm install
  1. Set up environment variables: Copy .env.example to .env and update the values:
cp .env.example .env
  1. Start MongoDB (make sure MongoDB is installed and running)

  2. Install MongoDB Community Edition:

  3. Start the development server:

npm run dev

API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user
  • GET /api/auth/verify - Verify token
  • POST /api/auth/logout - Logout user

Users

  • GET /api/users/profile - Get user profile
  • PUT /api/users/profile - Update user profile
  • GET /api/users/stats - Get user statistics
  • DELETE /api/users/account - Delete user account

Progress

  • POST /api/progress - Save progress
  • GET /api/progress - Get user progress
  • GET /api/progress/stats - Get progress statistics
  • DELETE /api/progress/:id - Delete progress entry

Simulations

  • GET /api/simulations - Get all simulations
  • GET /api/simulations/:id - Get simulation by ID
  • POST /api/simulations/initialize - Initialize default simulations (admin)

Environment Variables

  • NODE_ENV - Environment (development/production)
  • PORT - Server port (default: 5000)
  • MONGODB_URI - MongoDB connection string
  • JWT_SECRET - JWT secret key
  • FRONTEND_URL - Frontend URL for CORS

Database Schema

User

  • name, email, password (hashed)
  • role (student/teacher/admin)
  • timestamps, last login

Progress

  • userId, simulationId, simulationName
  • timeSpent, score, parameters, results
  • achievements, completedAt

Simulation

  • simulationId, name, description
  • category, difficulty, estimatedTime
  • parameters, learning objectives
  • materials, prerequisites

Development

# Start development server with auto-reload
npm run dev

# Run tests
npm test

# Start production server
npm start

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages