A medical priority dispatch system that streamlines case management, resource allocation, determinant codes and emergency response coordination between dispatchers, admins and responders.
- Overview
- Features
- Technology Stack
- Project Structure
- Prerequisites
- Installation
- Configuration
- Running the Application
- API Documentation
- Testing
- Database Management
DISPATCHUMS is a modern, full-stack medical priority dispatch system designed to help emergency services manage cases efficiently. The system provides real-time case tracking, admin management, call card display, and chatbox feedback testimonial features.
- π User Authentication & Authorization: Secure JWT-based authentication with role-based access control (Admin/User)
- π Dashboard: Comprehensive overview with analytics and insights
- π¨ Case Management: Create, update, track, and manage emergency cases
- π Diagnostic Tools: Advanced diagnostic features for case analysis
- π€ User Profile Management: Profile updates and password management
- π Feedback System: Interactive chat-based feedback mechanism
- π§ Email Notifications: Automated email notifications for password recovery and verification
- π Reporting & Analytics: Visual analytics using charts and graphs
- ποΈ Trash Management: Soft delete functionality with restore capabilities
- Responsive design for mobile and desktop
- Real-time data updates
- PDF export functionality
- Timeline tracking for cases
- Work info management
- Haversine Formula for shortest distance
- Framework: Next.js 15.5.4
- UI Library: React 19.1.0
- Language: TypeScript 5.9.3
- Styling:
- Tailwind CSS 4.x
- Chakra UI 3.28.1
- Emotion
- Icons:
- Heroicons 2.2.0
- Lucide React 0.544.0
- React Icons 5.5.0
- Charts: Recharts 3.5.1
- Animation: Framer Motion 12.23.24
- PDF Generation: jsPDF 4.0.0
- Framework: FastAPI 0.104.0+
- Server: Uvicorn 0.24.0+
- Language: Python 3.8+
- ORM: SQLAlchemy 2.0.25+
- Database: SQLite (development) / PostgreSQL (production ready)
- Authentication:
- python-jose (JWT)
- passlib (password hashing with bcrypt)
- Environment Management: python-dotenv
- File Uploads: python-multipart
- Linting: ESLint
- Process Management: Concurrently
- Version Control: Git
dispatchums
βββ frontend/ # Next.js frontend application
β βββ app/ # App directory (Next.js 13+ App Router)
β β βββ dashboard/ # Dashboard pages
β β β βββ admin/ # Admin-specific pages
β β β β βββ design/ # Design management
β β β β βββ users/ # User management
β β β βββ user/ # User-specific pages
β β βββ diagnostic/ # Diagnostic tools
β β βββ entry/ # Entry pages
β β βββ login/ # Login page
β β βββ profile/ # User profile pages
β β βββ questions/ # Questions/FAQ section
β β βββ register/ # Registration page
β β βββ layout.tsx # Root layout
β β βββ page.tsx # Landing page
β β βββ globals.css # Global styles
β βββ components/ # React components
β β βββ landing/ # Landing page components
β β βββ shared/ # Shared/reusable components
β βββ contexts/ # React contexts
β βββ lib/ # Utility functions and API clients
β β βββ api.ts # API integration
β βββ public/ # Static assets
β βββ types/ # TypeScript type definitions
β βββ next.config.ts # Next.js configuration
β βββ tailwind.config.ts # Tailwind CSS configuration
β βββ tsconfig.json # TypeScript configuration
β βββ package.json # Frontend dependencies
β
βββ my-fastapi-backend/ # FastAPI backend application
β βββ app/ # Application source code
β β βββ database/ # Database configuration
β β βββ models/ # SQLAlchemy models
β β βββ routers/ # API route handlers
β β β βββ auth.py # Authentication endpoints
β β β βββ cases.py # Case management endpoints
β β β βββ feedback.py # Feedback endpoints
β β βββ auth.py # Authentication utilities
β β βββ email_service.py # Email service
β β βββ main.py # FastAPI application entry point
β β βββ __init__.py
β βββ tests/ # Test files (in root)
β βββ init_database.py # Database initialization script
β βββ migrate_*.py # Database migration scripts
β βββ requirements.txt # Backend dependencies
β βββ run_server_simple.bat # Simple server start script
β βββ start_server.bat # Server start script
β
βββ components/ # Shared components (if any)
β βββ shared/
β
βββ package.json # Root package.json with scripts
βββ README.md # This file
Before you begin, ensure you have the following installed:
- Node.js: >= 18.0.0
- npm: >= 9.0.0
- Python: >= 3.8
- pip: Latest version
- Git: For version control
- VS Code: With recommended extensions (ESLint, Pylance, Prettier)
git clone <repository-url>
cd https://github.com/claygiraf/dispatchums/Using the root package.json:
npm run install:allOr install separately:
cd frontend
npm installcd my-fastapi-backend
pip install -r requirements.txt- Create a
.envfile in themy-fastapi-backenddirectory:
# Application Settings
PROJECT_NAME=Dispatchums API
DEBUG=True
# Database
DATABASE_URL=sqlite:///./dispatchums.db
# For PostgreSQL: postgresql://user:password@localhost/dbname
# JWT Authentication
SECRET_KEY=your-secret-key-here-change-in-production
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
# Email Settings (for password recovery)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASSWORD=your-app-password
EMAIL_FROM=noreply@dispatchums.com
# CORS Settings
CORS_ORIGINS=http://localhost:3000,http://127.0.0.1:3000- Initialize the database:
cd my-fastapi-backend
python init_database.pyThe frontend is configured to connect to http://localhost:8000 by default. Update the API base URL in frontend/lib/api.ts if needed.
From the root directory:
npm run devThis will start:
- Frontend: http://localhost:3000
- Backend: http://localhost:8000
Backend:
cd my-fastapi-backend
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Frontend:
cd frontend
npm run devnpm run buildnpm run startOr manually:
# Backend
cd my-fastapi-backend
uvicorn app.main:app --host 0.0.0.0 --port 8000
# Frontend
cd frontend
npm run build
npm startOnce the backend is running, access the interactive API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- OpenAPI JSON: http://localhost:8000/api/v1/openapi.json
POST /api/v1/login- User loginPOST /api/v1/register- User registrationPOST /api/v1/forgot-password- Request password resetPOST /api/v1/verify-email- Verify email addressGET /api/v1/me- Get current user info
GET /api/v1/cases- List all casesPOST /api/v1/cases- Create new caseGET /api/v1/cases/{id}- Get case detailsPUT /api/v1/cases/{id}- Update caseDELETE /api/v1/cases/{id}- Delete case (soft delete)
POST /api/v1/feedback- Submit feedbackGET /api/v1/feedback- List feedback (admin only)
The backend includes comprehensive test suites:
cd my-fastapi-backend
# Test specific functionality
python test_login.py
python test_registration.py
python test_api.py
python test_complete_flow.py
python test_password_change.py
python test_user_management.py
python test_feedback_chat.py
# Test email functionality
python test_email_sending.py
python test_forgot_password.py
python test_verification_flow.py
# Test profile and persistence
python test_profile_persistence.py
python test_profile_update.pyRun ESLint to check for code quality:
cd frontend
npm run lintThe project includes several migration scripts:
cd my-fastapi-backend
# Add specific columns
python add_missing_columns.py
python add_username_column.py
python migrate_timeline_columns.py
# Migrate data
python migrate_db.py
python migrate_feedback_chat.py
python migrate_id_system.py
python migrate_user_fields.py
# Fix data
python fix_password_changed_field.py
python fix_usernames.py# Check database state
python check_users.py
python check_users_data.py
python check_db_users.py
python check_id_sync.py
# Verify data
python verify_sync.pypython reset_admin_password.pypython setup_test_users.pyThe system supports multiple user roles:
- Admin: Full access to all features including user management, case configuration and unit creation.
- Responder: Emergency response personnel with access to case management and field operations
- User: Access to new case, profile management, feedback chatbox and email verification.
- JWT-based authentication
- Password hashing with bcrypt
- Role-based access control (RBAC)
- CORS configuration
- SQL injection prevention (SQLAlchemy ORM)
- Environment variable protection
This is an academic project under MIT license.