Skip to content

sumon-ray/Next-Event-Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

211 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Next Event Pro Server - Event Planner & Participation System API

A robust, secure, JWT-protected RESTful API backend that powers the Next Event Pro platform, enabling comprehensive event management with integrated payment processing and advanced participant management features.

🌐 Live API

Visit Next Event Pro

πŸ“š Repositories

πŸ“– Project Overview

The Next Event Pro Server is a comprehensive Node.js/Express.js backend that provides secure APIs for event creation, management, and participation. Built with TypeScript and Prisma ORM, it features sophisticated payment processing, role-based authentication, and scalable architecture patterns.

🎯 Core API Capabilities

  • RESTful Architecture - Clean, standardized API endpoints following REST principles
  • JWT Authentication - Secure token-based authentication and authorization
  • Payment Processing - Integrated SSLCommerz payment gateway with invoice generation
  • File Management - Secure file upload and storage capabilities
  • Email Services - Automated email notifications and invoice delivery
  • Database Management - Type-safe operations with Prisma ORM
  • Error Handling - Comprehensive error management and validation

πŸ‘₯ API Access Control

πŸ”§ Admin Endpoints

  • Monitor all events and user activity through /api/meta/*
  • Manage users and content moderation via /api/user/*
  • Access comprehensive analytics and reports
  • Override user permissions for system maintenance

πŸ‘€ User Endpoints

  • Authentication: /api/auth/* - Login, register, password management
  • Event Management: /api/event/* - CRUD operations for personal events
  • Participation: /api/participant/* - Join requests and approvals
  • Payments: /api/payment/* - Secure payment processing
  • Invitations: /api/invite/* - Send and manage event invitations
  • Reviews: /api/review/* - Post-event feedback and ratings
  • Profile: /api/profile/* - User profile management

πŸ’° Payment Integration Features

SSLCommerz Integration

  • Secure Transactions - PCI DSS compliant payment processing
  • Multiple Payment Methods - Cards, mobile banking, net banking
  • Automatic Invoice Generation - PDF invoices with event details
  • Payment Verification - Webhook-based payment confirmation
  • Refund Management - Automated refund processing

Payment Workflows

  • Immediate Processing - Real-time payment validation
  • Status Tracking - Complete payment lifecycle monitoring
  • Email Notifications - Automated payment confirmations
  • Invoice Delivery - Professional PDF invoice generation

πŸ—οΈ Architecture Overview

Backend Architecture

  • Modular Design - Feature-based module organization
  • Service Layer - Business logic separation from controllers
  • Middleware Stack - Authentication, validation, and error handling
  • Database Layer - Prisma ORM with PostgreSQL
  • File Processing - Secure file upload and management

Security Implementation

  • JWT Authentication - Secure token-based sessions
  • Input Validation - Zod schema validation for all endpoints
  • Error Handling - Comprehensive error management system
  • Rate Limiting - API abuse prevention
  • CORS Configuration - Cross-origin request security

πŸ“ Server Project Structure

src/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ builders/                 # Query builders and utilities
β”‚   β”‚   └── PrismaQueryBuilder.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ config/                   # Application configuration
β”‚   β”‚   └── index.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ errors/                   # Error handling utilities
β”‚   β”‚   β”œβ”€β”€ AppError.ts
β”‚   β”‚   └── handleZodError.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ globalTypes/              # Global TypeScript definitions
β”‚   β”‚   β”œβ”€β”€ error.type.ts
β”‚   β”‚   └── response.type.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ helpers/                  # Utility functions
β”‚   β”‚   β”œβ”€β”€ CalculatePagination.ts
β”‚   β”‚   β”œβ”€β”€ catchAsync.ts
β”‚   β”‚   β”œβ”€β”€ emailHelper.ts
β”‚   β”‚   β”œβ”€β”€ fileUploader.ts
β”‚   β”‚   β”œβ”€β”€ generatePaymentInvoicePDF.ts
β”‚   β”‚   β”œβ”€β”€ invoiceSender.ts
β”‚   β”‚   β”œβ”€β”€ jwtHelpers.ts
β”‚   β”‚   β”œβ”€β”€ RefineQuery.ts
β”‚   β”‚   β”œβ”€β”€ sendResponse.ts
β”‚   β”‚   └── tokenDecoder.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ interfaces/               # TypeScript interfaces
β”‚   β”‚   β”œβ”€β”€ file.ts
β”‚   β”‚   └── pagination.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ middlewares/              # Express middlewares
β”‚   β”‚   β”œβ”€β”€ Auth.ts
β”‚   β”‚   β”œβ”€β”€ globalErrorhandler.ts
β”‚   β”‚   β”œβ”€β”€ notFound.ts
β”‚   β”‚   └── validateRequest.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ modules/                  # Feature modules
β”‚   β”‚   β”œβ”€β”€ auth/                 # Authentication module
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.constant.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.interface.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.route.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.service.ts
β”‚   β”‚   β”‚   └── emailSender.ts
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ event/                # Event management
β”‚   β”‚   β”‚   β”œβ”€β”€ event.constants.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ event.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ event.interface.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ event.routes.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ event.service.ts
β”‚   β”‚   β”‚   └── event.validation.ts
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ invite/               # Invitation system
β”‚   β”‚   β”‚   β”œβ”€β”€ invite.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ invite.interface.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ invite.route.ts
β”‚   β”‚   β”‚   └── invite.service.ts
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ meta/                 # System metadata & analytics
β”‚   β”‚   β”‚   β”œβ”€β”€ meta.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ meta.route.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ meta.service.ts
β”‚   β”‚   β”‚   └── meta.utils.ts
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ participant/          # Participant management
β”‚   β”‚   β”‚   β”œβ”€β”€ participant.constants.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ participant.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ participant.inteface.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ participant.route.ts
β”‚   β”‚   β”‚   └── participant.service.ts
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ payment/              # Payment processing
β”‚   β”‚   β”‚   β”œβ”€β”€ payment.constants.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ payment.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ payment.interface.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ payment.route.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ payment.service.ts
β”‚   β”‚   β”‚   └── payment.utils.ts
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ profile/              # User profile management
β”‚   β”‚   β”‚   β”œβ”€β”€ profile.constraint.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ profile.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ profile.interface.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ profile.routes.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ profile.services.ts
β”‚   β”‚   β”‚   └── profile.validation.ts
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ review/               # Review system
β”‚   β”‚   β”‚   β”œβ”€β”€ review.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ review.interface.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ review.router.ts
β”‚   β”‚   β”‚   └── review.service.ts
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ sslcommerz/           # Payment gateway integration
β”‚   β”‚   β”‚   β”œβ”€β”€ sslcommerz.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ sslcommerz.route.ts
β”‚   β”‚   β”‚   └── sslcommerz.service.ts
β”‚   β”‚   β”‚
β”‚   β”‚   └── user/                 # User management
β”‚   β”‚       β”œβ”€β”€ user.constants.ts
β”‚   β”‚       β”œβ”€β”€ user.controller.ts
β”‚   β”‚       β”œβ”€β”€ user.interface.ts
β”‚   β”‚       β”œβ”€β”€ user.routes.ts
β”‚   β”‚       β”œβ”€β”€ user.service.ts
β”‚   β”‚       └── user.validation.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ routes/                   # Route definitions
β”‚   β”‚   └── index.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ shared/                   # Shared utilities
β”‚   β”‚   └── prisma.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ templates/                # Email/PDF templates
β”‚   β”‚   └── invoice.template.hbs
β”‚   β”‚
β”‚   └── types/                    # Additional type definitions
β”‚       β”œβ”€β”€ profile.types.ts
β”‚       └── sslcommerz-lts.d.ts

πŸ› οΈ Technology Stack

Core Backend Technologies

  • Node.js - JavaScript runtime environment
  • Express.js - Fast, unopinionated web framework
  • TypeScript - Type safety and enhanced developer experience
  • Prisma - Next-generation ORM with type safety
  • PostgreSQL - Advanced relational database

Authentication & Security

  • JWT - JSON Web Token for secure authentication
  • bcrypt - Password hashing and security
  • Zod - TypeScript-first schema validation
  • Helmet - Security middleware for Express

Payment & Communication

Development & Deployment

πŸš€ API Features

πŸ” Authentication System

  • User Registration - Secure account creation with email verification
  • Login/Logout - JWT-based session management
  • Password Management - Secure password reset and change functionality
  • Email Verification - Account activation via email confirmation
  • Role-Based Access - Admin and user role management

🎟️ Event Management APIs

  • CRUD Operations - Complete event lifecycle management
  • Event Types - Support for Public/Private and Free/Paid events
  • File Upload - Event image and document management
  • Search & Filter - Advanced event discovery capabilities
  • Capacity Management - Event size limitations and waitlist handling

πŸ‘₯ Participant Management

  • Join Requests - Sophisticated approval workflow APIs
  • Invitation System - Direct user invitation with payment integration
  • Ban Management - Host controls for participant management
  • Status Tracking - Real-time participant status updates

πŸ’³ Payment Processing

  • SSLCommerz Integration - Secure payment gateway connection
  • Transaction Management - Complete payment lifecycle tracking
  • Invoice Generation - Automated PDF invoice creation
  • Webhook Handling - Real-time payment status updates
  • Refund Processing - Automated refund management

πŸ“Š Analytics & Reporting

  • System Metrics - Comprehensive application analytics
  • User Statistics - User engagement and activity tracking
  • Event Analytics - Event performance and participation data
  • Payment Reports - Financial transaction reporting

πŸ”” Notification System

  • Email Services - Automated email notifications
  • Payment Confirmations - Transaction success/failure notifications
  • Event Updates - Participant communication system
  • System Alerts - Administrative notification system

πŸ“± API Response Format

All API responses follow a consistent format:

{
  success: boolean;
  statusCode: number;
  message: string;
  meta?: {
    page: number;
    limit: number;
    total: number;
  };
  data: any;
}

🎨 Development Patterns

Architecture Patterns

  • MVC Pattern - Model-View-Controller separation
  • Service Layer - Business logic encapsulation
  • Repository Pattern - Data access abstraction
  • Middleware Pattern - Request/response processing pipeline

Code Quality

  • TypeScript - Full type safety throughout the application
  • ESLint & Prettier - Code formatting and linting
  • Error Boundaries - Comprehensive error handling
  • Input Validation - Zod schema validation for all inputs

πŸ“§ Contact Information

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • SSLCommerz merchant credentials
  • Email service credentials (Gmail/SendGrid)

Installation & Setup

  1. Clone the repository
git clone https://github.com/sumon-ray/Next-Event-Server.git
cd Next-Event-Server
  1. Install dependencies
npm install
  1. Configure environment variables
cp .env.example .env

Add the following environment variables:

# Database
DATABASE_URL="postgresql://username:password@localhost:5432/nextevent"

# JWT
JWT_SECRET="your-jwt-secret"
JWT_EXPIRES_IN="7d"

# SSLCommerz
STORE_ID="your-store-id"
STORE_PASSWD="your-store-password"
SSL_PAYMENT_API="https://sandbox.sslcommerz.com/gwprocess/v4/api.php"
SSL_VALIDATION_API="https://sandbox.sslcommerz.com/validator/api/validationserverAPI.php"

# Email
EMAIL_USER="your-email@gmail.com"
EMAIL_PASS="your-app-password"

# File Upload
CLOUDINARY_CLOUD_NAME="your-cloudinary-name"
CLOUDINARY_API_KEY="your-cloudinary-key"
CLOUDINARY_API_SECRET="your-cloudinary-secret"

# Frontend URL
CLIENT_URL="http://localhost:3000"
  1. Setup the database
npx prisma migrate dev
npx prisma generate
npx prisma db seed
  1. Start the development server
npm run dev

The server will start on http://localhost:5000

πŸ§ͺ API Testing

Test Credentials

{
  "admin": {
    "email": "admin@nextevent.com",
    "password": "admin123"
  },
  "user": {
    "email": "user@nextevent.com",
    "password": "user123"
  }
}

Available Scripts

npm run dev          # Start development server
npm run build        # Build for production
npm run start        # Start production server
npm run lint         # Run ESLint
npm run format       # Format code with Prettier
npm run migrate      # Run database migrations
npm run generate     # Generate Prisma client
npm run seed         # Seed database with test data

πŸ“ˆ Performance Optimizations

  • Database Indexing - Optimized queries with proper indexing
  • Connection Pooling - Efficient database connection management
  • Caching Strategy - Redis caching for frequently accessed data
  • Query Optimization - Prisma query optimization techniques
  • Error Handling - Comprehensive error management system

πŸ” Security Implementation

  • JWT Authentication - Secure token-based authentication
  • Password Hashing - bcrypt for secure password storage
  • Input Validation - Zod schema validation for all inputs
  • SQL Injection Prevention - Prisma ORM protection
  • XSS Protection - Helmet.js security middleware
  • CORS Configuration - Proper cross-origin resource sharing
  • Rate Limiting - API abuse prevention middleware

πŸ“„ API Documentation

Core Endpoints

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • POST /api/auth/forgot-password - Password reset request
  • POST /api/auth/reset-password - Password reset confirmation

Events

  • GET /api/event - Get all events (with filters)
  • POST /api/event - Create new event
  • GET /api/event/:id - Get event details
  • PUT /api/event/:id - Update event
  • DELETE /api/event/:id - Delete event

Payments

  • POST /api/payment/init - Initialize payment
  • POST /api/payment/success - Payment success callback
  • POST /api/payment/fail - Payment failure callback
  • GET /api/payment/history - Payment history

Participants

  • POST /api/participant/join - Join event request
  • PUT /api/participant/approve/:id - Approve participant
  • DELETE /api/participant/remove/:id - Remove participant

🀝 Contributing

This project demonstrates advanced backend development practices and is available for portfolio review and professional evaluation.

πŸ“„ License

This project is created for portfolio purposes and professional demonstration.

πŸ™ Acknowledgments

  • Express.js Team - For the robust web framework
  • Prisma Team - For the excellent ORM and database toolkit
  • SSLCommerz - For secure payment processing capabilities
  • Railway/Render - For reliable backend hosting solutions
  • TypeScript Team - For enhanced development experience

Created with ❀️ by Sumon Ray

This backend demonstrates production-ready API development, secure payment integration, and scalable architecture patterns for modern web applications.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •