artifacts-dashboard/docs/ARCHITECTURE.md
Paweł Orzech f845647934
Some checks failed
Release / release (push) Has been cancelled
Initial release: Artifacts MMO Dashboard & Automation Platform
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)
2026-03-01 19:46:45 +01:00

63 lines
2.5 KiB
Markdown

# Architecture
## Overview
Artifacts Dashboard is a monorepo with a Python/FastAPI backend and Next.js frontend, connected via REST API and WebSocket.
```
┌─────────────┐ ┌──────────────┐ ┌──────────────┐
│ Frontend │────▶│ Backend │────▶│ Artifacts API│
│ (Next.js) │◀────│ (FastAPI) │◀────│ │
└─────────────┘ WS └──────┬───────┘ └──────────────┘
┌──────▼───────┐
│ PostgreSQL │
└──────────────┘
```
## Backend
### Layers
1. **API Layer** (`app/api/`) — FastAPI routes, request/response handling
2. **Service Layer** (`app/services/`) — business logic, external API communication
3. **Engine Layer** (`app/engine/`) — automation engine with strategies and decision modules
4. **Data Layer** (`app/models/`) — SQLAlchemy models, database access
### Key Patterns
- **Strategy Pattern** — each automation type (combat, gathering, crafting, trading, task) implements a common interface
- **State Machine** — strategies operate as state machines (e.g., move → fight → heal → deposit → repeat)
- **Token Bucket** — rate limiting shared across all automation runners
- **Event Bus** — asyncio pub/sub connecting engine events with WebSocket relay
- **A* Pathfinding** — map navigation using cached tile data
### Automation Engine
```
AutomationManager
├── AutomationRunner (per character)
│ ├── Strategy (combat/gathering/crafting/trading/task)
│ ├── CooldownTracker
│ └── RateLimiter (shared)
└── Coordinator (multi-character)
```
## Frontend
- **App Router** — file-based routing with layouts
- **TanStack Query** — server state management with WebSocket-driven invalidation
- **shadcn/ui** — component library built on Radix UI
- **Recharts** — analytics charts
## Database
| Table | Purpose |
|-------|---------|
| `game_data_cache` | Cached static game data |
| `character_snapshots` | Periodic character state snapshots |
| `automation_configs` | Automation configurations |
| `automation_runs` | Automation execution state |
| `automation_logs` | Action logs |
| `price_history` | Grand Exchange price history |
| `event_log` | Game event history |