agent files
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
vaxtrack-backend/*
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
I am working on a full-stack MERN (MongoDB, Express, React, Node.js) web application for tracking vaccination schedules. We are a team of 4, and I need you to act as our Lead Developer.
|
||||
|
||||
Here is the full context of the project. Please memorize this architecture and constraints before answering my request.
|
||||
|
||||
### **1. Project Overview**
|
||||
* **Name:** "Vax-Track" (Vaccination Management System).
|
||||
* **Users:** Admins (Government), Hospital Staff, and Public Citizens (Parents/Guardians).
|
||||
* **Core Feature:** A "Family/Dependent" architecture where one registered User (Parent) can manage vaccination records and appointments for multiple Dependents (Children/Elders).
|
||||
|
||||
### **2. Tech Stack & Architecture**
|
||||
* **Backend:** Node.js with Express.js.
|
||||
* **Database:** MongoDB (NoSQL) using Mongoose ODM.
|
||||
* **Auth:** JWT (JSON Web Tokens) with role-based middleware (Admin, Staff, User).
|
||||
* **Architecture:** Monolithic Repo but with "Microservice-style" modular folders. Each module has its own Controllers, Routes, and Models.
|
||||
|
||||
### **3. Team Roles & Responsibilities (STRICT SEPARATION)**
|
||||
We must keep our code contributions distinct to get individual marks. Do not mix these responsibilities when generating code.
|
||||
|
||||
* **Minidu (Inventory & Family Identity):**
|
||||
* **Features:** User Auth, Adding Dependents (Child/Spouse), Managing Vaccine Brands, Managing Stock Batches.
|
||||
* **3rd Party API:** Cloudinary (for uploading vaccine vial images).
|
||||
* **Key Models:** `User`, `Dependent`, `Vaccine`, `Batch`.
|
||||
|
||||
* **Nethmi (Locations & Scheduling):**
|
||||
* **Features:** Registering Hospitals, Creating Clinic Dates/Events, Managing Capacity.
|
||||
* **3rd Party API:** LocationIQ or Mapbox (converts address strings to Lat/Long coordinates).
|
||||
* **Key Models:** `Hospital`, `Clinic`.
|
||||
|
||||
* **Saniru (Appointments & Queue):**
|
||||
* **Features:** Booking Appointments (checking quota), Canceling, Viewing Schedule.
|
||||
* **Logic:** Must handle booking for "Self" OR "Dependent".
|
||||
* **3rd Party API:** goqr.me API (generates QR code for appointment pass).
|
||||
* **Key Models:** `Appointment`.
|
||||
|
||||
* **Kaveen (Records & Notifications):**
|
||||
* **Features:** Marking patients as "Vaccinated" (Doctor view), Digital Vaccination Card, Email Alerts.
|
||||
* **3rd Party API:** SendGrid or Nodemailer (sends confirmation emails).
|
||||
* **Key Models:** `Record`, `SideEffect`.
|
||||
|
||||
### **4. Database Relationships (The Logic)**
|
||||
* **Users** have 0 or more **Dependents**.
|
||||
* **Appointments** link to a `Clinic` and a `User`. They optionally link to a `Dependent`.
|
||||
* *Logic:* If `dependentId` is null, it's for the User. If set, it's for the child.
|
||||
* **Records** link to a specific `Batch` (for tracking) and a specific `Patient` (User or Dependent).
|
||||
|
||||
### **5. Current Goal**
|
||||
* We are working on **Milestone 1 (Backend Focus)**.
|
||||
* We need RESTful APIs that return JSON.
|
||||
* All endpoints must handle errors gracefully (400, 404, 500).
|
||||
|
||||
---
|
||||
**MY REQUEST:** [TYPE YOUR QUESTION HERE - e.g., "Create the Mongoose schema for Minidu's Vaccine module" or "Write the Controller logic for Saniru's appointment booking"]
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
### **1. The Core Strategy: "Microservices" Approach**
|
||||
|
||||
- **Shared Foundation (Group Task):** Everyone works together on **Day 1** to set up the `User` model, `Auth` middleware (JWT), and MongoDB connection. This is "boilerplate" and doesn't count towards the distinct 4 endpoints.
|
||||
- **Individual Ownership:** Each member owns a specific business domain.
|
||||
|
||||
---
|
||||
|
||||
### **2. Revised Role Allocation (The "Who Does What")**
|
||||
|
||||
### **Member 1: Minidu – Supply Chain & Family Identity**
|
||||
|
||||
- **Core Domain:** Managing the vaccine stocks AND the "Head of Household" logic (adding children/dependents).
|
||||
- **Complexity:** Inventory tracking + Relation mapping (Parent-Child).
|
||||
- **3rd Party API:** **Cloudinary / ImgBB** (Upload images of vaccine vials/branding).
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
| --- | --- | --- |
|
||||
| `POST` | `/api/vaccines` | Add Vaccine (w/ **Image Upload** to Cloudinary). |
|
||||
| `POST` | `/api/batches` | Add Stock Batch (Qty, Expiry). |
|
||||
| `POST` | `/api/users/dependents` | **New:** Add a child/spouse to the logged-in user's account. |
|
||||
| `GET` | `/api/users/dependents` | **New:** List all family members managed by the user. |
|
||||
|
||||
### **Member 2: Nethmi – Clinic & Location Services**
|
||||
|
||||
- **Core Domain:** Managing where and when vaccinations happen.
|
||||
- **Complexity:** Spatial data (Coordinates) + Time Management.
|
||||
- **3rd Party API:** **LocationIQ / Mapbox** (Convert address to Lat/Long coordinates).
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
| --- | --- | --- |
|
||||
| `POST` | `/api/hospitals` | Register Hospital (Auto-fetch **Lat/Lon** from API). |
|
||||
| `POST` | `/api/clinics` | Create a Vaccination Event (Date, Time, Vaccine Type). |
|
||||
| `PUT` | `/api/clinics/:id` | Update capacity (e.g., increase slots). |
|
||||
| `GET` | `/api/clinics/search` | Filter clinics by City or Vaccine Type. |
|
||||
|
||||
### **Member 3: Saniru – Appointment Engine**
|
||||
|
||||
- **Core Domain:** The booking transaction logic (handling quotas).
|
||||
- **Complexity:** Concurrency (preventing double booking) + Handling "Booking for Dependent".
|
||||
- **3rd Party API:** **QR Code API ([goqr.me](http://goqr.me/))** (Generate a unique pass for the appointment).
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
| --- | --- | --- |
|
||||
| `POST` | `/api/appointments` | Book Slot. **Logic:** Handle `dependentId` vs `userId`. Check Quota. Generate **QR**. |
|
||||
| `PUT` | `/api/appointments/:id` | Cancel & Restore Quota to the Clinic. |
|
||||
| `GET` | `/api/appointments/my` | List appointments for **Self AND Family**. |
|
||||
| `GET` | `/api/appointments/clinic/:id` | Admin View: List of people (Names + QR Codes) for a specific day. |
|
||||
|
||||
### **Member 4: Kaveen – Records & Communication**
|
||||
|
||||
- **Core Domain:** Medical history and notifying users.
|
||||
- **Complexity:** State management (Vaccinated vs. Pending) + External Comms.
|
||||
- **3rd Party API:** **SendGrid / EmailJS** (Send confirmations).
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
| --- | --- | --- |
|
||||
| `POST` | `/api/records` | Doctor marks patient as "Vaccinated". **Triggers Email**. |
|
||||
| `GET` | `/api/records/history` | Get full history for **Self AND Dependents**. |
|
||||
| `GET` | `/api/records/due` | Logic: Calculate next dose date based on vaccine rules. |
|
||||
| `POST` | `/api/side-effects` | Log adverse reactions for a specific batch. |
|
||||
|
||||
---
|
||||
|
||||
### **3. Milestone 1 Schedule (Feb 8 - Feb 20)**
|
||||
|
||||
**Internal Target:** Finish by Friday, Feb 20 (gives 1 week buffer before Evaluation 01).
|
||||
|
||||
### **Phase 1: Setup (Days 1-2)**
|
||||
|
||||
- **Dates:** Feb 8-9
|
||||
- **Group:** Git Repo, Express Setup, Mongo Atlas Connection.
|
||||
- **Shared Code:** Write `authController.js` (Register/Login) and `authMiddleware.js`.
|
||||
- **API Keys:** Get keys for Cloudinary, LocationIQ, and SendGrid. Put them in `.env`.
|
||||
|
||||
### **Phase 2: Individual Feature Dev (Days 3-8)**
|
||||
|
||||
- **Dates:** Feb 10-15
|
||||
- **Minidu:** Build `Dependent` model. Implement logic: "Parent ID must match User ID". Implement Image Upload.
|
||||
- **Nethmi:** Build `Hospital` model. Implement Geocoding middleware.
|
||||
- **Saniru:** Build `Appointment` model. Logic: "If `dependentId` exists, save that name, else save User name." Integrate QR API.
|
||||
- **Kaveen:** Build `Record` model. Logic: "When status = Vaccinated, fire email function."
|
||||
|
||||
### **Phase 3: Integration & Testing (Days 9-12)**
|
||||
|
||||
- **Dates:** Feb 16-19
|
||||
- **Crucial Integration:**
|
||||
- Does Saniru's booking subtract from Nethmi's clinic capacity?
|
||||
- Does Kaveen's history show Minidu's vaccine details?
|
||||
- **Testing:** Test the **"Family Flow"**:
|
||||
1. Login as Parent.
|
||||
2. Add Child (Minidu).
|
||||
3. Book Appt for Child (Saniru).
|
||||
4. Doctor marks Child vaccinated (Kaveen).
|
||||
5. Parent checks email (Kaveen).
|
||||
|
||||
---
|
||||
|
||||
### **4. Pre-Submission Checklist (Evaluation 01 Specific)**
|
||||
|
||||
**Group Marks (20%)**
|
||||
|
||||
- [ ] **Architecture Diagram:** Includes the "Dependent" entity logic?
|
||||
- [ ] **Framework Justification:** Slide explaining "Why MongoDB?" -> "Because storing nested family records and varied vaccine attributes is easier in JSON/BSON."
|
||||
|
||||
**Individual Marks (80%) - The "Must Haves"**
|
||||
|
||||
- [ ] **Minidu:** Is the vaccine image hosted on Cloudinary? Can you add a child to a user account?
|
||||
- [ ] **Nethmi:** Does the Hospital registration automatically fill in Lat/Long?
|
||||
- [ ] **Saniru:** Does the appointment response include a valid QR code link? Can you book for a dependent?
|
||||
- [ ] **Kaveen:** Does the email arrive when a record is updated? Does the history endpoint show family data?
|
||||
|
||||
**Code Quality**
|
||||
|
||||
- [ ] **Separation:** Controllers are separate from Routes.
|
||||
- [ ] **Security:** "Dependents" can only be viewed by their own Parent (Middleware check).
|
||||
- [ ] **Validation:** Inputs are validated (e.g., cannot book a date in the past).
|
||||
@@ -0,0 +1,107 @@
|
||||
erDiagram
|
||||
%% SHARED COMPONENT (All Members)
|
||||
%% User Management is central to the system
|
||||
USERS {
|
||||
ObjectId _id PK
|
||||
string name
|
||||
string email
|
||||
string password
|
||||
string role "Admin, HospitalStaff, Public"
|
||||
string nic "National ID"
|
||||
string phone
|
||||
string address
|
||||
date createdAt
|
||||
}
|
||||
|
||||
%% MODULE 1: VACCINE SUPPLY CHAIN (Minidu)
|
||||
%% Manages the abstract vaccine types and specific physical batches
|
||||
VACCINE {
|
||||
ObjectId _id PK
|
||||
string name "e.g., Pfizer, Sinopharm"
|
||||
string manufacturer
|
||||
string description
|
||||
int dosesRequired
|
||||
int daysBetweenDoses
|
||||
string imageUrl "Cloudinary URL"
|
||||
}
|
||||
|
||||
BATCH {
|
||||
ObjectId _id PK
|
||||
ObjectId vaccineId FK
|
||||
ObjectId hospitalId FK
|
||||
string batchNumber
|
||||
int quantity
|
||||
date expiryDate
|
||||
date arrivalDate
|
||||
string status "Available, Expired, Depleted"
|
||||
}
|
||||
|
||||
%% MODULE 2: CLINIC MANAGEMENT (Nethmi)
|
||||
%% Manages the physical locations and time slots
|
||||
HOSPITAL {
|
||||
ObjectId _id PK
|
||||
string name
|
||||
string district
|
||||
string city
|
||||
object location "Lat/Lng from LocationIQ"
|
||||
string contactNumber
|
||||
string type "Govt, Private"
|
||||
}
|
||||
|
||||
CLINIC {
|
||||
ObjectId _id PK
|
||||
ObjectId hospitalId FK
|
||||
ObjectId vaccineId FK
|
||||
date date
|
||||
string timeSlot "08:00-12:00"
|
||||
int maxCapacity
|
||||
int currentBookings
|
||||
string status "Scheduled, Active, Completed, Cancelled"
|
||||
}
|
||||
|
||||
%% MODULE 3: APPOINTMENT ENGINE (Saniru)
|
||||
%% Manages the booking transaction and queue
|
||||
APPOINTMENT {
|
||||
ObjectId _id PK
|
||||
ObjectId clinicId FK
|
||||
ObjectId userId FK
|
||||
int queueNumber
|
||||
string status "Pending, Completed, Cancelled, No-Show"
|
||||
string qrCodeUrl "QR API Generated"
|
||||
date bookedAt
|
||||
}
|
||||
|
||||
%% MODULE 4: PATIENT RECORDS & HISTORY (Kaveen)
|
||||
%% Manages the permanent medical history and post-vax data
|
||||
RECORD {
|
||||
ObjectId _id PK
|
||||
ObjectId userId FK
|
||||
ObjectId appointmentId FK
|
||||
ObjectId batchId FK "Traceability"
|
||||
date vaccinationDate
|
||||
string notes
|
||||
date nextDoseDate
|
||||
string certificateUrl "Generated PDF"
|
||||
}
|
||||
|
||||
%% RELATIONSHIPS
|
||||
%% Linking the specific modules together
|
||||
|
||||
%% Minidu's Relationships
|
||||
VACCINE ||--o{ BATCH : "has many batches"
|
||||
|
||||
%% Nethmi's Relationships
|
||||
HOSPITAL ||--o{ CLINIC : "hosts"
|
||||
HOSPITAL ||--o{ BATCH : "stocks"
|
||||
|
||||
%% Saniru's Relationships
|
||||
CLINIC ||--o{ APPOINTMENT : "has bookings"
|
||||
USERS ||--o{ APPOINTMENT : "makes"
|
||||
|
||||
%% Kaveen's Relationships
|
||||
APPOINTMENT ||--|| RECORD : "generates"
|
||||
USERS ||--o{ RECORD : "has history"
|
||||
BATCH ||--o{ RECORD : "used in"
|
||||
|
||||
%% Cross-Module Links
|
||||
VACCINE ||--o{ CLINIC : "offered at"
|
||||
Reference in New Issue
Block a user