Skip to content

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 framework
  • json - Data storage
  • datetime - Date/time handling
  • hashlib - 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 configuration

Data 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 access
  • doctor - Medical staff access
  • nurse - Patient care access
  • patient - Personal data access
  • familymember - 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 ​

  1. User enters credentials
  2. System validates against user database
  3. Session created with user information
  4. Role-based redirect to appropriate dashboard

Health Log Creation Flow ​

  1. Patient navigates to health log form
  2. Enters health information
  3. Marks sensitivity if needed
  4. System validates and stores data
  5. Updates patient's health log history

Emergency Call Flow ​

  1. Patient creates emergency call
  2. System creates emergency record
  3. Nurses receive notification
  4. Nurse accepts and responds
  5. Emergency marked as resolved
  6. 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.json
User Browser <-> Load Balancer <-> Streamlit Instances <-> Database
                                                         <-> Cache
                                                         <-> Object Storage

Backup 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