# salehairum/cs4067-assignment-02-k224360-saleha_irum architecture

> Architecture diagram of the GitHub repository salehairum/cs4067-assignment-02-k224360-saleha_irum, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/salehairum/cs4067-assignment-02-k224360-saleha_irum
- Repository: https://github.com/salehairum/cs4067-assignment-02-k224360-saleha_irum

## Overview

##### Project Type and Purpose
- This is a microservices-based Online Event Booking System.
- It exposes multiple independent services (User, Event, Booking, Notification, Payment) that collaborate via REST (synchronous) and RabbitMQ (asynchronous) to handle user registration, event management, booking, notifications, and payments.

##### Main Components
a. Frontend
- Static HTML/CSS/JS UI served from a web server or CDN.
b. User Service (FastAPI + PostgreSQL)
c. Event Service (Spring Boot + MongoDB)
d. Booking Service (Flask + PostgreSQL)
e. Notification Service (Flask + MongoDB) + Consumer
f. Payment Service (Flask mock)
g. Databases
- PostgreSQL instances for User & Booking services
- MongoDB instances for Event & Notification services
h. Messaging Layer
- RabbitMQ broker for async events (e.g., booking created → notifications, payment)
i. (Optional) API Gateway or Reverse Proxy

##### Component Relationships and Data Flow
1. User interacts with the Frontend.
2. Frontend issues REST calls to:
- User Service for registration/login
- Event Service for listing/searching events
- Booking Service to book an event
3. Booking Service writes booking data to its PostgreSQL, then publishes a “BookingCreated” event to RabbitMQ.
4. Notification Service’s consumer subscribes to “BookingCreated”, saves to MongoDB, and pushes email/SMS.
5. Payment Service subscribes or is called synchronously after booking to process payment.
6. Services may call one another synchronously (e.g., Booking Service calls User Service to validate user) over REST.

##### Architectural Patterns & Principles
- Microservices: each service is separately deployable, with its own database (polyglot persistence).
- Event-driven: decoupled async processing via RabbitMQ.
- Clear separation of concerns: user, event, booking, notification, payment.
- Technology diversity: FastAPI, Spring Boot, Flask tailored to service needs.

##### Essential Elements
- Clear component labels (Service Name + Tech + Port).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend
    Frontend["Frontend UI<br/>(HTML/CSS/JS)"]:::frontend

    %% Backend Services
    UserService["User Service<br/>(FastAPI, PostgreSQL, :8000)"]:::python
    EventService["Event Service<br/>(Spring Boot, MongoDB, :8080)"]:::java
    BookingService["Booking Service<br/>(Flask, PostgreSQL, :5000)"]:::python
    NotificationService["Notification Service<br/>(Flask Consumer, MongoDB, :5001)"]:::python
    PaymentService["Payment Service<br/>(Flask Mock, :5002)"]:::python

    %% Message Broker
    RabbitMQ((RabbitMQ Broker)):::broker

    %% Databases
    UserDB[(User PostgreSQL)]:::dbpg
    BookingDB[(Booking PostgreSQL)]:::dbpg
    EventDB[(Event MongoDB)]:::dbmongo
    NotificationDB[(Notification MongoDB)]:::dbmongo

    %% Init Scripts
    DBInitSQL["PostgreSQL Init Script"]:::script
    MongoInit["MongoDB Init Script"]:::script

    %% Orchestration
    Orchestration["Compose & Env"]:::orchestration
    Docs["README"]:::docs

    %% Layout
    Frontend -->|REST: /users,/events,/bookings| UserService
    Frontend -->|REST: /events/list| EventService
    Frontend -->|REST: /bookings/create| BookingService

    BookingService -->|"HTTP POST /users/validate"| UserService
    BookingService -->|Publish BookingCreated| RabbitMQ

    RabbitMQ -->|"BookingCreated"| NotificationService
    RabbitMQ -.->|"BookingCreated"| PaymentService

    UserService -->|Writes| UserDB
    BookingService -->|Writes| BookingDB
    EventService -->|Writes| EventDB
    NotificationService -->|Writes| NotificationDB

    DBInitSQL --> UserDB
    DBInitSQL --> BookingDB
    MongoInit --> EventDB
    MongoInit --> NotificationDB

    Orchestration --> RabbitMQ
    Orchestration --> UserService
    Orchestration --> EventService
    Orchestration --> BookingService
    Orchestration --> NotificationService
    Orchestration --> PaymentService

    Orchestration --> DBInitSQL
    Orchestration --> MongoInit

    Docs --> Orchestration

    %% Click Events
    click BookingService "https://github.com/salehairum/cs4067-assignment-02-k224360-saleha_irum/tree/main/booking_services/"
    click UserService "https://github.com/salehairum/cs4067-assignment-02-k224360-saleha_irum/tree/main/user_services/"
    click Orchestration "https://github.com/salehairum/cs4067-assignment-02-k224360-saleha_irum/blob/main/compose.yaml"
    click DBInitSQL "https://github.com/salehairum/cs4067-assignment-02-k224360-saleha_irum/blob/main/init.sql"
    click MongoInit "https://github.com/salehairum/cs4067-assignment-02-k224360-saleha_irum/blob/main/init-mongo.js"
    click Docs "https://github.com/salehairum/cs4067-assignment-02-k224360-saleha_irum/blob/main/README.md"

    %% Styles
    classDef frontend fill:#f2f2f2,stroke:#333,stroke-width:1px
    classDef python fill:#cce5ff,stroke:#0366d6,stroke-width:1px
    classDef java fill:#d4f4dd,stroke:#196619,stroke-width:1px
    classDef dbpg fill:#ffe5b4,stroke:#cc7a00,stroke-width:1px
    classDef dbmongo fill:#ccece6,stroke:#008080,stroke-width:1px
    classDef broker fill:#e5d4f4,stroke:#800080,stroke-width:1px
    classDef script fill:#f9e79f,stroke:#b7950b,stroke-width:1px
    classDef orchestration fill:#f0f0f0,stroke:#555,stroke-width:1px
    classDef docs fill:#f5f5f5,stroke:#999,stroke-width:1px
```
