Files
bot-dashboard/backend/app/schemas/bot.py
Claude 297e94593f feat: Complete production-ready bot management dashboard system
Implement a comprehensive web-based dashboard for managing Telegram and Discord bots
with real-time monitoring, process control, and beautiful UI.

Backend (FastAPI):
- Complete REST API with OpenAPI documentation
- WebSocket support for real-time log streaming and statistics
- SQLAlchemy models for bots, logs, and users
- JWT-based authentication system
- Process management with subprocess and psutil
- Auto-restart functionality with configurable backoff
- System and bot resource monitoring (CPU, RAM, network)
- Comprehensive error handling and logging

Frontend (Next.js 14 + TypeScript):
- Modern React application with App Router
- shadcn/ui components with Tailwind CSS
- TanStack Query for data fetching and caching
- Real-time WebSocket integration
- Responsive design for mobile, tablet, and desktop
- Beautiful dark theme with glassmorphism effects
- Bot cards with status badges and controls
- System statistics dashboard

Example Bots:
- Telegram userbot using Telethon
- Telegram bot using python-telegram-bot
- Discord bot using discord.py
- Full command examples and error handling

Infrastructure:
- Docker and Docker Compose configurations
- Multi-stage builds for optimal image sizes
- Nginx reverse proxy with WebSocket support
- Production and development compose files
- Rate limiting and security headers

Documentation:
- Comprehensive README with setup instructions
- API documentation examples
- Configuration guides
- Troubleshooting section
- Makefile for common commands

Features:
- Start/stop/restart bots with one click
- Real-time log streaming via WebSocket
- Live system and bot statistics
- Auto-restart on crashes
- Bot configuration management
- Process monitoring and resource tracking
- Search and filter bots
- Responsive UI with loading states
- Toast notifications for all actions

Security:
- JWT token-based authentication
- Password hashing with bcrypt
- CORS configuration
- Environment variable management
- Input validation and sanitization
- Rate limiting in nginx
- Security headers configured
2025-11-21 10:31:11 +00:00

82 lines
2.2 KiB
Python

"""Pydantic schemas for bot operations."""
from typing import Optional, Dict, Any, List
from datetime import datetime
from pydantic import BaseModel, Field, ConfigDict
from app.models.bot import BotType, BotStatus
class BotCreate(BaseModel):
"""Schema for creating a new bot."""
name: str = Field(..., min_length=1, max_length=100, description="Unique bot name")
type: BotType = Field(..., description="Bot type (telegram_userbot, telegram_bot, discord_bot)")
config: Dict[str, Any] = Field(..., description="Bot configuration (tokens, settings)")
auto_restart: bool = Field(True, description="Enable automatic restart on crash")
model_config = ConfigDict(
json_schema_extra={
"example": {
"name": "My Telegram Bot",
"type": "telegram_bot",
"config": {
"token": "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",
"admin_user_ids": [12345678]
},
"auto_restart": True
}
}
)
class BotUpdate(BaseModel):
"""Schema for updating bot configuration."""
name: Optional[str] = Field(None, min_length=1, max_length=100)
config: Optional[Dict[str, Any]] = None
auto_restart: Optional[bool] = None
model_config = ConfigDict(
json_schema_extra={
"example": {
"name": "Updated Bot Name",
"auto_restart": False
}
}
)
class BotResponse(BaseModel):
"""Schema for bot response."""
id: str
name: str
type: BotType
config: Dict[str, Any]
status: BotStatus
auto_restart: bool
created_at: datetime
updated_at: datetime
last_started_at: Optional[datetime]
process_id: Optional[int]
restart_count: int
last_crash_at: Optional[datetime]
model_config = ConfigDict(from_attributes=True)
class BotListResponse(BaseModel):
"""Schema for paginated bot list."""
total: int
page: int
page_size: int
bots: List[BotResponse]
class BotStatusResponse(BaseModel):
"""Schema for bot status information."""
id: str
name: str
status: BotStatus
process_id: Optional[int]
uptime_seconds: Optional[int]
last_started_at: Optional[datetime]