TutorByte Backend is the core REST API that powers the TutorByte platform. It is built using modern web technologies focused on performance, security, and scalability. It provides functionality for robust user authentication, tutor booking management, availability scheduling, payment processing, and administrative controls.
- Language: TypeScript
- Framework: Express.js (Node.js)
- Database: PostgreSQL
- ORM: Prisma
- Authentication: Better Auth (with JWT & bcrypt enhancements)
- Payment Processing: Stripe & SslCommerz
- File Uploads & Media Storage: Multer + Cloudinary
- Scheduling/Cron Jobs:
node-cron - Validation: Zod
- Role-Based Access Control: Secure routes structured around Students, Tutors, and Admins.
- Tutor Profiles & Search: Browse, filter, and fetch detailed tutor profiles, subjects, and language metadata.
- Booking & Availability System: Real-time scheduling with checking against tutor's set availability.
- Multi-Gateway Payment Integration: Seamless processing using both Stripe and SslCommerz.
- Cloud Media Storage: Direct image/file uploads straight to Cloudinary using secure middleware.
Follow these steps to set up the backend locally:
- Node.js (v18 or higher)
- PostgreSQL
- Stripe Account (for payments)
- Cloudinary Account (for media)
-
Clone the repository (if applicable):
git clone https://github.com/abubakar308/TutorByte-Backend cd TutorByte-backend -
Install dependencies:
npm install
-
Environment Setup: Create a
.envfile in the root directory and add the necessary configuration parameters. (EnsureDATABASE_URL,STRIPE_SECRET_KEY,CLOUD_NAME,CLOUD_API_KEY,CLOUD_API_SECRET, and other relevant keys are set). -
Initialize Prisma (Database push & Client generation):
npx prisma db push npx prisma generate
-
Start the development server:
npm run dev
TutorByte Backend adheres to a standardized JSON response structure for successful API requests.
Standard Success Response:
{
"httpStatusCode": 200, // or 201 for Created
"success": true,
"message": "Dynamic success message describing the action",
"data": {
// Requested data or newly created resource payload
}
}| Status Code | Type | Description |
|---|---|---|
| 200 OK | Success | Request succeeded and data is returned. |
| 201 Created | Success | A new resource (e.g., User, Booking) has been created successfully. |
| 400 Bad Request | Error | Missing required fields, validation error (Zod), or bad syntax. |
| 401 Unauthorized | Error | Missing, invalid, or expired authentication token. |
| 403 Forbidden | Error | User lacks sufficient role permissions to access the resource. |
| 404 Not Found | Error | The requested resource (User, Tutor, Subject, etc.) does not exist. |
| 500 Internal Server Error | Error | Unhandled backend exception or database connectivity issue. |
(Note: Validation errors may surface an array of errorMessages to distinctly clarify each missing or improperly formatted field).
The baseline API endpoint is /api/v1.
POST /api/auth/*- Complete auth handling powered by Better Auth.GET/POST /api/v1/tutors- Tutor discovery and management.GET/POST /api/v1/users- Student/User operations.GET/POST /api/v1/bookings- Scheduling logic and endpoints.GET/POST /api/v1/availability- Tutor's timeslot availability routing.GET/POST /api/v1/payments- Processing, Webhooks for Stripe and SslCommerz integration.GET/POST /api/v1/admin- Privileged administrative operations.GET/POST /api/v1/subject- Subject categorization.GET/POST /api/v1/language- Language metadata parsing.
npm run dev: Runs the backend in watch mode usingtsx.npm run build: Generates Prisma typing and builds the TypeScript application usingtsuptargeting Node 20.npm start: Runs the built application from thedist/server.jsfolder.npm run postinstall: Generates the Prisma schema automatically upon package installation.