ClubSphere β Backend (Server Side) Backend API for ClubSphere, a full-stack MERN application for managing local clubs, memberships, events, and payments. This server handles authentication, role-based authorization, database operations, and Stripe payment processing.
π Project Overview The backend of ClubSphere is built using Node.js, Express.js, and MongoDB, with secure authentication via Firebase Admin SDK and payment processing through Stripe API. It provides RESTful APIs to support role-based dashboards for Admins, Club Managers, and Members.
π Key Features RESTful API architecture Firebase JWT-based authentication & authorization Role-based access control (Admin, Club Manager, Member) Secure Stripe payment integration (test mode) CRUD operations for clubs, events, and memberships Event registration & membership lifecycle handling Admin moderation system (approve/reject clubs) Centralized payment tracking Production-ready CORS configuration
π Technology Stack Node.js Express.js MongoDB Firebase Admin SDK (JWT verification) Stripe API CORS dotenv
π Project Structure server/ βββ index.js βββ routes/ β βββ users.routes.js β βββ clubs.routes.js β βββ events.routes.js β βββ memberships.routes.js β βββ payments.routes.js β βββ admin.routes.js βββ middleware/ β βββ verifyJWT.js β βββ verifyAdmin.js β βββ verifyClubManager.js βββ config/ β βββ firebase.config.js β βββ stripe.config.js βββ utils/ β βββ generateToken.js βββ .env
π Database Collections users name email photoURL role (admin | clubManager | member) createdAt clubs clubName description category location bannerImage membershipFee status (pending | approved | rejected) managerEmail (FK β users) createdAt, updatedAt memberships userEmail clubId status (active | expired | pendingPayment) paymentId joinedAt expiresAt (optional) events clubId title description eventDate location isPaid eventFee maxAttendees (optional) createdAt eventRegistrations eventId userEmail clubId status (registered | cancelled) paymentId (optional) registeredAt payments userEmail amount type (membership | event) clubId eventId (optional) stripePaymentIntentId / transactionId status createdAt
π Authentication & Authorization Firebase Authentication (handled on client) Firebase Admin SDK verifies JWT on server Protected routes using middleware: verifyJWT verifyAdmin verifyClubManager
π³ Stripe Payment Flow Client requests payment intent Server creates Stripe PaymentIntent Stripe returns clientSecret Client confirms payment Server stores payment & updates membership/event status
βοΈ Environment Variables Create a .env file in the server directory: PORT=3000 MONGODB_URI=your_mongodb_connection_string STRIPE_SECRET_KEY=your_stripe_secret_key FIREBASE_PROJECT_ID=your_project_id FIREBASE_CLIENT_EMAIL=your_client_email FIREBASE_PRIVATE_KEY=your_private_key
π¦ Installation & Setup cd server npm install
βΆ Run the Server npm run dev The server will run on: http://localhost:3000
π§ͺ Testing Accounts (Client Side) Admin Email: admin100@gmail.com Password: Admin@1234 Club Manager Email: manager100@gmail.com Password: Manager@11234
π Important NPM Packages express cors mongodb firebase-admin stripe dotenv
Developed by: MD Perbej Bhuiyan Akib