Skip to content

claygiraf/dispatchums

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DISPATCHUMS MEDICAL PRIORITY DISPATCH SYSTEM

A medical priority dispatch system that streamlines case management, resource allocation, determinant codes and emergency response coordination between dispatchers, admins and responders.

πŸ“‹ Table of Contents

🎯 Overview

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.

✨ Features

Core 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

Additional Features

  • 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

πŸ›  Technology Stack

Frontend

Backend

Development Tools

  • Linting: ESLint
  • Process Management: Concurrently
  • Version Control: Git

πŸ“ Project Structure

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

πŸ“‹ Prerequisites

Before you begin, ensure you have the following installed:

Required

  • Node.js: >= 18.0.0
  • npm: >= 9.0.0
  • Python: >= 3.8
  • pip: Latest version

Recommended

  • Git: For version control
  • VS Code: With recommended extensions (ESLint, Pylance, Prettier)

πŸš€ Installation

1. Clone the Repository

git clone <repository-url>
cd https://github.com/claygiraf/dispatchums/

2. Install All Dependencies

Using the root package.json:

npm run install:all

Or install separately:

Frontend Dependencies

cd frontend
npm install

Backend Dependencies

cd my-fastapi-backend
pip install -r requirements.txt

βš™οΈ Configuration

Backend Configuration

  1. Create a .env file in the my-fastapi-backend directory:
# 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
  1. Initialize the database:
cd my-fastapi-backend
python init_database.py

Frontend Configuration

The frontend is configured to connect to http://localhost:8000 by default. Update the API base URL in frontend/lib/api.ts if needed.

πŸƒ Running the Application

Development Mode

Option 1: Run Both Together (Recommended)

From the root directory:

npm run dev

This will start:

Option 2: Run Separately

Backend:

cd my-fastapi-backend
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

Frontend:

cd frontend
npm run dev

Production Mode

Build Frontend

npm run build

Start Production Servers

npm run start

Or manually:

# Backend
cd my-fastapi-backend
uvicorn app.main:app --host 0.0.0.0 --port 8000

# Frontend
cd frontend
npm run build
npm start

πŸ“š API Documentation

Once the backend is running, access the interactive API documentation:

Main API Endpoints

Authentication

  • POST /api/v1/login - User login
  • POST /api/v1/register - User registration
  • POST /api/v1/forgot-password - Request password reset
  • POST /api/v1/verify-email - Verify email address
  • GET /api/v1/me - Get current user info

Cases

  • GET /api/v1/cases - List all cases
  • POST /api/v1/cases - Create new case
  • GET /api/v1/cases/{id} - Get case details
  • PUT /api/v1/cases/{id} - Update case
  • DELETE /api/v1/cases/{id} - Delete case (soft delete)

Feedback

  • POST /api/v1/feedback - Submit feedback
  • GET /api/v1/feedback - List feedback (admin only)

πŸ§ͺ Testing

Backend Tests

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.py

Frontend Tests

Run ESLint to check for code quality:

cd frontend
npm run lint

πŸ—„οΈ Database Management

Database Migrations

The 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

Database Inspection

# 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.py

Reset Admin Password

python reset_admin_password.py

Setup Test Users

python setup_test_users.py

πŸ‘₯ User Roles

The 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.

πŸ”’ Security Features

  • JWT-based authentication
  • Password hashing with bcrypt
  • Role-based access control (RBAC)
  • CORS configuration
  • SQL injection prevention (SQLAlchemy ORM)
  • Environment variable protection

🀝 Contributing

This is an academic project under MIT license.

About

DISPATCHUMS, a Medical Priority Dispatch System (MPDS) is structured emergency response system designed to enhance pre-hospital care by assessing and prioritizing medical emergencies based on severity.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors