This is a web application built with Next.js for managing Outpatient Department (OPD) activities in a hospital. The application allows for scheduling appointments, managing patient records, and providing an interface for doctors and staff to handle daily operations efficiently.
- Next.js: React framework for server-rendered applications.
- JavaScript: Main programming language.
- CSS: Styling of the application.
- Node.js: Backend server.
- MongoDB: Database for storing patient records and appointments.
- Clone the repository:
git clone https://github.com/yhimanshu22/hospital-opd.git- Navigate to the project directory:
cd hospital-opd- Install dependencies:
npm install- Set up environment variables:
Create a .env.local file in the root directory and add the following variables:
# Database (use either name — the app reads both)
MONGO_URI=<your_mongodb_connection_string>
# or: MONGODB_URI=<your_mongodb_connection_string>
# Required for sign-in (JWT cookie)
JWT_SECRET=<a_long_random_string>
NEXT_PUBLIC_API_KEY=<your_api_key>- Start the development server:
npm run dev- Open http://localhost:3000 in your browser to see the application.
Do this in the MongoDB Atlas UI (it cannot be done from this repo alone).
-
Use a current connection string
Database → your cluster → Connect → Drivers → copy themongodb+srv://...URI. Replace<password>with your database user password.
If tools reportNon-existent domain/querySrv ENOTFOUNDfor your hostname, the cluster was removed/renamed or the URI is outdated—copy a fresh URI from Atlas, do not reuse an old host. Network Access (0.0.0.0/0) does not fix a hostname that does not exist in DNS—you must replaceMONGO_URIwith the host Atlas shows today, then update Vercel → Environment Variables and Redeploy. -
Network Access (allow Vercel / the internet)
Network Access → Add IP Address → choose Allow Access from Anywhere → enter0.0.0.0/0→ Confirm. Wait until the entry is Active (about one minute).
(Tighter IP lists are possible but do not work well with Vercel’s changing outbound IPs unless you use Atlas–Vercel integration or Private Endpoint.) -
Database user
Database Access → ensure a user exists with a known password and Read and write to any database (or appropriate custom role) → password must match what you put in the URI. -
Cluster not paused
On M0/M2/M5, open the cluster and Resume if Atlas shows it paused. -
Vercel
Vercel project → Settings → Environment Variables → setMONGO_URIorMONGODB_URIfor Production (and Preview if you use preview URLs) → Redeploy the latest deployment.
Contributions are welcome! Please fork the repository and create a pull request with your changes.









