Hospital communication system built with Django Channels for real-time WebSocket communication.
- Role-based communication: Anesthetist, Nurse, and Surgeon roles
- Real-time messaging: WebSocket-based instant communication
- Location-based channels: Operating Rooms and Wards
- Message logging: Tracks sent and acknowledged messages with timestamps
- Notifications: Visual alerts and sound notifications for new messages
- Heartbeat system: 3-second ping to monitor connection status
- Python 3.11+
- PostgreSQL
- Redis
- Clone the repository:
git clone <repository-url>
cd szpital-django-ws- Install dependencies:
make install- Set up environment variables:
cp .env.example .env
# Edit .env with your database and Redis settings- Set up PostgreSQL database:
CREATE DATABASE dkp;
CREATE USER dkp WITH PASSWORD 'dkp';
GRANT ALL PRIVILEGES ON DATABASE dkp TO dkp;- Run migrations:
make migrate- Collect static files:
make collectstatic- Start Redis server:
redis-server- Start Django Channels server:
make run- Access the application at http://localhost:8000
- Select Role: Choose Anesthetist, Nurse, or Surgeon
- Select Location:
- Anesthetist: Select Operating Room
- Nurse/Surgeon: Select Ward
- Communication:
- Anesthetist: Can send messages to Nurses and Surgeons
- Nurse/Surgeon: Receive messages and must acknowledge them
CAN_ACCEPT_PATIENTS: From Anesthetist to NurseSURGERY_DONE: From Anesthetist to NursePATIENT_IN_THE_OR: From Anesthetist to Surgeon
make install # Install dependencies
make migrate # Run migrations
make run # Run development server
make shell # Open Django shell
make test # Run tests
make clean # Clean cache files
make superuser # Create admin user- Django: Web framework
- Django Channels: WebSocket support
- Redis: Channel layer for WebSocket communication
- PostgreSQL: Database for data persistence
- Daphne: ASGI server
-
Install Docker and Docker Compose:
# Ubuntu/Debian sudo apt update && sudo apt install docker.io docker-compose-plugin sudo usermod -aG docker $USER # macOS # Install Docker Desktop from https://docker.com
-
Configure Environment:
cp .env.production .env.production.local # Edit the file with your domain and settings nano .env.production.local -
Deploy the Application:
./docker/scripts/docker-deploy.sh prod
-
Set up SSL Certificates (if using a domain):
./docker/scripts/certbot-setup.sh
The Docker setup includes:
- app: Django application with Daphne ASGI server
- postgres: PostgreSQL database
- redis: Redis for caching and WebSocket channels
- nginx: Reverse proxy with SSL termination
- certbot: Automatic SSL certificate management
# Start all services
docker-compose up -d
# Stop all services
docker-compose down
# View logs
docker-compose logs -f
# Run migrations
docker-compose exec app python dkp/manage.py migrate
# Create superuser
docker-compose exec app python dkp/manage.py createsuperuser
# Access Django shell
docker-compose exec app python dkp/manage.py shell
# Create backup
./docker/scripts/docker-backup.shKey variables in .env.production:
DOMAIN: Your domain name (e.g.,yourdomain.com)EMAIL: Email for SSL certificatesSECRET_KEY: Generate a strong secret keyDB_PASSWORD: Secure database passwordALLOWED_HOSTS: Add your domain
The system includes Let's Encrypt SSL certificate management:
- Automatic certificate issuance and renewal
- HTTP to HTTPS redirect
- WebSocket SSL proxy support
- Security headers enabled
For detailed Docker deployment instructions, see README-Docker.md.
Access the admin interface at http://localhost:8000/admin to:
- View message logs
- Manage roles, operating rooms, and wards
- Monitor system activity