Skip to content

This is the backend API for the Event Platform, a backend web application for event management. It supports user authentication, event CRUD operations, and visual statistics, all powered by Node.js, Express, and MongoDB.

License

Notifications You must be signed in to change notification settings

omarl68/event-platform

Repository files navigation

πŸŽ‰ Event Platform – Backend API

This is the backend for a collaborative event management platform built using Node.js, Express.js, and MongoDB, following a monolith architecture. It enables users to create, manage, and set number of participate in events updates.

✨ Features

  • πŸ“… Event management: Create, update, delete, and view events
  • πŸ”— RESTful APIs for events, users and Auth
  • 🐳 Docker support for development and production
  • πŸ“š OpenAPI documentation with Swagger
  • πŸ—οΈ Monolith architecture for scalability
  • πŸ›‘οΈ TypeScript for type safety
  • βœ… Data validation with Joi

πŸš€ Quick Start

πŸ”§ Requirements

  • Node.js v18+
  • pnpm (package manager)
  • Docker & Docker Compose (optional, but recommended)

πŸŽ₯ Demo

Watch the demo


πŸ“₯ Installation

Option 1: Local Development (without Docker)

# Clone the repository
git clone https://github.com/your-org/event-platform.git
cd event-platform

# Install dependencies
pnpm install

# Copy environment file
cp .env.example .env


# Edit `.env` and configure your MongoDB URI
# Example: MONGODB_URI=mongodb://localhost:27017/event-platform

# Start the development server
pnpm run dev

Server will run by default on: http://localhost:3001

Option 2: Docker Development

Make sure Docker and Docker Compose are installed.

Development Environment

make dev         # Start development environment
make dev-build   # Build and start development
make dev-down    # Stop development environment

Production Environment

make prod        # Start production environment
make prod-build  # Build and start production
make prod-down   # Stop production environment

Useful Docker Commands

make logs        # View container logs
make restart     # Restart containers
make clean       # Remove volumes and prune
make clean-dev   # Clean development environment
make test        # Run backend tests
make db-shell    # Access MongoDB shell
make help        # View all available make targets

πŸ“‚ Project Structure

/project-root/
β”œβ”€β”€ dist/                    # Compiled TypeScript output
β”œβ”€β”€ logs/                    # Application logs
β”œβ”€β”€ public/ 
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ constants/           # Enums, status codes
β”‚   β”œβ”€β”€ core/                # Auth middleware, base services
β”‚   β”œβ”€β”€ docs/                # OpenAPI YAML files
β”‚   β”œβ”€β”€ controllers/         # Request handlers (auth, events, users)
β”‚   β”œβ”€β”€ services/            # Business logic and service classes
β”‚   β”œβ”€β”€ repository/          # Data access and database queries
β”‚   β”œβ”€β”€ models/              # Mongoose models and schemas
β”‚   β”œβ”€β”€ routes/              # Route definitions and mapping
β”‚   β”œβ”€β”€ config/              # Centralized configuration (env variables to app variables)
β”‚   β”œβ”€β”€ __tests__/                # Test suites and test utilities
β”‚   β”œβ”€β”€ types/               # TypeScript interfaces and types
β”‚   β”œβ”€β”€ utils/               # Helper functions (jwtHelper,error handling)
β”‚   β”œβ”€β”€ app.ts               # Express application 
β”‚   β”œβ”€β”€ server.ts            # Application entry point
β”œβ”€β”€ .env                     # Environment variables
β”œβ”€β”€ .env.example             # Example environment file
β”œβ”€β”€ docker-compose.dev.yml   # Development Docker configuration
β”œβ”€β”€ docker-compose.yml       # Production Docker configuration
β”œβ”€β”€ Makefile                 # Docker and project commands
β”œβ”€β”€ package.json
└── pnpm-lock.yaml

πŸ“‘ API Documentation

πŸ“– The API documentation is auto-generated using Swagger (OpenAPI).

API Endpoints Overview

  • Auth: /api/ - Authentication and authorization
  • Users: /api/users - User management
  • Events: /api/events - Event operations

πŸ§ͺ Example Data

πŸ‘€ Example User

{
  "email": "[email protected]",
  "password": "123456Aa"
}

πŸ“† Example Event

{
  "title": "Team Hackathon",
  "date": "2025-08-15",
  "location": "Berlin",
  "nbParticipants": 50
}

πŸ“˜ API Endpoints Overview

Method Endpoint Description Protected
POST /api/register Register a new user ❌
POST /api/login User login (JWT issued) ❌
GET /api/events List all events βœ…
POST /api/events Create a new event βœ…
GET /api/events/stats Get event statistics βœ…
GET /api/events/:id Get event by ID βœ…
PUT /api/events/:id Update event by ID βœ…
DELETE /api/events/:id Delete event by ID βœ…

All protected endpoints require JWT authentication. Validation is performed for event creation, update, and ID parameters.


πŸ§ͺ Testing

Run tests using Docker or locally:

# Using Docker
make test

# Or locally
pnpm test

πŸ”§ Environment Variables

Copy .env.example to .env and configure the following variables:

# Database
MONGODB_URI=mongodb://localhost:27017/event-platform

# Server
PORT=3001
NODE_ENV=development

# JWT
JWT_SECRET=your-secret-key
JWT_EXPIRES_IN=7d

πŸš€ Deployment

Production Deployment

  1. Build the application:

    pnpm run build
  2. Start production server:

    pnpm run start:prod

Docker Production

make prod-build  # Build production images
make prod        # Start production environment

πŸ› οΈ Development

Available Scripts

# Development
pnpm run start:dev    # Start with nodemon
pnpm run build        # Build TypeScript
pnpm run start:prod   # Start production server

# Testing
pnpm run test         # Run tests
pnpm run test:watch   # Run tests in watch mode

# Linting
pnpm run lint         # Run ESLint
pnpm run lint:fix     # Fix ESLint issues

βœ… Tech Stack

  • Backend Framework: Node.js with Express.js
  • Database: MongoDB with Mongoose ODM
  • Language: TypeScript
  • Documentation: Swagger (OpenAPI)
  • Validation: Joi
  • Authentication: JWT
  • Containerization: Docker & Docker Compose
  • Package Manager: pnpm

πŸ“ Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Code Style

  • Follow TypeScript best practices
  • Use ESLint configuration provided
  • Write tests for new features
  • Update documentation as needed

πŸ› Troubleshooting

Common Issues

  1. MongoDB Connection Error

    • Ensure MongoDB is running
    • Check MONGODB_URI in .env
  2. Port Already in Use

    • Change PORT in .env
    • Kill existing processes: lsof -ti:3001 | xargs kill
  3. Docker Issues

    • Clean containers: make clean
    • Rebuild images: make dev-build

πŸ“ž Support

If you encounter any issues or have questions:

  1. Check the API Documentation
  2. Review the troubleshooting section
  3. Open an issue on GitHub

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Built with the backend
  • Inspired by modern event platforms
  • Community contributions welcome

Happy Event Planning! πŸš€

About

This is the backend API for the Event Platform, a backend web application for event management. It supports user authentication, event CRUD operations, and visual statistics, all powered by Node.js, Express, and MongoDB.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published