Backend API server for the MentorMinds Stellar platform, built with Node.js, Express, TypeScript, and PostgreSQL.
- RESTful API with Express.js
- TypeScript for type safety
- PostgreSQL database with connection pooling
- Stellar SDK integration for blockchain operations
- JWT Authentication for secure user sessions
- Input Validation with Zod
- Security with Helmet and CORS
- Logging with Morgan
- Environment Configuration with dotenv
- Interactive API Docs with Swagger UI (OpenAPI 3.0)
- Video Meeting Integration with multiple provider support (Daily.co, Whereby, Zoom, Jitsi)
- Automated Meeting Room Generation on booking confirmation
- Email Notifications for meeting links
- Timezone Handling with Luxon (IANA timezones, DST-aware)
- Session Reminders with cron-based scheduling
Once the server is running, interactive API documentation is available at:
| URL | Description |
|---|---|
http://localhost:5000/api/v1/docs |
Swagger UI β explore and test all endpoints |
http://localhost:5000/api/v1/docs/spec.json |
Raw OpenAPI 3.0 spec (JSON) |
- Open
http://localhost:5000/api/v1/docsin your browser - Click Authorize (π) and enter your JWT token:
Bearer <your_access_token> - Obtain a token via
POST /auth/loginorPOST /auth/register - Explore endpoints grouped by tag: Auth, Users, Mentors, Payments, Wallets, Admin
The spec auto-updates on every server restart from JSDoc annotations in src/routes/*.ts.
- Node.js 20+ and npm
- PostgreSQL 14+
- Stellar account (testnet for development)
- Install dependencies:
npm install- Setup environment variables:
cp .env.example .envEdit .env with your configuration:
- Database credentials
- JWT secrets
- Stellar network settings
- CORS origins
- Setup database:
# Create database
createdb mentorminds
# Run migrations (coming soon)
npm run migratenpm run devServer runs on http://localhost:5000 with hot reload
npm run build
npm startmentorminds-backend/
βββ src/
β βββ config/ # Configuration files
β β βββ database.ts # PostgreSQL configuration
β β βββ stellar.ts # Stellar SDK configuration
β βββ controllers/ # Route controllers
β βββ middleware/ # Express middleware
β β βββ errorHandler.ts
β β βββ notFoundHandler.ts
β βββ models/ # Database models
β βββ routes/ # API routes
β βββ services/ # Business logic
β βββ utils/ # Utility functions
β βββ types/ # TypeScript types
β βββ server.ts # Entry point
βββ database/
β βββ migrations/ # Database migrations
βββ .env.example # Environment variables template
βββ tsconfig.json # TypeScript configuration
βββ package.json
GET /health
GET /api/v1
GET /api/v1/timezones - List all IANA timezones
GET /api/v1/timezones/:identifier - Get timezone details
POST /api/v1/auth/register- User registrationPOST /api/v1/auth/login- User loginGET /api/v1/users/:id- Get user profileGET /api/v1/mentors- List mentorsPOST /api/v1/bookings- Create bookingPOST /api/v1/bookings/:id/confirm- Confirm booking with auto-generated meeting URLGET /api/v1/bookings- List user sessions with meeting linksPOST /api/v1/bookings- Create booking (with timezone support)POST /api/v1/payments- Process paymentGET /api/v1/wallets/:id- Get wallet info
| Variable | Description | Default |
|---|---|---|
NODE_ENV |
Environment (development/production) | development |
PORT |
Server port | 5000 |
DATABASE_URL |
PostgreSQL connection string | - |
JWT_SECRET |
JWT signing secret | - |
STELLAR_NETWORK |
Stellar network (testnet/mainnet) | testnet |
STELLAR_HORIZON_URL |
Horizon server URL | testnet URL |
CORS_ORIGIN |
Allowed CORS origins | * |
See .env.example for complete list.
For video meeting functionality, add these variables:
MEETING_PROVIDER=jitsi # Options: daily, whereby, zoom, jitsi
MEETING_API_KEY=your_api_key # Required for Daily, Whereby, Zoom
MEETING_ROOM_EXPIRY_MINUTES=30 # Meeting expires 30 min after session endπ See Meeting Providers Guide for detailed setup instructions.
The project uses Jest with Supertest for comprehensive API integration testing. The test suite includes:
- Isolated Tests: Each test runs with a clean database state
- Test Factories: Helper functions to create test data (users, mentors, sessions, payments)
- HTTP Integration Tests: Test actual HTTP requests against the Express app
- Coverage Reporting: Minimum 70% coverage threshold enforced
# Run all tests
npm test
# Run tests in watch mode (for development)
npm run test:watch
# Run tests with coverage report
npm run test:coverageTests use a separate PostgreSQL database configured via DATABASE_URL_TEST environment variable.
- Create the test database:
createdb mentorminds_test-
Configure
.env.test(already provided) with your test database credentials -
Tables are automatically created and truncated between tests
import request from 'supertest';
import app from '../app';
import { createUser } from './factories/user.factory';
import { authenticatedGet } from './helpers/request.helper';
describe('Users API', () => {
it('should get user profile', async () => {
const user = await createUser({ role: 'user' });
const token = generateTestToken({ userId: user.id, email: user.email, role: user.role });
const response = await authenticatedGet('/users/me', token);
expect(response.status).toBe(200);
expect(response.body.email).toBe(user.email);
});
});import { createUser, createMentor, createUsers } from './factories/user.factory';
import { createSession } from './factories/session.factory';
import { createPayment } from './factories/payment.factory';
// Create a single user
const user = await createUser({
email: 'custom@test.com',
role: 'admin',
});
// Create a mentor
const mentor = await createMentor({
bio: 'Expert developer with 10 years experience',
});
// Create multiple users
const users = await createUsers(5);
// Create a session (requires existing users)
const session = await createSession({
mentorId: mentor.id,
menteeId: user.id,
scheduledAt: new Date(),
});
// Create a payment
const payment = await createPayment({
userId: user.id,
amount: 100,
type: 'deposit',
});import {
authenticatedGet,
authenticatedPost,
authenticatedPut,
authenticatedDelete
} from './helpers/request.helper';
// GET request
const response = await authenticatedGet('/users/me', token);
// POST request with data
const response = await authenticatedPost('/sessions', sessionData, token);
// PUT request
const response = await authenticatedPut('/users/profile', updateData, token);
// DELETE request
const response = await authenticatedDelete('/sessions/:id', token);src/
βββ __tests__/ # Test files
β βββ health.test.ts # Health check tests
β βββ ... # Other test files
βββ tests/
β βββ setup.ts # Global test setup/teardown
β βββ factories/ # Test data factories
β β βββ user.factory.ts
β β βββ mentor.factory.ts
β β βββ session.factory.ts
β β βββ payment.factory.ts
β β βββ index.ts
β βββ helpers/ # Test helpers
β βββ request.helper.ts
β βββ index.ts
After running npm run test:coverage, reports are generated in:
coverage/lcov-report/index.html- HTML report (open in browser)coverage/coverage-summary.json- JSON summarycoverage/coverage-final.json- Final coverage data
CI will fail if coverage drops below 70%.
npm run dev- Start development server with hot reloadnpm run build- Build for productionnpm start- Start production servernpm run lint- Run ESLintnpm run lint:fix- Fix ESLint errorsnpm run format- Format code with Prettiernpm test- Run all testsnpm run test:watch- Run tests in watch modenpm run test:coverage- Run tests with coverage report
- Helmet.js for security headers
- CORS configuration
- JWT token authentication
- Input validation with Zod
- SQL injection prevention
- Rate limiting (coming soon)
- Runtime: Node.js 18+
- Framework: Express.js 5
- Language: TypeScript 5
- Database: PostgreSQL 14+
- Blockchain: Stellar SDK
- Authentication: JWT
- Validation: Zod
- Security: Helmet, CORS
- Logging: Morgan
- Timezone: Luxon (IANA timezones, DST-aware)
- Scheduling: Cron (session reminders)
- Project setup
- Basic Express server
- Database configuration
- Stellar SDK integration
- Authentication endpoints
- User management
- Mentor management
- Booking system
- Payment processing
- Wallet management
- Admin dashboard API
- API Documentation (coming soon)
- Database Schema (coming soon)
- Stellar Integration
- Timezone Handling Guide
- DST Edge Cases
- Implementation Summary
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
See CONTRIBUTING.md for branch naming and PR conventions.
MIT License - see LICENSE file for details
For issues and questions:
- Create an issue on GitHub
- Check existing documentation
- Review the codebase
Status: π’ Active Development
Built with β€οΈ for the MentorMinds Stellar platform
Run the full stack locally: `bash docker-compose up --build `
Run the test suite in Docker: `bash docker-compose -f docker-compose.test.yml up --exit-code-from test-backend `