|
|
|
|
@@ -32,56 +32,62 @@ tests/ # Test suites
|
|
|
|
|
|
|
|
|
|
## Technology Stack
|
|
|
|
|
|
|
|
|
|
| Layer | Technology |
|
|
|
|
|
| ---------- | --------------------------------------------------- |
|
|
|
|
|
| Backend | FastAPI, Uvicorn, SQLAlchemy, SQLite, Pydantic |
|
|
|
|
|
| Frontend | HTML5, CSS3, Vanilla JS, Bootstrap 5, HTMX |
|
|
|
|
|
| Security | JWT (python-jose), bcrypt (passlib) |
|
|
|
|
|
| Real-time | Native WebSocket |
|
|
|
|
|
| Layer | Technology |
|
|
|
|
|
| --------- | ---------------------------------------------- |
|
|
|
|
|
| Backend | FastAPI, Uvicorn, SQLAlchemy, SQLite, Pydantic |
|
|
|
|
|
| Frontend | HTML5, CSS3, Vanilla JS, Bootstrap 5, HTMX |
|
|
|
|
|
| Security | JWT (python-jose), bcrypt (passlib) |
|
|
|
|
|
| Real-time | Native WebSocket |
|
|
|
|
|
|
|
|
|
|
## Series Identifier Convention
|
|
|
|
|
|
|
|
|
|
Throughout the codebase, two identifiers are used for anime series:
|
|
|
|
|
|
|
|
|
|
- **`key`**: Primary identifier (provider-assigned, URL-safe, e.g., `"attack-on-titan"`)
|
|
|
|
|
- **`folder`**: Display/filesystem metadata only (e.g., `"Attack on Titan (2013)"`)
|
|
|
|
|
- **`key`**: Primary identifier (provider-assigned, URL-safe, e.g., `"attack-on-titan"`)
|
|
|
|
|
- **`folder`**: Display/filesystem metadata only (e.g., `"Attack on Titan (2013)"`)
|
|
|
|
|
|
|
|
|
|
All lookups, events, and API operations use `key`. The `folder` is metadata for display purposes.
|
|
|
|
|
|
|
|
|
|
## API Endpoints
|
|
|
|
|
|
|
|
|
|
### Authentication (`/api/auth`)
|
|
|
|
|
- `POST /login` - Master password authentication (returns JWT)
|
|
|
|
|
- `POST /logout` - Invalidate session
|
|
|
|
|
- `GET /status` - Check authentication status
|
|
|
|
|
|
|
|
|
|
- `POST /login` - Master password authentication (returns JWT)
|
|
|
|
|
- `POST /logout` - Invalidate session
|
|
|
|
|
- `GET /status` - Check authentication status
|
|
|
|
|
|
|
|
|
|
### Configuration (`/api/config`)
|
|
|
|
|
- `GET /` - Get configuration
|
|
|
|
|
- `PUT /` - Update configuration
|
|
|
|
|
- `POST /validate` - Validate without applying
|
|
|
|
|
- `GET /backups` - List backups
|
|
|
|
|
- `POST /backups/{name}/restore` - Restore backup
|
|
|
|
|
|
|
|
|
|
- `GET /` - Get configuration
|
|
|
|
|
- `PUT /` - Update configuration
|
|
|
|
|
- `POST /validate` - Validate without applying
|
|
|
|
|
- `GET /backups` - List backups
|
|
|
|
|
- `POST /backups/{name}/restore` - Restore backup
|
|
|
|
|
|
|
|
|
|
### Anime (`/api/anime`)
|
|
|
|
|
- `GET /` - List anime with missing episodes (returns `key` as identifier)
|
|
|
|
|
- `GET /{anime_id}` - Get anime details (accepts `key` or `folder` for backward compatibility)
|
|
|
|
|
- `POST /search` - Search for anime (returns `key` as identifier)
|
|
|
|
|
- `POST /add` - Add new series (extracts `key` from link URL)
|
|
|
|
|
- `POST /rescan` - Trigger library rescan
|
|
|
|
|
|
|
|
|
|
- `GET /` - List anime with missing episodes (returns `key` as identifier)
|
|
|
|
|
- `GET /{anime_id}` - Get anime details (accepts `key` or `folder` for backward compatibility)
|
|
|
|
|
- `POST /search` - Search for anime (returns `key` as identifier)
|
|
|
|
|
- `POST /add` - Add new series (extracts `key` from link URL)
|
|
|
|
|
- `POST /rescan` - Trigger library rescan
|
|
|
|
|
|
|
|
|
|
**Response Models:**
|
|
|
|
|
- `AnimeSummary`: `key` (primary identifier), `name`, `site`, `folder` (metadata), `missing_episodes`, `link`
|
|
|
|
|
- `AnimeDetail`: `key` (primary identifier), `title`, `folder` (metadata), `episodes`, `description`
|
|
|
|
|
|
|
|
|
|
- `AnimeSummary`: `key` (primary identifier), `name`, `site`, `folder` (metadata), `missing_episodes`, `link`
|
|
|
|
|
- `AnimeDetail`: `key` (primary identifier), `title`, `folder` (metadata), `episodes`, `description`
|
|
|
|
|
|
|
|
|
|
### Download Queue (`/api/queue`)
|
|
|
|
|
- `GET /status` - Queue status and statistics
|
|
|
|
|
- `POST /add` - Add episodes to queue
|
|
|
|
|
- `DELETE /{item_id}` - Remove item
|
|
|
|
|
- `POST /start` | `/stop` | `/pause` | `/resume` - Queue control
|
|
|
|
|
- `POST /retry` - Retry failed downloads
|
|
|
|
|
- `DELETE /completed` - Clear completed items
|
|
|
|
|
|
|
|
|
|
- `GET /status` - Queue status and statistics
|
|
|
|
|
- `POST /add` - Add episodes to queue
|
|
|
|
|
- `DELETE /{item_id}` - Remove item
|
|
|
|
|
- `POST /start` | `/stop` | `/pause` | `/resume` - Queue control
|
|
|
|
|
- `POST /retry` - Retry failed downloads
|
|
|
|
|
- `DELETE /completed` - Clear completed items
|
|
|
|
|
|
|
|
|
|
### WebSocket (`/ws/connect`)
|
|
|
|
|
|
|
|
|
|
Real-time updates for downloads, scans, and queue operations.
|
|
|
|
|
|
|
|
|
|
**Rooms**: `downloads`, `download_progress`, `scan_progress`
|
|
|
|
|
@@ -102,40 +108,48 @@ Real-time updates for downloads, scans, and queue operations.
|
|
|
|
|
## Core Services
|
|
|
|
|
|
|
|
|
|
### SeriesApp (`src/core/SeriesApp.py`)
|
|
|
|
|
|
|
|
|
|
Main engine for anime series management with async support, progress callbacks, and cancellation.
|
|
|
|
|
|
|
|
|
|
### Callback System (`src/core/interfaces/callbacks.py`)
|
|
|
|
|
- `ProgressCallback`, `ErrorCallback`, `CompletionCallback`
|
|
|
|
|
- Context classes include `key` + optional `folder` fields
|
|
|
|
|
- Thread-safe `CallbackManager` for multiple callback registration
|
|
|
|
|
|
|
|
|
|
- `ProgressCallback`, `ErrorCallback`, `CompletionCallback`
|
|
|
|
|
- Context classes include `key` + optional `folder` fields
|
|
|
|
|
- Thread-safe `CallbackManager` for multiple callback registration
|
|
|
|
|
|
|
|
|
|
### Services (`src/server/services/`)
|
|
|
|
|
|
|
|
|
|
| Service | Purpose |
|
|
|
|
|
| ----------------- | ------------------------------------------- |
|
|
|
|
|
| AnimeService | Series management, scans (uses SeriesApp) |
|
|
|
|
|
| DownloadService | Queue management, download execution |
|
|
|
|
|
| ScanService | Library scan operations with callbacks |
|
|
|
|
|
| ProgressService | Centralized progress tracking + WebSocket |
|
|
|
|
|
| WebSocketService | Real-time connection management |
|
|
|
|
|
| AuthService | JWT authentication, rate limiting |
|
|
|
|
|
| ConfigService | Configuration persistence with backups |
|
|
|
|
|
| Service | Purpose |
|
|
|
|
|
| ---------------- | ----------------------------------------- |
|
|
|
|
|
| AnimeService | Series management, scans (uses SeriesApp) |
|
|
|
|
|
| DownloadService | Queue management, download execution |
|
|
|
|
|
| ScanService | Library scan operations with callbacks |
|
|
|
|
|
| ProgressService | Centralized progress tracking + WebSocket |
|
|
|
|
|
| WebSocketService | Real-time connection management |
|
|
|
|
|
| AuthService | JWT authentication, rate limiting |
|
|
|
|
|
| ConfigService | Configuration persistence with backups |
|
|
|
|
|
|
|
|
|
|
## Frontend
|
|
|
|
|
|
|
|
|
|
### Static Files
|
|
|
|
|
- CSS: `styles.css` (Fluent UI design), `ux_features.css` (accessibility)
|
|
|
|
|
- JS: `app.js`, `queue.js`, `websocket_client.js`, accessibility modules
|
|
|
|
|
|
|
|
|
|
- CSS: `styles.css` (Fluent UI design), `ux_features.css` (accessibility)
|
|
|
|
|
- JS: `app.js`, `queue.js`, `websocket_client.js`, accessibility modules
|
|
|
|
|
|
|
|
|
|
### WebSocket Client
|
|
|
|
|
|
|
|
|
|
Native WebSocket wrapper with Socket.IO-compatible API:
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
const socket = io();
|
|
|
|
|
socket.join('download_progress');
|
|
|
|
|
socket.on('download_progress', (data) => { /* ... */ });
|
|
|
|
|
socket.join("download_progress");
|
|
|
|
|
socket.on("download_progress", (data) => {
|
|
|
|
|
/* ... */
|
|
|
|
|
});
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Authentication
|
|
|
|
|
|
|
|
|
|
JWT tokens stored in localStorage, included as `Authorization: Bearer <token>`.
|
|
|
|
|
|
|
|
|
|
## Testing
|
|
|
|
|
@@ -154,12 +168,14 @@ conda run -n AniWorld python -m pytest tests/api/ -v
|
|
|
|
|
## Production Notes
|
|
|
|
|
|
|
|
|
|
### Current (Single-Process)
|
|
|
|
|
- SQLite with WAL mode
|
|
|
|
|
- In-memory WebSocket connections
|
|
|
|
|
- File-based config and queue persistence
|
|
|
|
|
|
|
|
|
|
- SQLite with WAL mode
|
|
|
|
|
- In-memory WebSocket connections
|
|
|
|
|
- File-based config and queue persistence
|
|
|
|
|
|
|
|
|
|
### Multi-Process Deployment
|
|
|
|
|
- Switch to PostgreSQL/MySQL
|
|
|
|
|
- Move WebSocket registry to Redis
|
|
|
|
|
- Use distributed locking for queue operations
|
|
|
|
|
- Consider Redis for session/cache storage
|
|
|
|
|
|
|
|
|
|
- Switch to PostgreSQL/MySQL
|
|
|
|
|
- Move WebSocket registry to Redis
|
|
|
|
|
- Use distributed locking for queue operations
|
|
|
|
|
- Consider Redis for session/cache storage
|
|
|
|
|
|