DocFinder — Specialist Doctor & Chamber Finder REST API

A fast RESTful backend API built with Node.js (v20+), Express 5, and plain parameterized SQL on PostgreSQL (`pg`) that helps patients in Bangladesh discover verified medical specialists and nearby visiting chambers from disease symptoms and location. Features symptom-to-specialty resolution with English and Bengali disease aliases, spherical Haversine geo-distance search with bounding-box indexing, 3-role JWT RBAC (Patient, Doctor, Admin), BMDC verification workflows, and interactive Swagger OpenAPI 3.0 documentation across 19 endpoints.
Main Technology Stack
Node.js 20+Express 5PostgreSQLPlain SQL (pg)ZodJWT & bcryptSwagger / OpenAPI 3.0express-rate-limitPostmanVercel ServerlessESLint
Key Contributions
- Engineered a 19-endpoint modular REST API using Express 5 and node-postgres (`pg`) with zero ORM overhead, strict Zod payload/query/env validation, and explicit ACID multi-table transactions via `withTransaction`.
- Built a multi-step geo-aware doctor & chamber search engine (`GET /api/search/doctors`) combining disease-to-specialty mapping, 3-tier location resolution (query GPS → Chattogram areas lookup → saved user profile), bounding-box indexing (`idx_chambers_location`), and spherical Haversine distance calculation with fee and weekday filters.
- Implemented disease autocomplete (`GET /api/diseases`) matching both English medical terms and Bengali symptom aliases alongside pre-seeded relational fixtures (12 areas, 12 specialties, 30 diseases, and 40 sample doctors).
- Constructed 3-tier Role-Based Access Control (USER, DOCTOR, ADMIN) using JWT Bearer auth, bcrypt password hashing, authentication rate limiting, BMDC registration validation, and admin approval/rejection safeguards ensuring unverified doctors never surface in public search results.
- Authored interactive OpenAPI 3.0 Swagger UI documentation (`/api-docs`) powered by a pre-compiled JSON spec and CDN assets for reliable Vercel serverless deployment, paired with structured global PostgreSQL error mapping (SQLSTATE `23505`, `23503`, `22P02`, `23514`).
Challenges Faced
- Computing accurate proximity distances and filtering open weekday consultation chambers without PostGIS dependencies. Solved with a PostgreSQL lat/lng bounding-box pre-filter (`lat ± radius / 111`) paired with spherical Haversine distance ordering.
- Serving interactive Swagger UI static assets reliably inside Vercel's serverless runtime where local `swagger-jsdoc` glob resolution and static bundles can fail. Solved by compiling `swaggerSpec.json` ahead of time and loading Swagger UI bundles via CDN.
- Guaranteeing public search visibility safety across doctor onboarding states so `PENDING` or `REJECTED` accounts can manage profiles privately while remaining hidden from patient search and public doctor detail queries.
Potential Improvements and Future Plans
- Upgrade spatial proximity search from spherical Haversine SQL to native PostGIS geometry points for high-volume polygon and multi-city queries.
- Introduce Redis caching for disease autocomplete lookups and high-traffic specialty search results.
- Add verified patient reviews, real-time chamber appointment queue booking, and automated OTP/password-reset email workflows.