System Architecture
CareLog is a healthcare management system built with Python and Streamlit, using a JSON-based data storage approach.
Overview
CareLog's architecture is designed for:
- Simplicity and ease of deployment
- Rapid development and prototyping
- Educational purposes
- Small to medium-scale healthcare facilities
Technology Stack
Frontend
Streamlit Framework:
- Python-based web framework
- Interactive UI components
- Real-time updates
- Built-in session management
- Responsive design
Key Features:
- Form handling
- Data visualization
- File uploads
- Interactive widgets
- Custom CSS styling
Backend
Python:
- Core application logic
- Business rules implementation
- Data processing
- Authentication and authorization
Libraries:
streamlit- Web frameworkjson- Data storagedatetime- Date/time handlinghashlib- Password hashing (if implemented)
Data Storage
JSON-based Database:
- File:
data/data.json - Simple structure
- Human-readable
- Easy backup
- Version control friendly
Data Collections:
- Users
- Patients
- Health Logs
- Diagnoses
- Prescriptions
- Appointments
- Emergency Calls
- Feedback
- Audit Logs
Application Structure
carelog/
├── app.py # Main application entry point
├── data/
│ ├── data.json # Primary data storage
│ └── backups/ # Backup files
├── pages/ # Streamlit pages
│ ├── admin.py
│ ├── doctor.py
│ ├── nurse.py
│ ├── patient.py
│ └── family.py
├── utils/ # Utility functions
│ ├── auth.py # Authentication
│ ├── database.py # Data access
│ └── helpers.py # Helper functions
├── requirements.txt # Python dependencies
└── .streamlit/
└── config.toml # Streamlit configurationData Model
User Entity
json
{
"userId": "string (UUID)",
"email": "string (unique)",
"password": "string (hashed)",
"name": "string",
"firstName": "string",
"lastName": "string",
"role": "string (hospitaladmin|doctor|nurse|patient|familymember)",
"disabled": "boolean",
"linkedPatients": ["string (userId)"]
}Health Log Entity
json
{
"healthLogId": "string (UUID)",
"userId": "string (patientId)",
"date": "string (ISO date)",
"symptoms": "string",
"activities": "string",
"sleep": "string",
"nutrition": "string",
"notes": "string",
"isSensitive": "boolean"
}Diagnosis Entity
json
{
"diagnosisId": "string (UUID)",
"patientId": "string (userId)",
"doctorId": "string (userId)",
"date": "string (ISO date)",
"diagnosis": "string",
"notes": "string"
}Prescription Entity
json
{
"prescriptionId": "string (UUID)",
"patientId": "string (userId)",
"doctorId": "string (userId)",
"medication": "string",
"dosage": "string",
"date": "string (ISO date)",
"notes": "string",
"active": "boolean"
}Emergency Call Entity
json
{
"emergencyId": "string (UUID)",
"patientId": "string (userId)",
"nurseId": "string (userId, optional)",
"reason": "string",
"timestamp": "string (ISO datetime)",
"status": "string (pending|responded|resolved)",
"resolution": "string (optional)"
}Authentication & Authorization
Session Management
- Streamlit's session state for user sessions
- Session persistence during user interaction
- Automatic session cleanup on logout
Role-Based Access Control (RBAC)
Implementation:
- Role stored in user object
- Page-level access control
- Function-level permission checks
- Data filtering based on role
Roles:
hospitaladmin- Full accessdoctor- Medical staff accessnurse- Patient care accesspatient- Personal data accessfamilymember- Limited patient access
Security Architecture
Data Security
Password Handling:
- Hashed password storage (recommended)
- Secure password comparison
- No plaintext passwords in logs
Access Control:
- Role-based permissions
- User session validation
- Data access filtering
- Audit logging
Privacy Protection
Sensitive Data:
- Sensitive flag on health logs
- Family member access restrictions
- Role-based data visibility
Data Flow
User Login Flow
- User enters credentials
- System validates against user database
- Session created with user information
- Role-based redirect to appropriate dashboard
Health Log Creation Flow
- Patient navigates to health log form
- Enters health information
- Marks sensitivity if needed
- System validates and stores data
- Updates patient's health log history
Emergency Call Flow
- Patient creates emergency call
- System creates emergency record
- Nurses receive notification
- Nurse accepts and responds
- Emergency marked as resolved
- Response logged in audit trail
Scalability Considerations
Current Limitations
- JSON file storage (not for large scale)
- Single file data access
- No concurrent access control
- Limited query capabilities
- File I/O performance
Scaling Recommendations
For production use, consider:
- Database migration (PostgreSQL, MySQL)
- Caching layer (Redis)
- Load balancing
- Horizontal scaling
- Cloud deployment
- CDN for static assets
Deployment Architecture
Local Deployment
User Browser <-> Streamlit App <-> data.jsonProduction Deployment (Recommended)
User Browser <-> Load Balancer <-> Streamlit Instances <-> Database
<-> Cache
<-> Object StorageBackup Architecture
Backup Strategy
- Automated daily backups
- Manual backup triggers
- Retention policy enforcement
- Offsite backup replication
Backup Storage
data/
├── data.json # Active database
└── backups/
├── backup_YYYY-MM-DD_HH-MM-SS.json
└── [multiple backup files]Monitoring & Logging
Audit Logging
- User actions logged
- Data access tracked
- System events recorded
- Security events monitored
Application Logging
- Error logging
- Performance metrics
- User activity
- System health
Integration Points
Potential Integrations
- Email notifications (SMTP)
- SMS alerts (Twilio, etc.)
- Electronic Health Records (HL7/FHIR)
- Laboratory systems
- Pharmacy systems
- Payment gateways
Performance Optimization
Current Optimizations
- Efficient data filtering
- Lazy loading of data
- Session caching
- Minimal dependencies
Future Optimizations
- Database indexing
- Query optimization
- Caching strategies
- Asynchronous processing
- Background jobs