A full-stack emergency dispatch management system for Chaveirim volunteer organizations. Built with React, Express, PostgreSQL, and TypeScript.
- Call Management: Create, edit, broadcast, and close emergency calls
- Member Directory: Manage volunteer roster with skills, zones, and contact info
- Assignment System: Assign members to calls with ETA tracking
- Queue Management: Phone queue login/logout for dispatchers
- Real-time Updates: WebSocket-powered live updates across all clients
- Draft System: Auto-save drafts locally and to the cloud
- Highway Mode: Select highway, direction, exits, mile markers
- Address Mode: Google Places autocomplete integration
- Free Text Mode: Manual location entry for complex situations
- Map Integration: Google Maps links and coordinate support
- Make/Model Selection: Searchable database of vehicles
- Color Picker: Visual color selection
- Custom Entry: Free-form vehicle descriptions
- Fuzzy Matching: AI-powered vehicle text extraction
- Broadcast System: Send to WhatsApp, SMS, and email
- Multi-channel: Configurable notification channels
- Message Templates: Auto-generated broadcast messages
- User Management: Role-based access (Admin, Dispatcher, Member)
- Schedule Management: Dispatcher shift scheduling
- Reference Data: Manage highways, vehicles, agencies, problem codes
- Webhook Logs: Track all outgoing/incoming integrations
- System Settings: Configure app behavior
- React 18 with TypeScript
- TanStack Query for data fetching and caching
- Tailwind CSS for styling
- Vite for development and building
- Lucide React for icons
- Express.js with TypeScript
- PostgreSQL with Drizzle ORM
- Passport.js for authentication
- WebSocket for real-time updates
- Multer for file uploads
- Google Maps/Places for location services
- SendGrid for email
- Twilio for SMS
- WAHA for WhatsApp
- OpenAI for AI features
- Node.js 18+
- PostgreSQL database (Neon recommended)
- npm or yarn
- Clone the repository
git clone https://github.com/your-org/chaveirim-dispatcher.git
cd chaveirim-dispatcher- Install dependencies
npm install- Configure environment
cp .env.example .envEdit .env with your configuration:
# Required
DATABASE_URL=postgresql://user:password@host:5432/database
SESSION_SECRET=your-64-character-random-string
# Optional integrations
GOOGLE_MAPS_API_KEY=your-google-api-key
SENDGRID_API_KEY=your-sendgrid-key
TWILIO_ACCOUNT_SID=your-twilio-sid
TWILIO_AUTH_TOKEN=your-twilio-token
OPENAI_API_KEY=your-openai-key- Initialize database
npm run db:push- Start development server
npm run devThe app will be available at http://localhost:3000
The application uses 28 PostgreSQL tables:
users- Authentication accountsmembers- Volunteer directorycalls- Emergency call recordscallAssignments- Member-to-call assignmentscallLogs- Activity audit traildrafts- Incomplete call drafts
schedules- Recurring dispatcher shiftsshiftOverrides- Temporary schedule changesqueueSessions- Active phone queue logins
highways- Highway directoryhighwayExits- Exit coordinatescarMakes- Vehicle manufacturerscarModels- Vehicle modelsagencies- Requesting organizationsproblemCodes- Call nature/typesimportantPhones- Contact directory
settings- App configurationwebhookLogs- Integration auditfeedback- User feedback
The server exposes 90 REST API endpoints:
POST /api/login- Authenticate userPOST /api/logout- End sessionGET /api/user- Current user infoPOST /api/register- Create accountPOST /api/forgot-password- Request resetPOST /api/reset-password- Reset with token
GET /api/calls- List callsGET /api/calls/:id- Call detailsPOST /api/calls- Create callPATCH /api/calls/:id- Update callPOST /api/calls/:id/close- Close callPOST /api/calls/:id/assign- Assign memberPOST /api/calls/:id/broadcast- Send broadcast
GET /api/members- List membersGET /api/members/:id- Member detailsPOST /api/members- Create memberPATCH /api/members/:id- Update memberGET /api/search-directory- Search members
GET /api/schedules- List schedulesPOST /api/schedules- Create scheduleGET /api/queue-sessions- Active queue membersPOST /api/phone-system/queue-login- Join queue
chaveirim-dispatcher/
βββ client/ # React frontend
β βββ src/
β β βββ components/ # UI components
β β β βββ ui/ # Base UI primitives
β β β βββ CallCard.tsx
β β β βββ MemberSearch.tsx
β β β βββ LocationPicker.tsx
β β β βββ ...
β β βββ hooks/ # Custom React hooks
β β β βββ useAuth.ts
β β β βββ useCalls.ts
β β β βββ ...
β β βββ pages/ # Page components
β β β βββ Dashboard.tsx
β β β βββ CallForm.tsx
β β β βββ ...
β β βββ lib/ # Utilities
β β βββ App.tsx
β β βββ main.tsx
β βββ index.html
βββ server/ # Express backend
β βββ index.ts # Entry point
β βββ auth.ts # Passport config
β βββ routes.ts # API routes
β βββ storage.ts # Database layer
β βββ websocket.ts # Real-time server
β βββ integrations.ts # External services
β βββ vite.ts # Dev server
βββ shared/ # Shared code
β βββ schema.ts # Database schema
β βββ db.ts # DB connection
βββ public/ # Static assets
β βββ sw.js # Service worker
β βββ manifest.json # PWA manifest
βββ package.json
| Variable | Required | Description |
|---|---|---|
DATABASE_URL |
Yes | PostgreSQL connection string |
SESSION_SECRET |
Yes | 64+ char random string |
NODE_ENV |
No | development or production |
PORT |
No | Server port (default: 3000) |
APP_URL |
No | Production URL for CORS |
GOOGLE_MAPS_API_KEY |
No | Google Maps/Places API |
SENDGRID_API_KEY |
No | Email sending |
TWILIO_ACCOUNT_SID |
No | SMS sending |
TWILIO_AUTH_TOKEN |
No | SMS sending |
TWILIO_PHONE_NUMBER |
No | SMS from number |
WHATSAPP_API_URL |
No | WAHA server URL |
WHATSAPP_API_TOKEN |
No | WAHA auth token |
OPENAI_API_KEY |
No | AI features |
Configure features in the admin settings panel or via environment:
- Google Places autocomplete
- SMS notifications
- WhatsApp integration
- AI-powered features
- Push notifications
The app is a Progressive Web App with:
- Offline Support: Service worker caches static assets
- Install Prompt: Add to home screen on mobile
- Push Notifications: Real-time call alerts
- Background Sync: Queue offline actions
npm run dev # Start dev server with hot reload
npm run build # Build for production
npm run start # Start production server
npm run db:push # Push schema to database
npm run db:studio # Open Drizzle Studio
npm run db:generate # Generate migrations
npm run typecheck # Run TypeScript checks- TypeScript strict mode
- ESLint + Prettier
- Conventional commits
npm run build
npm startFROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]- Node.js 18+
- PostgreSQL 14+
- SSL certificate (for production)
- WebSocket support
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License - see LICENSE
Built with β€οΈ for the Chaveirim volunteer network.
Need help? Open an issue or contact the development team.
