|
| 1 | +# Analytics Architecture Diagram |
| 2 | + |
| 3 | +```mermaid |
| 4 | +graph TB |
| 5 | + %% External traffic |
| 6 | + Client[Client/Browser] --> API[API Gateway] |
| 7 | +
|
| 8 | + %% Main queue |
| 9 | + API --> PVQ[page_views Queue<br/>RabbitMQ] |
| 10 | +
|
| 11 | + %% Partitioner service |
| 12 | + PVQ --> Partitioner[Partitioner Service] |
| 13 | +
|
| 14 | + %% Partitioned queues |
| 15 | + Partitioner --> PV0[page_views_0<br/>RabbitMQ] |
| 16 | + Partitioner --> PV1[page_views_1<br/>RabbitMQ] |
| 17 | + Partitioner --> PV2[page_views_2<br/>RabbitMQ] |
| 18 | + Partitioner --> PVN[page_views_n-1<br/>RabbitMQ] |
| 19 | +
|
| 20 | + %% Aggregator services |
| 21 | + PV0 --> Agg0[Aggregator_0<br/>Service] |
| 22 | + PV1 --> Agg1[Aggregator_1<br/>Service] |
| 23 | + PV2 --> Agg2[Aggregator_2<br/>Service] |
| 24 | + PVN --> AggN[Aggregator_n-1<br/>Service] |
| 25 | +
|
| 26 | + %% Final destination |
| 27 | + Agg0 --> IncSvc[Increments Service] |
| 28 | + Agg1 --> IncSvc |
| 29 | + Agg2 --> IncSvc |
| 30 | + AggN --> IncSvc |
| 31 | +
|
| 32 | + %% Styling |
| 33 | + classDef queue fill:#e1f5fe,stroke:#01579b,stroke-width:2px |
| 34 | + classDef service fill:#f3e5f5,stroke:#4a148c,stroke-width:2px |
| 35 | + classDef gateway fill:#e8f5e8,stroke:#1b5e20,stroke-width:2px |
| 36 | + classDef client fill:#fff3e0,stroke:#e65100,stroke-width:2px |
| 37 | +
|
| 38 | + class PVQ,PV0,PV1,PV2,PVN queue |
| 39 | + class Partitioner,Agg0,Agg1,Agg2,AggN service |
| 40 | + class API gateway |
| 41 | + class Client client |
| 42 | + class IncSvc service |
| 43 | +``` |
| 44 | + |
| 45 | +## Architecture Flow |
| 46 | + |
| 47 | +1. **API Gateway**: Receives page view requests from clients and writes them to the main `page_views` queue |
| 48 | +2. **Partitioner Service**: Reads from `page_views` queue and distributes messages across N partitioned queues (`page_views_0` to `page_views_n-1`) |
| 49 | +3. **Aggregator Services**: Each aggregator service (0 to n-1) reads from its respective partitioned queue and: |
| 50 | + - Processes up to 1000 messages OR waits 1 minute (whichever comes first) |
| 51 | + - Aggregates messages by pages |
| 52 | + - Writes aggregated data to the increments service |
| 53 | + |
| 54 | +## Components |
| 55 | + |
| 56 | +- **API Gateway**: Entry point for page view data |
| 57 | +- **RabbitMQ Queues**: |
| 58 | + - `page_views`: Main queue for incoming data |
| 59 | + - `page_views_0` to `page_views_n-1`: Partitioned queues for parallel processing |
| 60 | +- **Partitioner Service**: Distributes load across partitions |
| 61 | +- **Aggregator Services**: Process and aggregate data in parallel |
| 62 | +- **Increments Service**: Final destination for aggregated analytics data |
0 commit comments