Skip to content

Repository files navigation

FixItNow - On-Demand Service Marketplace Backend

FixItNow is a production-ready, highly secure, and scalable on-demand service marketplace backend. It enables customers to find and book professional technicians for various services, allows technicians to manage their availability and bookings, and provides an admin dashboard for full platform oversight.


πŸ“¦ Submission Details

Item Value
Backend Repo https://github.com/Sumayea104/fixitnow-backend
Live API https://fixitnow-backend-m1ur.onrender.com
API Docs https://fixitnow-backend-m1ur.onrender.com/api-docs
Postman Collection https://github.com/Sumayea104/fixitnow-backend/blob/main/postman/FixItNow.postman_collection.json
Admin Email admin@fixitnow.com
Admin Password admin123
Demo Video 🎬

⚠️ These credentials are for testing and demonstration only.


πŸš€ Tech Stack

Technology Purpose
Runtime: Node.js (v18+ or v20+)
Framework: Express.js with TypeScript
Database: PostgreSQL (Neon)
ORM: Prisma ORM
Security: Helmet, CORS, bcrypt, JSON Web Token (JWT)
Validation: Zod
Logger: Morgan
Payment: Stripe & SSLCommerz

πŸ“‚ Project Architecture

The project follows a Modular Architecture for scalability and clean separation of concerns:

fixitnow-backend/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ env.ts
β”‚   β”‚   └── prisma.ts
β”‚   β”œβ”€β”€ constants/
β”‚   β”‚   └── index.ts
β”‚   β”œβ”€β”€ errors/
β”‚   β”‚   └── AppError.ts
β”‚   β”œβ”€β”€ interfaces/
β”‚   β”‚   └── index.ts
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”œβ”€β”€ auth.ts
β”‚   β”‚   β”œβ”€β”€ errorHandler.ts
β”‚   β”‚   β”œβ”€β”€ role.ts
β”‚   β”‚   └── validate.ts
β”‚   β”œβ”€β”€ modules/
β”‚   β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   β”‚   β”œβ”€β”€ admin.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ admin.route.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ admin.service.ts
β”‚   β”‚   β”‚   └── admin.validation.ts
β”‚   β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.route.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.service.ts
β”‚   β”‚   β”‚   └── auth.validation.ts
β”‚   β”‚   β”œβ”€β”€ booking/
β”‚   β”‚   β”‚   β”œβ”€β”€ booking.constant.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ booking.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ booking.interface.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ booking.route.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ booking.service.ts
β”‚   β”‚   β”‚   └── booking.validation.ts
β”‚   β”‚   β”œβ”€β”€ category/
β”‚   β”‚   β”‚   β”œβ”€β”€ category.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ category.route.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ category.service.ts
β”‚   β”‚   β”‚   └── category.validation.ts
β”‚   β”‚   β”œβ”€β”€ payment/
β”‚   β”‚   β”‚   β”œβ”€β”€ payment.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ payment.route.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ payment.service.ts
β”‚   β”‚   β”‚   └── payment.validation.ts
β”‚   β”‚   β”œβ”€β”€ review/
β”‚   β”‚   β”‚   β”œβ”€β”€ review.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ review.route.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ review.service.ts
β”‚   β”‚   β”‚   └── review.validation.ts
β”‚   β”‚   β”œβ”€β”€ service/
β”‚   β”‚   β”‚   β”œβ”€β”€ service.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ service.route.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ service.service.ts
β”‚   β”‚   β”‚   └── service.validation.ts
β”‚   β”‚   β”œβ”€β”€ technician/
β”‚   β”‚   β”‚   β”œβ”€β”€ technician.controller.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ technician.route.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ technician.service.ts
β”‚   β”‚   β”‚   └── technician.validation.ts
β”‚   β”‚   └── user/
β”‚   β”‚       β”œβ”€β”€ user.controller.ts
β”‚   β”‚       β”œβ”€β”€ user.route.ts
β”‚   β”‚       β”œβ”€β”€ user.service.ts
β”‚   β”‚       └── user.validation.ts
β”‚   β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ app.ts
β”‚   └── server.ts
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma
β”‚   └── prisma.config.ts
β”œβ”€β”€ .env
β”œβ”€β”€ .gitignore
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ package.json
β”œβ”€β”€ README.md
└── tsconfig.json

Security Features Implemented

  • Helmet: Secure HTTP headers to prevent common vulnerabilities
  • CORS: Configured cross-origin resource sharing
  • Data Validation: Runtime request schema validation enforced via Zod
  • Password Hashing: Secure cryptography with bcrypt
  • Role-Based Access Control (RBAC): Strict endpoint protection based on authorization roles (Admin, Customer, Technician)
  • JWT Authentication: Stateless authentication with JSON Web Tokens
  • Environment Variables: Secure configuration management

πŸ“š API Endpoints

Base URL: https://fixitnow-backend-m1ur.onrender.com


πŸ”‘ Authentication

Method Endpoint Description
POST /api/auth/register Register a new user
POST /api/auth/login User login
GET /api/auth/me Get current logged-in user details

πŸ‘€ Users

Method Endpoint Description Access
GET /api/users/profile Get current user profile Private
PUT /api/users/profile Update user profile Private
PATCH /api/users/change-password Change user password Private
GET /api/users Get all users Admin
GET /api/users/:id Get user by ID Admin
PATCH /api/users/:id/status Update user status Admin

πŸ‘‘ Admin

Method Endpoint Description
GET /api/admin/dashboard/stats Get platform dashboard statistics
GET /api/admin/users Get all users with filters
GET /api/admin/users/:id Get user details by ID
PATCH /api/admin/users/:id/status Update user status
POST /api/admin/categories Create a new service category
GET /api/admin/categories Get all categories
PATCH /api/admin/categories/:id Update a category
DELETE /api/admin/categories/:id Delete a category

πŸ› οΈ Technicians

Method Endpoint Description
GET /api/technicians Get all technicians with filters
GET /api/technicians/:id Get technician profile by ID
PUT /api/technicians/profile Update technician profile
PUT /api/technicians/availability Update technician availability slots
GET /api/technicians/bookings Get technician's bookings
PATCH /api/technicians/bookings/:id Update booking status
GET /api/technicians/stats Get technician statistics

πŸ“… Bookings

Method Endpoint Description
POST /api/bookings Create a new booking
GET /api/bookings Get current user's bookings
GET /api/bookings/:id Get booking details by ID
PATCH /api/bookings/:id/cancel Cancel a booking
PATCH /api/bookings/:id/status Update booking status (Technician only)

πŸ’³ Payments

Method Endpoint Description
POST /api/payments/create Create a payment
GET /api/payments Get payment history
GET /api/payments/:id Get payment details
PATCH /api/payments/confirm/:id Confirm payment

⭐ Reviews

Method Endpoint Description
GET /api/reviews Get all reviews with filters
POST /api/reviews Create a review
GET /api/reviews/:id Get review details by ID
PATCH /api/reviews/:id Update a review
DELETE /api/reviews/:id Delete a review
GET /api/reviews/technician/:technicianId Get all reviews for a technician
POST /api/reviews/:id/helpful Mark a review as helpful
POST /api/reviews/:id/reply Reply to a review

πŸ’‘ Challenges & Key Learnings

πŸš€ Technical Challenges & Solutions

  1. Dual Payment Gateway Integration (Stripe & SSLCommerz):

    • Challenge: Integrating both Stripe and SSLCommerz required managing distinct transaction flows, payload structures, and webhook handlers for international and local currency payments seamlessly.
    • Solution: Designed a unified payment service module with isolated routing logic and dedicated webhook listeners to process real-time status updates from both gateways securely.
  2. Role-Based Routing & Security (RBAC):

    • Challenge: Restricting route access cleanly across three distinct user roles (Customer, Technician, and Admin) without repetitive permission logic.
    • Solution: Implemented a strict, middleware-driven Role-Based Access Control (RBAC) layer (verifyToken, verifyAdmin, verifyTechnician) that validates JWTs and authorizes requests based on user roles before reaching controller logic.
  3. Prisma Client & Vercel Deployment Issues:

    • Challenge: Initially deploying the backend on Vercel caused database connection failures as the Prisma Client wasn't generated during the automated build phase.
    • Solution: Resolved the deployment issue by configuring a custom pre-build script ("vercel-build": "prisma generate && tsc -b") in package.json, ensuring schema generation occurs prior to TypeScript compilation.
  4. Automating Authentication with Cookie-Parser Migration:

    • Challenge: Replaced tedious manual Authorization: Bearer <token> token copy-pasting during Postman testing and frontend integration by migrating to secure HTTP-Only Cookies.
    • Solution: Integrated cookie-parser on the backend so that JWTs are automatically injected and stored in client storage upon login, securing the authentication flow and protecting against XSS attacks.

πŸ“š Key Learnings

  • Multi-Gateway Architecture: Learned how to architect modular payment handlers that cleanly separate localized payment logic (SSLCommerz) from global standards (Stripe).

  • CI/CD & Deployment Configurations: Gained hands-on experience troubleshooting build-time environment dependencies, database ORM client generation, and cloud deployment pipelines.

  • Modern Web Security Practices: Practical knowledge in hardening authentication with HTTP-Only cookies, CORS policies, and strict role-based authorization layers.


πŸ“š API Documentation

πŸ”‘ Admin Credentials

Credential Value
Email admin@fixitnow.com
Password admin123

⚠️ These credentials are for testing and demonstration only.


🌐 Live API


πŸ§ͺ Testing

Test API with cURL

# Health Check
curl https://fixitnow-backend-m1ur.onrender.com/health

# Register User
curl -X POST https://fixitnow-backend-m1ur.onrender.com/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"test@example.com","password":"password123","name":"Test User","role":"CUSTOMER"}'

# Login
curl -X POST https://fixitnow-backend-m1ur.onrender.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"test@example.com","password":"password123"}'

Test with Postman

Import the Postman collection from [postman/FixItNow.postman_collection.json](https://documenter.getpostman.com/view/55163778/2sBY4SNK1v)


🀝 Contributing

  1. Fork the repository
  2. Create a 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

πŸ‘¨β€πŸ’» Developer


πŸ“ž Support

For any questions or issues, please open an issue or contact the developer.


⭐ Show Your Support

If you found this project helpful, please give it a ⭐ on GitHub!


About

A modular and robust Node.js backend API built with TypeScript and Express for a home services marketplace. It features distinct role-based permissions (Customer, Technician, Admin), service booking management with dynamic status handling, and integrated secure payment processing via Stripe and SSLCommerz.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages