All Node.js dependencies have been installed via npm install. The following key packages are now available:
Core Framework:
express@5.2.1- Web frameworktypescript@6.0.3- TypeScript compiler
Database:
@prisma/client@7.8.0- Prisma ORM client@prisma/adapter-pg@7.8.0- PostgreSQL adapter for Prismapg@8.21.0- PostgreSQL native client
Authentication & Security:
bcryptjs@2.4.3- Password hashingjsonwebtoken@9.0.2- JWT authenticationuuid@14.0.0- UUID generation
Real-time Communication:
socket.io@4.8.3- WebSocket serversocket.io-client@4.8.3- WebSocket client
Utilities:
cors@2.8.6- CORS middlewaredotenv@17.4.2- Environment configuration
Dev Dependencies:
- TypeScript type definitions for all packages
nodemon@3.1.14- Development auto-reloadts-node@10.9.2- TypeScript executionprisma@7.8.0- Prisma CLI tools
Total: 277 packages installed (3 moderate security vulnerabilities noted - run npm audit fix if needed)
Created .env file with database connection settings:
DATABASE_URL=postgresql://studyadmin:studypass123@localhost:5432/studyroom_db?schema=public
NODE_ENV=development
PORT=5000
JUDGE0_URL=http://localhost:2358
JUDGE0_AUTH_TOKEN=
Successfully compiled all TypeScript source files to JavaScript in the dist/ directory.
The Prisma schema defines 5 main modules:
users- User accounts, profiles, roles, streak trackingoauth_accounts- OAuth provider integrationssubscriptions- Pro/subscription managementbadges- Achievement badgesuser_badges- User badge assignmentsfriendships- User connections and friend requests
study_rooms- Study room metadataroom_members- Room membership and online statuschat_messages- In-room messagingroom_tasks- Task management in roomswhiteboard_sessions- Collaborative whiteboarding
problems- Coding problems with test casessubmissions- Code submissions and execution resultsdiscussions- Problem discussion threadsstudy_plans- Structured learning pathsstudy_plan_problems- Problems in planscontests- Coding contestscontest_problems- Problems in contestscontest_participants- Contest participation
mock_interviews- Interview sessionsmock_interview_problems- Problems in interviewsmock_interview_results- Interview results and scorespair_sessions- Pair programming sessionspair_cursors- Real-time cursor positions
leaderboard_entries- Leaderboard rankingsanalytics_events- Event trackingaudit_logs- Audit trail
# Start PostgreSQL, Redis (for Judge0), and the API
cd server
docker compose up -d --build
# Start with Judge0 code execution support
docker compose --profile judge0 up -d --build
# Create tables from Prisma schema
docker compose exec api npx prisma db push
# Run smoke tests
docker compose exec api npm run test:dbYou'll need PostgreSQL 15+ installed locally:
-
Create the database:
CREATE DATABASE studyroom_db; CREATE USER studyadmin WITH PASSWORD 'studypass123'; ALTER USER studyadmin CREATEDB; GRANT ALL PRIVILEGES ON DATABASE studyroom_db TO studyadmin;
-
Push Prisma schema to create tables:
npm run db:push
-
Run smoke tests:
npm run test:db
-
Seed database (optional):
npm run seed
-
Start the server:
npm run start # or for development with auto-reload: npm run dev
npm run build- Compile TypeScript to JavaScriptnpm run dev- Watch TypeScript and recompile on changesnpm start- Start the built servernpm run docker:start- Start server in Docker with ts-nodenpm run db:push- Sync Prisma schema with database (creates/updates tables)npm run test:db- Run backend smoke test suitenpm run seed- Run database seed script
Health Check:
GET /health
Authentication:
POST /api/auth/registerPOST /api/auth/loginGET /api/auth/profile
Practice Problems:
GET /api/problemsGET /api/problems/:idPOST /api/problemsPUT /api/problems/:idDELETE /api/problems/:id
Code Execution:
GET /api/code/languagesPOST /api/code/run
server/
├── src/
│ ├── server.ts # Server entry point
│ ├── app.ts # Express app setup
│ ├── config/
│ │ └── database.ts # Prisma client instance
│ ├── middleware/ # Auth, error handling
│ ├── modules/
│ │ ├── auth/ # Authentication routes/controllers
│ │ ├── practice/ # Problem CRUD routes
│ │ ├── codeExecution/ # Judge0 proxy
│ │ └── [other modules]/
│ ├── socket/
│ │ └── socketServer.ts # WebSocket real-time events
│ └── test-db.ts # Smoke tests
├── prisma/
│ ├── schema.prisma # Database schema
│ └── seed.ts # Seed script
├── dist/ # Compiled JavaScript (auto-generated)
├── Dockerfile # API container image
├── docker-compose.yml # Service orchestration
├── package.json # Dependencies
├── tsconfig.json # TypeScript config
└── .env # Environment variables
- Database credentials in .env are for development only. Change before production.
- Docker is recommended for a quick, isolated setup without installing PostgreSQL locally.
- Judge0 is optional and only runs when the
judge0profile is enabled. - Prisma migrations should be used for production deployments (see README.md).
- TypeScript source files in
src/are compiled todist/- don't editdist/directly.
- Module not found errors? Run
npm installagain - Prisma client issues? Run
npx prisma generate - Database connection failed? Verify PostgreSQL is running and .env has correct DATABASE_URL
- Port 5000 already in use? Change PORT in .env or kill the process using that port
For more details, see the README.md file in the server directory.