Some checks failed
Release / release (push) Has been cancelled
Full-stack dashboard for controlling, automating, and analyzing Artifacts MMO characters via the game's HTTP API. Backend (FastAPI): - Async Artifacts API client with rate limiting and retry - 6 automation strategies (combat, gathering, crafting, trading, task, leveling) - Automation engine with runner, manager, cooldown tracker, pathfinder - WebSocket relay (game server -> frontend) - Game data cache, character snapshots, price history, analytics - 9 API routers, 7 database tables, 3 Alembic migrations - 108 unit tests Frontend (Next.js 15 + shadcn/ui): - Live character dashboard with HP/XP bars and cooldowns - Character detail with stats, equipment, inventory, skills, manual actions - Automation management with live log streaming - Interactive canvas map with content-type coloring and zoom/pan - Bank management, Grand Exchange with price charts - Events, logs, analytics pages with Recharts - WebSocket auto-reconnect with query cache invalidation - Settings page, error boundaries, dark theme Infrastructure: - Docker Compose (dev + prod) - GitHub Actions CI/CD - Documentation (Architecture, Automation, Deployment, API)
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
import logging
|
|
|
|
from fastapi import APIRouter, HTTPException, Request
|
|
from httpx import HTTPStatusError
|
|
|
|
from app.schemas.game import DashboardData
|
|
from app.services.artifacts_client import ArtifactsClient
|
|
from app.services.character_service import CharacterService
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
router = APIRouter(prefix="/api", tags=["dashboard"])
|
|
|
|
|
|
def _get_client(request: Request) -> ArtifactsClient:
|
|
return request.app.state.artifacts_client
|
|
|
|
|
|
def _get_service(request: Request) -> CharacterService:
|
|
return request.app.state.character_service
|
|
|
|
|
|
@router.get("/dashboard", response_model=DashboardData)
|
|
async def get_dashboard(request: Request) -> DashboardData:
|
|
"""Return aggregated dashboard data: all characters + server status."""
|
|
client = _get_client(request)
|
|
service = _get_service(request)
|
|
|
|
try:
|
|
characters = await service.get_all(client)
|
|
except HTTPStatusError as exc:
|
|
raise HTTPException(
|
|
status_code=exc.response.status_code,
|
|
detail=f"Artifacts API error: {exc.response.text}",
|
|
) from exc
|
|
|
|
# Server status could be extended later (e.g., ping, event info)
|
|
server_status: dict | None = None
|
|
try:
|
|
events = await client.get_events()
|
|
server_status = {"events": events}
|
|
except Exception:
|
|
logger.warning("Failed to fetch server events for dashboard", exc_info=True)
|
|
|
|
return DashboardData(
|
|
characters=characters,
|
|
server_status=server_status,
|
|
)
|