Add comprehensive database integration, authentication, and admin dashboard
This commit introduces major enhancements to Talk2Me: ## Database Integration - PostgreSQL support with SQLAlchemy ORM - Redis integration for caching and real-time analytics - Automated database initialization scripts - Migration support infrastructure ## User Authentication System - JWT-based API authentication - Session-based web authentication - API key authentication for programmatic access - User roles and permissions (admin/user) - Login history and session tracking - Rate limiting per user with customizable limits ## Admin Dashboard - Real-time analytics and monitoring - User management interface (create, edit, delete users) - System health monitoring - Request/error tracking - Language pair usage statistics - Performance metrics visualization ## Key Features - Dual authentication support (token + user accounts) - Graceful fallback for missing services - Non-blocking analytics middleware - Comprehensive error handling - Session management with security features ## Bug Fixes - Fixed rate limiting bypass for admin routes - Added missing email validation method - Improved error handling for missing database tables - Fixed session-based authentication for API endpoints 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
		
							
								
								
									
										120
									
								
								admin/templates/dashboard_simple.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								admin/templates/dashboard_simple.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,120 @@ | ||||
| {% extends "base.html" %} | ||||
|  | ||||
| {% block title %}Dashboard - Talk2Me Admin{% endblock %} | ||||
|  | ||||
| {% block content %} | ||||
| <!-- Simple Mode Notice --> | ||||
| <div class="alert alert-warning" role="alert"> | ||||
|     <h4 class="alert-heading">Simple Mode Active</h4> | ||||
|     <p>The admin dashboard is running in simple mode because Redis and PostgreSQL services are not available.</p> | ||||
|     <hr> | ||||
|     <p class="mb-0">To enable full analytics and monitoring features, please ensure Redis and PostgreSQL are running.</p> | ||||
| </div> | ||||
|  | ||||
| <!-- Basic Info Cards --> | ||||
| <div class="row mb-4"> | ||||
|     <div class="col-md-4 mb-3"> | ||||
|         <div class="card"> | ||||
|             <div class="card-body"> | ||||
|                 <h5 class="card-title">System Status</h5> | ||||
|                 <p class="card-text"> | ||||
|                     <span class="badge badge-success">Online</span> | ||||
|                 </p> | ||||
|                 <small class="text-muted">Talk2Me API is running</small> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|      | ||||
|     <div class="col-md-4 mb-3"> | ||||
|         <div class="card"> | ||||
|             <div class="card-body"> | ||||
|                 <h5 class="card-title">Admin Access</h5> | ||||
|                 <p class="card-text"> | ||||
|                     <span class="badge badge-primary">Authenticated</span> | ||||
|                 </p> | ||||
|                 <small class="text-muted">You are logged in as admin</small> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|      | ||||
|     <div class="col-md-4 mb-3"> | ||||
|         <div class="card"> | ||||
|             <div class="card-body"> | ||||
|                 <h5 class="card-title">Services</h5> | ||||
|                 <p class="card-text"> | ||||
|                     Redis: <span class="badge badge-secondary">Not configured</span><br> | ||||
|                     PostgreSQL: <span class="badge badge-secondary">Not configured</span> | ||||
|                 </p> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
|  | ||||
| <!-- Available Actions --> | ||||
| <div class="card"> | ||||
|     <div class="card-header"> | ||||
|         <h5 class="mb-0">Available Actions</h5> | ||||
|     </div> | ||||
|     <div class="card-body"> | ||||
|         <p>In simple mode, you can:</p> | ||||
|         <ul> | ||||
|             <li>Access the Talk2Me API with admin privileges</li> | ||||
|             <li>View system health status</li> | ||||
|             <li>Logout from the admin session</li> | ||||
|         </ul> | ||||
|          | ||||
|         <p class="mt-3">To enable full features, set up the following services:</p> | ||||
|         <ol> | ||||
|             <li><strong>Redis</strong>: For caching, rate limiting, and session management</li> | ||||
|             <li><strong>PostgreSQL</strong>: For persistent storage of analytics and user data</li> | ||||
|         </ol> | ||||
|          | ||||
|         <div class="mt-4"> | ||||
|             <a href="/admin/logout" class="btn btn-secondary">Logout</a> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
|  | ||||
| <!-- Setup Instructions --> | ||||
| <div class="card mt-4"> | ||||
|     <div class="card-header"> | ||||
|         <h5 class="mb-0">Quick Setup Guide</h5> | ||||
|     </div> | ||||
|     <div class="card-body"> | ||||
|         <h6>1. Install Redis:</h6> | ||||
|         <pre class="bg-light p-2"><code># Ubuntu/Debian | ||||
| sudo apt-get install redis-server | ||||
| sudo systemctl start redis | ||||
|  | ||||
| # macOS | ||||
| brew install redis | ||||
| brew services start redis</code></pre> | ||||
|          | ||||
|         <h6>2. Install PostgreSQL:</h6> | ||||
|         <pre class="bg-light p-2"><code># Ubuntu/Debian | ||||
| sudo apt-get install postgresql | ||||
| sudo systemctl start postgresql | ||||
|  | ||||
| # macOS | ||||
| brew install postgresql | ||||
| brew services start postgresql</code></pre> | ||||
|          | ||||
|         <h6>3. Configure Environment:</h6> | ||||
|         <pre class="bg-light p-2"><code># Add to .env file | ||||
| REDIS_URL=redis://localhost:6379/0 | ||||
| DATABASE_URL=postgresql://user:pass@localhost/talk2me</code></pre> | ||||
|          | ||||
|         <h6>4. Initialize Database:</h6> | ||||
|         <pre class="bg-light p-2"><code>python init_auth_db.py</code></pre> | ||||
|          | ||||
|         <p class="mt-3">After completing these steps, restart the Talk2Me server to enable full admin features.</p> | ||||
|     </div> | ||||
| </div> | ||||
| {% endblock %} | ||||
|  | ||||
| {% block scripts %} | ||||
| <script> | ||||
| // Simple mode - no need for real-time updates or API calls | ||||
| console.log('Admin dashboard loaded in simple mode'); | ||||
| </script> | ||||
| {% endblock %} | ||||
		Reference in New Issue
	
	Block a user