Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/harshalw2003/BidAuc/llms.txt

Use this file to discover all available pages before exploring further.

BidAuc is a Node.js/Express REST API backed by MongoDB. The server exposes five route groups — users, jobs, bids, categories, and a dashboard — protected by a JWT middleware that reads a token from an httpOnly cookie. Two user roles, Seeker and Provider, drive all permission logic. A job moves through a defined lifecycle from creation to completion, and every state transition is recorded on the Job document.

Tech stack

LayerTechnologyPurpose
RuntimeNode.jsServer-side JavaScript execution
FrameworkExpressHTTP routing and middleware pipeline
DatabaseMongoDB 4+Document storage for users, jobs, bids, and categories
ODMMongooseSchema definition and query interface
AuthenticationJSON Web Tokens (JWT)Stateless session tokens stored in httpOnly cookies
OTP deliveryTwilioSMS-based one-time password for phone verification
File uploadsMultermultipart/form-data handling for profile pictures and job images
PaymentsRazorpaySubscription and transaction processing
Password hashingbcryptSecure credential storage
The server listens on port 5000 by default. MongoDB is expected at mongodb://localhost:27017/BidAuc.

System architecture

The application is organized into four layers that handle every request in sequence.
Client request


┌─────────────────────────────┐
│  Express router (index.js)  │  Mounts /user, /job, /bid, /category, /dashboard
└────────────┬────────────────┘


┌─────────────────────────────┐
│  Middlewares/auth.js        │  Verifies JWT from httpOnly cookie; attaches user to req
└────────────┬────────────────┘


┌─────────────────────────────┐
│  Route handlers             │  Validate input, enforce role-based access
└────────────┬────────────────┘


┌─────────────────────────────┐
│  Mongoose models            │  Read/write User, Job, Bid, Category documents
└────────────┬────────────────┘


         MongoDB

Request lifecycle

1

Route matching

Express matches the incoming URL and HTTP method to a registered route. Routes are mounted in index.js under their respective prefixes (/user, /job, /bid, /category, /dashboard).
2

Authentication check

The authenticateToken middleware in Middlewares/auth.js reads the JWT from the httpOnly cookie. If the token is valid, the decoded payload is attached to req.user and the request proceeds. Invalid or missing tokens return a 401 response immediately.
3

Role authorization

Individual route handlers inspect req.user.role to enforce Seeker-only or Provider-only actions. For example, only a Seeker can create a job; only a Provider can post a bid.
4

Database operation

The handler calls Mongoose methods on the relevant model (User, Job, Bid, or Category). Validation errors from Mongoose schema definitions are caught and returned as structured error responses.
5

Response

The handler returns a JSON response. Successful mutations include the updated document. Errors include a message field describing what went wrong.

Data models

User

Stored in the users collection. A single user document covers both roles; the role field determines which features are accessible.
FieldTypeNotes
userName.firstNameStringRequired
userName.lastNameStringRequired
phoneNumberNumberUnique; used for OTP login
emailStringRequired; unique
addressStringOptional
businessNameStringProviders only
roleString"Seeker" or "Provider"
profilePictureStringPath to uploaded image via Multer
tokenStringCurrent JWT; invalidated on logout
Subscription_isActiveBooleanRazorpay subscription status

Job

Stored in the jobs collection. Seekers create jobs; Providers bid on them.
FieldTypeNotes
jobNameStringRequired
categoryObjectIdRef: Category
urgencyStringE.g. "Low", "Medium", "High"
imagesStringPath to uploaded job image
descriptionStringRequired
additionalRequirementsStringOptional
postedByObjectIdRef: User (Seeker)
completionStatusString"pending", "completed", or "canceled"
bidStatusString"pending""accepted"
providerObjectIdRef: User (winning Provider)
acceptedBidObjectIdRef: Bid
timePostedDateAuto-set on creation

Bid

Stored in the bids collection. Each bid belongs to one job and one Provider.
FieldTypeNotes
jobObjectIdRef: Job
offerPriceNumberRequired; Provider’s quoted price
descriptionStringProvider’s proposal text
postedByObjectIdRef: User (Provider)
statusString"unaccepted" (default) or "accepted"
timePostedDateAuto-set on creation

Category

Stored in the categories collection. Categories are pre-seeded and used to classify jobs.
FieldTypeNotes
categoryNameStringRequired; unique
imageStringPath to category icon or image

Job lifecycle

Every job follows a linear state machine driven by Seeker and Provider actions.
Job created (bidStatus: "unaccepted", completionStatus: "pending")

        │  Providers submit bids via POST /bid/post

Seeker reviews bids via POST /bid/getOneJobBids

        │  Seeker calls POST /bid/acceptedBids

bidStatus: "accepted"
provider and acceptedBid set on Job document

        ├──────────────────────────────┐
        │  Seeker calls markAsCompleted│  Seeker calls cancelSeekerJob
        ▼                              ▼
completionStatus: "completed"     completionStatus: "canceled"
(job closed successfully)
Once a Seeker accepts a bid, the bidStatus on the job is set to "accepted" and the job is no longer visible to other Providers for bidding. Ensure the Seeker has reviewed all bids before accepting.

Authentication flow

BidAuc uses OTP-based phone authentication rather than passwords. This eliminates password-reset flows and reduces credential exposure.
1

Request OTP

The client posts a phone number to /user/generateOtp. The server uses Twilio to deliver a time-limited code via SMS.
2

Verify and issue token

The client submits the OTP to /user/register (new users) or /user/login (returning users). The server validates the OTP, signs a JWT with the user’s _id and role, and writes it to an httpOnly cookie.
3

Authenticated requests

Every subsequent request carries the cookie automatically. Middlewares/auth.js verifies the JWT on each protected route and attaches the decoded payload to req.user.
4

Logout

Calling /user/logout clears the cookie and invalidates the stored token on the User document.
Because the JWT is stored in an httpOnly cookie, it is inaccessible to JavaScript running in the browser, which reduces exposure to XSS attacks.

Route overview

PrefixRouter fileKey responsibilities
/userRoutes/userRoutes.jsOTP, register, login, logout, profile, picture upload
/jobRoutes/jobRoutes.jsCreate, list, filter by Seeker/Provider, job detail
/bidRoutes/bidRoutes.jsPost bid, list bids for a job, accept bid
/categoryRoutes/categoryRoutes.jsList all categories, get single category
/dashboardAggregated views for Seeker and Provider dashboards

Core concepts

Deep dive into Seeker and Provider roles, permissions, and how the bidding system works.

API reference

Complete endpoint documentation with request and response examples.

Build docs developers (and LLMs) love