# rishabhdas/events-app-opentelemetry architecture

> Architecture diagram of the GitHub repository rishabhdas/events-app-opentelemetry, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rishabhdas/events-app-opentelemetry
- Repository: https://github.com/rishabhdas/events-app-opentelemetry

## Overview

##### Project Type and Purpose
- This is a full-stack events application designed as a Proof-of-Concept (POC) for OpenTelemetry integration.
- The project demonstrates how a Python-based events app can use distributed tracing (via OpenTelemetry) to monitor inter-component calls.
- The application consists of:
- A Flask-based Frontend (user interface) rendering HTML.
- A FastAPI-based Backend that exposes REST APIs.
- A PostgreSQL datastore to hold event and participant data.
- Integration with Jaeger for visualizing telemetry data.

##### Analyzing the File Structure
- Top-level directories and files:
- “frontend” directory: Contains the Flask application, Dockerfile, requirements and HTML templates.
- “backend” directory: Contains the FastAPI application, Dockerfile, and dependencies.
- Root-level files like Docker Compose, Makefile, and bootstrap.py indicate container orchestration and easy spin-up of the entire environment.
- The presence of separate Dockerfiles for frontend and backend and a unified docker-compose.yaml file suggests a containerized environment where each component runs in its own container.

##### Key Components to Capture
a. Frontend:
- Handles UI rendering and user requests.
- Technologies: Flask, HTML templates.
b. Backend:
- Serves API calls, processes requests, and fetches data.
- Technologies: FastAPI, Python.
c. Datastore:
- Stores events and participants information.
d. Observability:
- OpenTelemetry instrumentation captures and traces calls between components, with traces visualized on the Jaeger dashboard.
e. Infrastructure/Orchestration:
- Containers: Use of Docker (each component containerized) and docker-compose to orchestrate services.
- Build/config: Makefile, bootstrap.py indicate simplified deployment and initialization.

##### Mapping Relationships and Data Flow
- User / Browser → Frontend: representing HTTP requests.
- Frontend → Backend: API calls from Flask to FastAPI endpoints.
- Backend → PostgreSQL: Data queries and transactions.
- Backend → OpenTelemetry: Tracing instrumentation gathering and sending telemetry data.
- OpenTelemetry → Jaeger: Flow of trace data for monitoring.
- That the telemetry collecting mechanism spans across the Frontend, Backend, and Database interactions.

##### Highlighting Architectural Patterns and Design Principles
- Separation of Concerns: Clear division between presentation (Frontend), business logic (Backend), and data (PostgreSQL).
- Containerization: Illustrate that each major component (Frontend, Backend, Database, and possibly Jaeger) runs in its own Docker container.
- Observability: Integration of tracing for end-to-end monitoring.

## Diagram (Mermaid)

```mermaid
graph TD
    User["User/Browser"]:::user
    Frontend["Frontend (Flask App)"]:::frontend
    Backend["Backend API (FastAPI)"]:::backend
    Database["PostgreSQL Datastore"]:::database
    OT["OpenTelemetry Agent"]:::observability
    Jaeger["Jaeger Dashboard"]:::observability
    Orchestration["Infrastructure/Orchestration"]:::orchestration

    User -->|"HTTP_requests"| Frontend
    Frontend -->|"API_calls"| Backend
    Backend -->|"DB_queries"| Database
    Frontend -->|"telemetry_data"| OT
    Backend -->|"telemetry_data"| OT
    OT -->|"trace_data"| Jaeger
    Orchestration -.->|"orchestrates"| Frontend
    Orchestration -.->|"orchestrates"| Backend
    Orchestration -.->|"orchestrates"| Database
    Orchestration -.->|"orchestrates"| OT

    click Frontend "https://github.com/rishabhdas/events-app-opentelemetry/blob/main/frontend/app.py"
    click Backend "https://github.com/rishabhdas/events-app-opentelemetry/blob/main/backend/app.py"
    click Orchestration "https://github.com/rishabhdas/events-app-opentelemetry/blob/main/docker-compose.yaml"

    classDef user fill:#f5c6cb,stroke:#721c24,stroke-width:2px;
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef database fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef observability fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef orchestration fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
