The WhatsApp Admin Dashboard is a Streamlit-based web application that provides administrators with a centralized interface to monitor and manage WhatsApp conversations through an Order Management System (OMS). It serves as a bridge between administrators and customers, allowing manual intervention in automated WhatsApp business communications.
OMS-AdminDashboard/
├── app.py # Main Streamlit application
├── config.py # Configuration settings and styling
├── utils.py # API utility functions
├── requirements.txt # Python dependencies
├── Dockerfile # Container deployment configuration
├── .dockerignore # Docker ignore patterns
└── .gitignore # Git ignore patterns
Purpose: Core Streamlit application that orchestrates the entire user interface and user interactions.
Key Components:
- Session State Management: Tracks selected user across page refreshes
- Connection Status: Real-time server connectivity monitoring
- Sidebar Interface: User list with search and auto-refresh functionality
- Chat Interface: Message display and sending functionality
- Welcome Screen: Landing page when no user is selected
Flow:
- Initialize Streamlit page configuration and CSS
- Check server connection status
- Display sidebar with active users list
- Handle user selection and chat interface
- Process message sending and refresh cycles
Purpose: Centralized configuration for API endpoints, UI settings, and styling.
Key Elements:
- API Configuration: Base URL and vendor ID for OMS server
- UI Settings: Streamlit page configuration and timezone settings
- Custom CSS: Dark theme styling for chat interface and overall application
Important Values:
API_BASE: Points to Railway-hosted OMS serverVENDOR_ID: Specific to "Andhra Ghuma Ghumalu" businessCUSTOM_CSS: Comprehensive dark theme with chat bubble styling
Purpose: Handles all communication with the OMS server and data processing.
Core Functions:
- Endpoint:
GET /admin/users/{VENDOR_ID} - Returns: List of users with recent WhatsApp activity
- Data Structure:
[{userId, userName, lastMessage, lastMessageTime, direction}]
- Endpoint:
GET /admin/messages/{VENDOR_ID}/{user_id} - Returns: Complete conversation history for specific user
- Data Structure:
[{message, timestamp, direction}]
- Endpoint:
POST /admin/send-message - Payload:
{vendorId, userId, message} - Returns: Boolean success status
- Endpoint:
GET /admin/test-redis - Purpose: Health check for server availability
- Purpose: Converts ISO timestamps to IST HH:MM format
- Handles: Timezone conversion and error fallback
- Purpose: Provides fallback display names for users
- Logic: Uses userName if available, otherwise "User {last4digits}"
Core Dependencies:
streamlit: Web application frameworkrequests: HTTP client for API communicationpytz: Timezone handling for IST conversionstreamlit-autorefresh: Auto-refresh functionality
app.py starts → Load config.py → Set page config → Apply custom CSS → Initialize session state
Check connection → Display sidebar → Fetch active users → Handle user selection → Display chat/welcome
User clicks contact → Store in session_state → Fetch messages → Display chat → Enable message sending
get_messages(user_id) → Format timestamps → Build HTML → Escape content → Render with custom CSS
User types message → Form submission → send_message() → Success feedback → Refresh interface
- Base URL:
https://ordermanagementsystem-production-dd4b.up.railway.app - Authentication: Vendor ID-based (no tokens required)
- Timeout: 5 seconds for reads, 15 seconds for message sending
- Error Handling: Graceful degradation with user feedback
- Active Users: Fetched every 10 seconds (if auto-refresh enabled)
- Messages: Fetched when user is selected and after sending messages
- Connection Test: Performed on app startup and refresh
- Sidebar: Fixed width, scrollable user list with search
- Main Area: Dynamic content (welcome screen or chat interface)
- Chat Container: Fixed height with scroll, custom message bubbles
# Messages are rendered as HTML with custom CSS classes
if msg['direction'] == 'in':
# User message (left-aligned, gray background)
HTML: <div class="message-left"><div class="user-message">...</div></div>
else:
# Bot message (right-aligned, gray background)
HTML: <div class="message-right"><div class="bot-message">...</div></div>- selected_user: Maintains current conversation context
- Auto-refresh: Toggle state for periodic updates
- Search query: Filters user list in real-time
- Base Image: Python 3.9-slim
- Port: 8501 (Streamlit default)
- Health Check: Built-in Streamlit health endpoint
- Environment: Configured for Railway deployment
- CORS: Disabled for deployment environment
- XSRF Protection: Disabled for API integration
- Headless Mode: Enabled for server deployment
- Input Sanitization: HTML escaping for all user messages
- XSS Prevention: Safe HTML rendering with Streamlit
- API Timeout: Prevents hanging requests
- Efficient Rendering: Single HTML block for all messages
- Minimal API Calls: Strategic refresh timing
- CSS Optimization: Inline styles for better performance
- Server Unavailable: Clear error message, app stops gracefully
- Timeout: User-friendly timeout messages
- API Errors: Generic error handling with fallback empty states
- Loading States: Spinner during message sending
- Success Feedback: Confirmation messages for actions
- Graceful Degradation: App continues functioning with limited data
- Vendor ID: Easily configurable for different businesses
- Timezone: Configurable for different regions
- Message Formatting: Customizable timestamp and display formats
- Color Scheme: Fully customizable through CSS variables
- Layout: Responsive design with configurable dimensions
- Branding: Easy to modify titles, icons, and styling
This implementation provides a robust, scalable foundation for WhatsApp business communication management with clear separation of concerns and maintainable architecture.