A microservices-based event management system with React frontend, Node.js/Express backend, and PostgreSQL database.
This project follows a microservices architecture with the following structure:
- Frontend: React application
- Backend Services:
user-service: User management (Participants, Event Organizers, Administrators)event-service: Event creation and managementregistration-service: Event registrations and waitlist management
- Shared: Common utilities and database configuration
- Database: PostgreSQL (NeonDB cloud database)
Terp-EventSphere/
├── frontend/ # React frontend
├── services/
│ ├── user-service/ # User management service
│ │ ├── controllers/ # API request handlers
│ │ ├── services/ # Business logic
│ │ ├── repositories/ # Database access
│ │ └── routes/ # Express routes
│ ├── event-service/ # Event management service
│ │ ├── controllers/
│ │ ├── services/
│ │ ├── repositories/
│ │ └── routes/
│ └── registration-service/ # Registration & waitlist service
│ ├── controllers/
│ ├── services/
│ ├── repositories/
│ └── routes/
├── shared/ # Shared utilities
│ └── db/ # Database configuration
└── database/
└── init.sql # Database schema
- Backend: Node.js, Express.js
- Database: PostgreSQL 15
- Language: JavaScript
- Package Manager: npm
- ORM: Raw SQL with
pglibrary - Password Hashing: bcrypt
The database implements the following entities:
-
Users (abstract base class with inheritance):
Participant: Can register for events and collect badgesEventOrganizer: Can create and manage eventsAdministrator: Can manage users and events
-
Events: Event information with capacity and status
-
Registrations: Association between Participants and Events (with QR codes)
-
WaitlistEntries: Association between Participants and Events (when events are full)
-
TerrapinPassport: Passport for participants to collect badges
-
Badges: Badges earned by participants for attending events
All tables support soft deletes (using deleted_at timestamp) and include created_at and updated_at timestamps.
- Node.js (v18 or higher recommended)
- npm
- NeonDB account (or any PostgreSQL database)
npm installThis will install dependencies for all workspaces (root, services, shared, frontend).
node setup-env.jsThis creates .env files for all services with default development values. See ENV_SETUP.md for detailed configuration.
Important: Update JWT_SECRET in all .env files with a strong random string for production.
This project uses NeonDB (cloud PostgreSQL). See NEON_SETUP.md for detailed setup instructions.
Quick Setup:
- Create a NeonDB account at neon.tech
- Create a new project and copy your connection string
- Update
DATABASE_URLin all service.envfiles with your NeonDB connection string - Set
DB_SSL=truein all service.envfiles - Run the database schema initialization:
# Option 1: Using psql (if installed) psql "your-neon-connection-string" -f database/init.sql # Option 2: Using Neon SQL Editor # Copy the contents of database/init.sql and run it in the Neon SQL Editor
Each service can be started independently:
# User Service (Port 3001)
cd services/user-service
npm run dev
# Event Service (Port 3002)
cd services/event-service
npm run dev
# Registration Service (Port 3003)
cd services/registration-service
npm run devOr start all services from the root:
npm run devPOST /api/users/register- Register a new user (FR-1)- Body:
{ email, password, role, name? } - Returns: User object (without password)
- Body:
POST /api/users/login- Login user (FR-2)- Body:
{ email, password } - Returns:
{ token, user }(JWT token and user object)
- Body:
POST /api/users/password-reset/request- Request password reset token (FR-4)- Body:
{ email } - Returns: Reset token (in production, sent via email)
- Body:
POST /api/users/password-reset/reset- Reset password using token (FR-4)- Body:
{ resetToken, newPassword } - Returns: Success message
- Body:
GET /api/users/profile- Get authenticated user's profile (FR-3)- Headers:
Authorization: Bearer <token>
- Headers:
PUT /api/users/profile- Update authenticated user's profile (FR-3)- Headers:
Authorization: Bearer <token> - Body:
{ name?, email? }(role cannot be changed)
- Headers:
GET /api/users/admin/users- Get all users (FR-5)- Headers:
Authorization: Bearer <token>
- Headers:
DELETE /api/users/admin/users/:id- Delete user (soft delete) (FR-5)- Headers:
Authorization: Bearer <token>
- Headers:
GET /api/users/:id- Get user by IDPOST /api/users- Create userPUT /api/users/:id- Update userDELETE /api/users/:id- Delete user (soft delete)
GET /api/events- Get all eventsGET /api/events/:id- Get event by IDPOST /api/events- Create eventPUT /api/events/:id- Update eventDELETE /api/events/:id- Delete event (soft delete)GET /api/events/:id/registrations- Get event registrationsGET /api/events/:id/waitlist- Get event waitlist
-
GET /api/registrations- Get all registrations -
GET /api/registrations/:id- Get registration by ID -
POST /api/registrations- Create registration -
PUT /api/registrations/:id- Update registration -
DELETE /api/registrations/:id- Delete registration (soft delete) -
GET /api/registrations/participant/:participantId- Get participant registrations -
GET /api/waitlist- Get all waitlist entries -
GET /api/waitlist/:id- Get waitlist entry by ID -
POST /api/waitlist- Create waitlist entry -
DELETE /api/waitlist/:id- Delete waitlist entry (soft delete) -
GET /api/waitlist/participant/:participantId- Get participant waitlist entries
All services use a shared database configuration located in shared/db/config.js. The database connection is initialized when each service starts.
All protected endpoints require a JWT token in the Authorization header:
Authorization: Bearer <your-jwt-token>
The authentication middleware can be imported and used in other services:
const { authenticate } = require('../../services/user-service/middleware/authMiddleware');
// Protect a route
router.get('/protected', authenticate, controller.method);
// Access user info in controller
// req.user will contain: { userID, role, email, name }For admin-only endpoints, use both middleware:
const { authenticate } = require('../../services/user-service/middleware/authMiddleware');
const { requireAdmin } = require('../../services/user-service/middleware/adminMiddleware');
router.delete('/admin/users/:id', authenticate, requireAdmin, controller.deleteUser);Environment variables are required for all services. See ENV_SETUP.md for detailed setup instructions.
Quick Setup:
node setup-env.jsThis will create .env files for all services with default development values.
Required Environment Variables:
DATABASE_URL- PostgreSQL connection string (format:postgresql://user:password@host:port/database)JWT_SECRET- Secret key for signing JWT tokens (use a strong random string, minimum 32 characters)JWT_EXPIRES_IN- Token expiration time (default: '24h')CORS_ORIGIN- Comma-separated list of allowed origins (e.g.,http://localhost:5173,http://localhost:3000)PORT- Service port (optional, defaults: 3001-3004 per service)
For Production:
- Set
DB_SSL=truefor cloud databases (Neon, Render, etc.) - Use strong, randomly generated
JWT_SECRET(e.g.,openssl rand -base64 32) - Restrict
CORS_ORIGINto production domains only
Using Neon Database: See NEON_SETUP.md for detailed instructions on configuring Neon PostgreSQL database.
- Create a new directory in
services/ - Set up the layered architecture:
controllers/- Request handlersservices/- Business logicrepositories/- Database accessroutes/- Express routes
- Add the service to the root
package.jsonworkspaces - Create a
package.jsonwith dependencies - Create an
.env.examplefile
The database schema is initialized via database/init.sql. Run this script on your NeonDB database to set up the schema. For production, consider using a proper migration system.
ISC