Skip to content

Latest commit

Β 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ™οΈ Rex Labs β€” Professional Studio Platform

License: MIT Next.js 14 Express MongoDB Supabase Vercel Render

A full-stack MERN platform for professional audio engineers and music producers β€” featuring a beat marketplace, studio booking system, and a secure admin dashboard.


🌐 Live Application

Service URL
Frontend (Client) https://rexlab.vercel.app
Backend (API) https://rexlab.onrender.com/api

✨ Key Features

  • 🎡 Beat Marketplace β€” Browse, preview, and purchase beats with cover art, BPM, genre, mood tags, and streaming previews. Beat ownership is tracked with a sold status flag.
  • πŸ’³ Razorpay Payment Integration β€” Secure order creation and server-side HMAC-SHA256 signature verification via the Razorpay API, with full order records persisted in MongoDB.
  • πŸ“… Studio Session Booking β€” Interactive calendar-driven booking flow supporting session types: Full Recording, Vocals, Audio/Instrumental, Mixing & Mastering, and Custom, with payment status tracking (pending β†’ advance_paid β†’ full_paid).
  • πŸ” JWT + Role-Based Auth β€” Stateless authentication using JSON Web Tokens. A two-tier role system (admin / client) enforces route-level access control via protect and admin middleware.
  • βš™οΈ Secure Admin Dashboard β€” A protected /admin area for managing beats (CRUD), viewing and updating studio session statuses, and handling customer enquiries with read/replied status tracking.
  • ☁️ Supabase File Storage β€” High-resolution WAV/ZIP beat files and audio previews are stored on Supabase Storage, keeping the main database lean and performant.

πŸ› οΈ Tech Stack

Frontend (/client)

Technology Version Purpose
Next.js 14.1.0 App Router, SSR/SSG framework
React ^18 UI component library
Tailwind CSS ^3.3.0 Utility-first styling
Framer Motion ^12.33.0 Animations and transitions
Axios ^1.13.5 HTTP client for API calls
@supabase/supabase-js ^2.99.1 Supabase Storage client
react-calendar ^6.0.0 Booking calendar UI
next-themes ^0.4.6 Dark/light mode toggling
react-hot-toast ^2.6.0 Toast notifications
react-icons ^5.5.0 Icon library
date-fns ^4.1.0 Date formatting utilities

Backend (/server)

Technology Version Purpose
Node.js >=18 Runtime environment
Express ^4.18.2 REST API framework
Mongoose ^8.0.3 MongoDB ODM
jsonwebtoken ^9.0.3 JWT generation and verification
bcryptjs ^2.4.3 Password hashing (salt rounds: 10)
Razorpay ^2.9.6 Payment gateway SDK
Stripe ^14.10.0 Payment gateway SDK (secondary)
@supabase/supabase-js ^2.99.1 Supabase Storage admin client
Cloudinary ^1.41.2 Alternative media storage
Nodemailer ^6.9.7 Email notifications
Multer ^1.4.5-lts.1 Multipart file upload handling
express-async-handler ^1.2.0 Async error propagation
Nodemon ^3.1.11 Dev server auto-restart
dotenv ^16.3.1 Environment variable management

Infrastructure

Service Role
MongoDB Atlas Cloud-hosted database
Supabase Storage Beat audio file hosting
Vercel Next.js frontend deployment
Render Express backend deployment

πŸ“ Repository Structure

rex-labs/
β”œβ”€β”€ client/                        # Next.js 14 frontend (App Router)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/                   # App Router pages
β”‚   β”‚   β”‚   β”œβ”€β”€ page.js            # Homepage (Hero, Showcase, Studio Gallery)
β”‚   β”‚   β”‚   β”œβ”€β”€ beats/             # Beat store listing page
β”‚   β”‚   β”‚   β”œβ”€β”€ book/              # Session booking page
β”‚   β”‚   β”‚   β”œβ”€β”€ about/             # About page
β”‚   β”‚   β”‚   β”œβ”€β”€ contact/           # Contact / enquiry form
β”‚   β”‚   β”‚   β”œβ”€β”€ enquiry/           # Enquiry submission page
β”‚   β”‚   β”‚   β”œβ”€β”€ location/          # Studio location page
β”‚   β”‚   β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ login/         # Admin login page
β”‚   β”‚   β”‚   β”‚   └── dashboard/     # Admin dashboard (beats, sessions, enquiries)
β”‚   β”‚   β”‚   β”œβ”€β”€ privacy-policy/
β”‚   β”‚   β”‚   β”œβ”€β”€ refund-policy/
β”‚   β”‚   β”‚   β”œβ”€β”€ shipping-policy/
β”‚   β”‚   β”‚   └── terms/
β”‚   β”‚   β”œβ”€β”€ components/            # Reusable UI components (Hero, NavBar, etc.)
β”‚   β”‚   β”œβ”€β”€ context/               # React context providers
β”‚   β”‚   β”œβ”€β”€ providers.js           # ThemeProvider & global wrappers
β”‚   β”‚   └── utils/                 # Utility helpers (API clients, formatters)
β”‚   β”œβ”€β”€ public/                    # Static assets (studio images, DAW logos)
β”‚   β”œβ”€β”€ next.config.mjs
β”‚   β”œβ”€β”€ tailwind.config.js
β”‚   └── vercel.json                # Vercel deployment config
β”‚
β”œβ”€β”€ server/                        # Express.js REST API
β”‚   β”œβ”€β”€ controllers/               # Route handler logic
β”‚   β”‚   β”œβ”€β”€ authController.js      # Register / Login
β”‚   β”‚   β”œβ”€β”€ beatController.js      # Beat CRUD
β”‚   β”‚   β”œβ”€β”€ sessionController.js   # Session booking CRUD
β”‚   β”‚   β”œβ”€β”€ enquiryController.js   # Enquiry management
β”‚   β”‚   └── paymentController.js   # Razorpay order & verification
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”œβ”€β”€ authMiddleware.js      # JWT protect + admin role guard
β”‚   β”‚   └── errorMiddleware.js     # Centralised error handler
β”‚   β”œβ”€β”€ models/                    # Mongoose schemas
β”‚   β”‚   β”œβ”€β”€ User.js
β”‚   β”‚   β”œβ”€β”€ Beat.js
β”‚   β”‚   β”œβ”€β”€ Session.js
β”‚   β”‚   β”œβ”€β”€ Order.js
β”‚   β”‚   └── Enquiry.js
β”‚   β”œβ”€β”€ routes/                    # Express routers
β”‚   β”‚   β”œβ”€β”€ authRoutes.js
β”‚   β”‚   β”œβ”€β”€ beatRoutes.js
β”‚   β”‚   β”œβ”€β”€ sessionRoutes.js
β”‚   β”‚   β”œβ”€β”€ enquiryRoutes.js
β”‚   β”‚   └── paymentRoutes.js
β”‚   β”œβ”€β”€ seeder.js                  # DB seed script (admin user + sample beats)
β”‚   β”œβ”€β”€ server.js                  # Entry point, DB connection, middleware setup
β”‚   └── render.yaml                # Render.com deployment config
β”‚
β”œβ”€β”€ dev-start.bat                  # Windows dev launcher (runs both servers)
β”œβ”€β”€ package.json                   # Root: concurrently runs client + server
└── README.md

πŸ—οΈ Core Architecture

Rex Labs follows a monorepo, decoupled full-stack architecture. The frontend and backend are developed and deployed independently but communicate over a JSON REST API.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Browser                    β”‚
β”‚            Next.js 14 App Router            β”‚
β”‚   (Vercel β†’ https://rexlab.vercel.app)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚ HTTPS / Axios (JSON)
              β”‚ CORS whitelist: localhost:3000,
              β”‚   *.vercel.app
              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          Express REST API (Node.js)          β”‚
β”‚   (Render β†’ https://rexlab.onrender.com)    β”‚
β”‚                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  Auth    β”‚  β”‚ Beats  β”‚  β”‚  Sessions  β”‚  β”‚
β”‚  β”‚ /api/    β”‚  β”‚ /api/  β”‚  β”‚  /api/     β”‚  β”‚
β”‚  β”‚  users   β”‚  β”‚  beats β”‚  β”‚  sessions  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚Enquiries β”‚  β”‚       Payment            β”‚ β”‚
β”‚  β”‚/api/     β”‚  β”‚  /api/payment/order      β”‚ β”‚
β”‚  β”‚enquiries β”‚  β”‚  /api/payment/verify     β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚              β”‚
           β–Ό              β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ MongoDB Atlasβ”‚  β”‚   Supabase   β”‚
  β”‚  (documents) β”‚  β”‚   Storage    β”‚
  β”‚              β”‚  β”‚ (audio/WAV)  β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Payment Flow:

  1. Client calls POST /api/payment/order β†’ server creates a Razorpay order (amount in paise, currency INR) and saves a pending Order record to MongoDB.
  2. Client renders the Razorpay checkout modal using the returned orderId and key.
  3. On payment success, client calls POST /api/payment/verify with razorpay_order_id, razorpay_payment_id, and razorpay_signature.
  4. Server recomputes the expected HMAC-SHA256 signature. If it matches, the Order is updated to paid status.

πŸ—„οΈ Database Schema

users

Field Type Constraints
username String Required, Unique
email String Required, Unique, Lowercase
password String Required, bcrypt hashed (salt: 10)
role String Enum: admin, client (default: client)
createdAt Date Default: Date.now

beats

Field Type Notes
title String Required
audioUrl String Required β€” preview MP3 (Supabase)
highResUrl String Optional β€” WAV/ZIP download link (Supabase)
coverArtUrl String Optional cover image
price Number Required (INR)
genre String Required
mood String Optional
bpm Number Optional
duration String e.g., "3:45"
isSold Boolean Default: false
plays Number Default: 0
downloads Number Default: 0

sessions

Field Type Notes
clientName String Required
clientEmail String Required, Lowercase
clientPhone String Required
date Date Required
timeSlot String e.g., "14:00 - 18:00"
sessionType String Enum: Full Recording, Audio / Instrumental, Vocals Recording, Mixing & Mastering, Custom
notes String Optional
status String Enum: pending, booked, completed, cancelled
paymentStatus String Enum: pending, advance_paid, full_paid

orders

Field Type Notes
user ObjectId (ref: User) Optional (guest checkout supported)
items[] Array `{ name, price, itemType: Beat
totalAmount Number Required
razorpayOrderId String Required, Unique
razorpayPaymentId String Populated post-verification
razorpaySignature String Populated post-verification
status String Enum: pending, paid, failed

enquiries

Field Type Notes
name String Required
email String Required, Lowercase
message String Required
status String Enum: new, read, replied

πŸ” Security

Mechanism Implementation
Password Hashing bcryptjs with salt rounds of 10 via a Mongoose pre-save hook
JWT Auth jsonwebtoken β€” Bearer tokens validated in authMiddleware.js
Role Guard admin middleware checks req.user.role === 'admin' before allowing write operations
Payment Verification HMAC-SHA256 signature recomputed server-side using RAZORPAY_KEY_SECRET; signatures are compared before marking an order as paid
CORS Policy Whitelist restricts origins to localhost:3000, rexlab.vercel.app, rexlabs.vercel.app, and all *.vercel.app preview URLs
Error Handling Centralised notFound + errorHandler middleware prevents stack trace leakage to clients

πŸš€ Local Development Setup

Prerequisites

  • Node.js v18 or higher
  • MongoDB Atlas account with a cluster URI
  • Razorpay account (test mode key pair)
  • Supabase project with Storage configured

1. Clone & Install

git clone https://github.com/Artyologist/rexlab.git
cd rexlab

# Install all dependencies (root + client + server)
npm run install-all

2. Configure Environment Variables

server/.env

PORT=5000
NODE_ENV=development
MONGODB_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/rexlabs
JWT_SECRET=your_super_secret_jwt_key

# Razorpay (Test Mode)
RAZORPAY_KEY_ID=rzp_test_xxxxxxxxxx
RAZORPAY_KEY_SECRET=your_razorpay_secret

# Supabase
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your_supabase_service_role_key

client/.env.local

NEXT_PUBLIC_API_URL=http://localhost:5000/api
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key

3. Seed the Database

Creates an admin user (admin@rexlabs.com / password123) and sample beats:

cd server
npm run data:import

To wipe the seed data:

npm run data:destroy

4. Run Development Servers

Option A β€” Windows (Recommended):

.\dev-start.bat

Option B β€” Concurrent (from root):

npm start

Option C β€” Separate terminals:

# Terminal 1
cd server && npm run dev   # http://localhost:5000

# Terminal 2
cd client && npm run dev   # http://localhost:3000

5. Admin Access

URL Credentials
http://localhost:3000/admin/login admin@rexlabs.com / password123

πŸ“Š Project Stats

Metric Value
API Endpoints 15 (Auth: 2, Beats: 5, Sessions: 5, Enquiries: 4, Payment: 2 β€” see routes)
Mongoose Models 5 (User, Beat, Session, Order, Enquiry)
Frontend Pages 12 (Home, Beats, Book, About, Contact, Enquiry, Location, Admin Login, Admin Dashboard, Privacy, Refund, Terms)
Frontend Deployment Vercel (Next.js managed)
Backend Deployment Render.com (Node web service, port 10000)
Database MongoDB Atlas (cloud)
File Storage Supabase Storage
UI Framework Next.js 14 App Router
Auth Strategy Stateless JWT (Bearer token)

πŸ“„ License

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


Built with 🎡 by Rex Labs

About

MERN + Next.js 14 studio platform with beat marketplace streaming, automated Razorpay order verification, calendar booking, and Supabase cloud storage.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages