All checks were successful
Build & Publish to GHCR / build (push) Successful in 1m27s
Switched to multi stage process to harden the Dockerfile
Service: Royalroad Chapters
Overview
service-royalroad-chapters is a FastAPI-based webserver that monitors Royalroad stories for new chapters and sends notifications data to backend-api-internal.
Features
- RSS Feed Monitoring: Parses Royal Road RSS feeds to detect new chapter releases
- Automatic Updates: Updates database with latest chapter numbers
- Retry Logic: Built-in retry mechanisms for network failures with exponential backoff
- Prometheus Metrics: Request counters and performance monitoring on port 9000
Prerequisites
- Python 3.10+
- MySQL database
- Backend notification service (for sending push notifications)
- Royal Road story IDs
Installation
pip install -r requirements.txt
Running the Service
python main.py
This starts two servers:
- Main API:
http://0.0.0.0:5000- Handles chapter check requests - Metrics Server:
http://0.0.0.0:9000/metrics- Prometheus metrics endpoint
API Endpoint
Check for New Chapters
GET /royalroad
Response:
{
"status": "checked"
}
Behavior:
- Fetches all active stories from the database
- Queries Royal Road RSS feed for each story
- Compares latest chapter with stored chapter number
- Updates database if new chapter is detected
- Sends notification to backend service
Error Responses:
404: Feed not found or has no entries500: Internal server error during processing503: Notification service unavailable after retries
Notification Format
Messages sent to the backend service:
{
"receipent_user_id": 1,
"message": {
"title": "New Life As A Max Level Archmage",
"body": "Chapter 68 has been released",
"link": "https://www.royalroad.com/fiction/118891/new-life-as-a-max-level-archmage/chapter/2683797/68-carve",
"category": "royal-road",
"timestamp": 1729339200
}
}
Headers:
X-API-Key-Internal: <api_key>
Content-Type: application/json
Monitoring
Prometheus Metrics
Available at http://localhost:9000/metrics:
http_requests_total{method, path, status}: Request counter with labels
Description
Languages
Python
96.2%
Dockerfile
3.8%