Updated readme
All checks were successful
Build & Publish to GHCR / build (push) Successful in 25s

This commit is contained in:
Florian 2025-10-18 20:12:18 +02:00
parent cfd611103c
commit 6abbddf4a6

View File

@ -1,3 +1,97 @@
# backend-api-internal
# Internal Notifier API
The internal part of the API. Duh!
A FastAPI-based internal service that receives notification requests and forwards them to RabbitMQ for asynchronous processing and delivery to end users.
## Features
- **RabbitMQ Integration**: Asynchronous message queuing for reliable notification delivery
- **Internal API Key Authentication**: Secure service-to-service communication
- **MySQL Connection Pooling**: Database connection management with automatic health checks
- **Prometheus Metrics**: Built-in request monitoring and tracking
## Architecture
This service acts as a gateway between internal services and the notification delivery system:
```
Internal Services → Internal Notifier API → RabbitMQ → Notification Workers → End Users
```
## Prerequisites
- Python 3.8+
- MySQL database
- RabbitMQ server
- Required Python packages (see Installation)
## Installation
```bash
pip install -r requirements.txt
```
## Running the Application
```bash
python main.py
```
This starts two servers:
- **Main API**: `http://0.0.0.0:8101`
- **Metrics Server**: `http://0.0.0.0:9000`
## API Endpoints
### Receive Notifications
```
POST /internal/receive-notifications
```
Receives notification data from internal services and queues it to RabbitMQ for delivery.
**Headers:**
- `X-API-Key-Internal`: Your internal API key
**Request Body:**
```json
{
"receipent_user_id": 12345,
"message": {
"title": "New Message",
"body": "You have a new notification",
"data": {
"category": "utility",
"link": "https://example.com",
"timestamp": "1760734800"
}
}
}
```
- `category` - Optional.
- `link` - Optional.
- `timestamp` - Optional.
**Response:**
```json
{
"status": "queued"
}
```
**Success:** Returns 200 status code when message is successfully queued to RabbitMQ
## Error Responses
- `403 Forbidden`: Invalid, missing, or inactive API key
- `500 Internal Server Error`: Database, RabbitMQ, or server error
## Monitoring
### Prometheus Metrics
Prometheus metrics are exposed on port 9000 and include:
- HTTP request counters by method, path, and status code
- Custom metrics from the metrics server
Access metrics at: `http://0.0.0.0:9000/metrics`