How sanjaygoud009/pawmira works
Purpose and Entry Points
PawMira is a MERN rescue-operations system for reporting injured animals, triaging cases, and enabling NGO response. The browser application starts at client/src/main.jsx and composes UI/routing from client/src/App.jsx. The Express API starts at server/server.js, connects through server/config/db.js, and exposes domain route modules.
Client Application and User Flows
React provides public information, authentication, emergency reporting, rescue feed, lost/found, volunteer, and NGO/admin experiences. Key operational pages are client/src/pages/ReportEmergency.jsx, client/src/pages/Dashboard.jsx, and client/src/pages/AdminDashboard.jsx. Shared report UI covers photo intake, location selection, and report presentation in client/src/components/report/ImageUpload.jsx, client/src/components/report/LocationPicker.jsx, and client/src/components/report/RescueCard.jsx.
Identity and Authorization Boundary
Client auth state is centralized in client/src/context/AuthContext.jsx, with consumer access through client/src/hooks/useAuth.js. Backend JWT authentication and access control are enforced by server/middleware/auth.js; identity persistence is modeled in server/models/User.js. Auth lifecycle endpoints are defined by server/routes/auth.js and implemented in server/controllers/authController.js.
Rescue Report Lifecycle
Reports enter from the web reporting flow or WhatsApp integration, pass through route/controller handling, and persist as rescue records. The core API boundary is server/routes/reports.js → server/controllers/reportController.js → server/models/Report.js. The Report model supports soft deletion, priority/status history, and geospatial location queries; dashboard/feed consumers retrieve and act on this operational queue.
Media and Location Processing
Images are compressed before submission in client/src/utils/imageCompressor.js, then validated and accepted by upload middleware in server/middleware/upload.js. Cloudinary integration is configured in server/config/cloudinary.js; image validation resides in server/utils/imageValidator.js. Location selected client-side is stored in MongoDB report data, whose geospatial indexing supports proximity/filtering for responders.
Messaging, Notifications, and WhatsApp Intake
In-app rescue conversations use server/routes/rescueMessageRoutes.js, server/controllers/rescueMessageController.js, and server/models/RescueMessage.js; broader messaging has a separate messagesRoutes domain. Notifications are independently exposed through server/routes/notifications.js and persisted in server/models/Notification.js. Twilio WhatsApp webhook/chatbot flow is isolated in server/routes/whatsapp.js and server/controllers/whatsappController.js, with temporary conversational state in TTL-backed server/models/WhatsAppSession.js.
Supporting Operational Domains and Runtime
Lost/found animal records are a separate workflow from emergency reports, centered on server/routes/lostFound.js, server/controllers/lostFoundController.js, and server/models/LostPet.js/server/models/FoundPet.js. Admin operations, rankings/gamification, contact handling, escalations, cleanup, and email are backend service domains. Runtime infrastructure is Node/Express, MongoDB/Mongoose, Cloudinary, and Twilio; client deployment configuration is present at client/vercel.json, with PWA/offline assets in client/public/sw.js.
Main entry points: server.js API server · reports.js Rescue reports API · App.jsx App routing · auth.js Auth lifecycle
Components 22
React client
- Browser entry
client/src/main.jsx - App routing
client/src/App.jsx - Auth state · Provides identity state through useAuth.
client/src/context/AuthContext.jsx - Emergency reporting · Report, responder dashboard, and admin dashboard flows.
client/src/pages/ReportEmergency.jsx - Report intake UI · Photo intake, location selection, and rescue cards.
client/src/components/report/ImageUpload.jsx - Image compression
client/src/utils/imageCompressor.js
Express API
- API server · Mounts domain routes and initializes the API.
server/server.js - Auth lifecycle
server/routes/auth.js - JWT access control
server/middleware/auth.js - Rescue reports API · Receives, updates, and retrieves the operational rescue queue.
server/routes/reports.js - Upload validation · Accepts validated report image uploads.
server/middleware/upload.js - Rescue conversations
server/routes/rescueMessageRoutes.js - Notifications
server/routes/notifications.js - WhatsApp intake · Twilio chatbot intake for rescue reports.
server/routes/whatsapp.js - Lost and found · Separate workflow for lost and found animals.
server/routes/lostFound.js
Data and integrations
- MongoDB connection
server/config/db.js - Users
server/models/User.js - Rescue records · Tracks status and priority history, soft deletion, and geospatial locations.
server/models/Report.js - Conversation state · Rescue messages plus TTL-backed WhatsApp sessions.
server/models/RescueMessage.js - Notification records
server/models/Notification.js - Cloudinary
server/config/cloudinary.js - Twilio WhatsApp
Connections 24
- Browser entry → App routing: renders
- App routing → Auth state: provides auth
- App routing → Emergency reporting: routes to
- Emergency reporting → Report intake UI: uses
- Report intake UI → Image compression: compresses images
- App routing → Auth lifecycle: auth requests
- Emergency reporting → Rescue reports API: submits and queries
- API server → Auth lifecycle: mounts
- API server → Rescue reports API: mounts
- API server → Rescue conversations: mounts
- API server → Notifications: mounts
- API server → WhatsApp intake: mounts
- API server → Lost and found: mounts
- Auth lifecycle → JWT access control: protects access
- Auth lifecycle → Users: manages
- Rescue reports API → JWT access control: enforces roles
- Rescue reports API → Upload validation: processes uploads
- Upload validation → Cloudinary: stores images
- Rescue reports API → Rescue records: persists queue
- Rescue conversations → Conversation state: persists
- Notifications → Notification records: persists
- WhatsApp intake → Twilio WhatsApp: webhook/chatbot
- WhatsApp intake → Rescue records: creates reports
- API server → MongoDB connection: connects