# paul-austin-oswego-csc480-hci521/oz-csc-480-hci-521-spring-2025 architecture

> Architecture diagram of the GitHub repository paul-austin-oswego-csc480-hci521/oz-csc-480-hci-521-spring-2025, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/paul-austin-oswego-csc480-hci521/oz-csc-480-hci-521-spring-2025
- Repository: https://github.com/paul-austin-oswego-csc480-hci521/oz-csc-480-hci-521-spring-2025

## Overview

##### Project type and purpose
- This is a full-stack web application (“Quotable”) that lets users and guests search, manage, favorite, and share inspirational quotes.
- It uses two Java microservices (user-service and quote-service) on Open Liberty (MicroProfile), a React/Vite frontend, an NGINX proxy, MongoDB as the primary data store, and Google OAuth for authentication.

##### File structure
- Top-level:
- docker-compose.yml orchestrates containers
- proxy/ holds the NGINX proxy config
- frontend/src/main/frontend contains a React/Vite SPA
- _backend/services/quote-service and user-service each contain a MicroProfile Java service
- Each service has its own Dockerfile, server.xml (Liberty), microprofile-config, resource endpoints (RESTApplication, *Resource.java), and client classes for inter-service calls (UserClient, QuoteClient).
- The .env and microprofile-config.properties define endpoints for proxy, user-service, quote-service, and OAuth credentials.

##### Main components
a. Client Tier
- User’s Browser (SPA)
b. Presentation & Routing Tier
- React/Vite container (serves index.html, JS/CSS assets)
- NGINX Proxy container (routes /users/* → user-service, /quotes/* → quote-service, /auth/callback → user-service/auth, static → frontend)
c. Business Logic Tier (Microservices)
- User Service
– Modules: Auth (JwtService, SessionService), Accounts, Bookmarks, Notifications, SharedQuotes, UsedQuotes
– Exposes REST endpoints via RestApplication
- Quote Service
– Modules: QuoteCreate/Read/Update/Delete, Moderation (ProfanityClass, DeleteService), Reporting
– Exposes REST endpoints via RestApplication
- Inter-service calls:
– User-service uses QuoteClient to fetch quote info
– Quote-service uses UserClient to fetch user data
d. Data Tier
- MongoDB container (one or two databases/collections for users and quotes; accessed via MongoUtil)
e. External Services
- Google OAuth 2.0 (CLIENT_ID, CLIENT_SECRET, REDIRECT_URI)

##### Relationships and data flows
- Browser → NGINX Proxy (HTTP) →
- Static assets → React/Vite
- API calls → appropriate microservice
- Microservices → MongoDB (read/write)
- Microservices ↔ each other (UserClient ↔ QuoteClient)
- User-service → Google OAuth (redirect, token exchange)
- Docker Compose orchestrates and links all containers

##### Architectural patterns & principles
- Microservices: two independent stateless services, each in its own container
- API Gateway / Reverse Proxy: NGINX routes requests and enforces CORS, TLS, host headers
- Single-Page Application: React app decoupled from backend, communicates over JSON REST
- Containerization & Orchestration: Docker Compose defines service dependencies and network links
- Configuration-as-Code: .env, microprofile-config.properties, server.xml
- Automated CI/CD & Testing: GitHub Actions workflows under .github/workflows, Playwright tests

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Orchestration Layer
    subgraph "Orchestration"
        DC["Docker Compose (Orchestration)"]:::orchestration
    end

    %% Client Tier
    subgraph "Client Tier"
        Browser["User’s Browser"]:::frontend
        Playwright["Playwright E2E Tests"]:::external
    end

    %% Presentation & Routing Tier
    subgraph "Routing & Presentation"
        NGINX["NGINX Proxy"]:::gateway
        SPA["React/Vite SPA"]:::frontend
    end

    %% Business Logic Tier
    subgraph "Business Logic Tier"
        subgraph "User Service"
            US["User Service\n(Java MicroProfile)"]:::microservice
        end
        subgraph "Quote Service"
            QS["Quote Service\n(Java MicroProfile)"]:::microservice
        end
    end

    %% Data Tier
    DB["MongoDB"]:::db

    %% External Services
    OAuth["Google OAuth 2.0"]:::external

    %% Connections
    Browser -->|"HTTP" | NGINX
    Browser -->|"E2E Tests"| Playwright
    NGINX -->|"Static Assets"| SPA
    NGINX -->|"/users/*, /auth/*"| US
    NGINX -->|"/quotes/*"| QS
    SPA -->|"API Calls"| NGINX
    US -->|"Read/Write"| DB
    QS -->|"Read/Write"| DB
    US -.->|"QuoteClient"| QS
    QS -.->|"UserClient"| US
    US -->|"OAuth Redirect/Token"| OAuth

    DC --> NGINX
    DC --> SPA
    DC --> US
    DC --> QS
    DC --> DB

    %% Click Events
    click DC "https://github.com/paul-austin-oswego-csc480-hci521/oz-csc-480-hci-521-spring-2025/blob/main/docker-compose.yml"
    click NGINX "https://github.com/paul-austin-oswego-csc480-hci521/oz-csc-480-hci-521-spring-2025/tree/main/proxy/Dockerfile"
    click SPA "https://github.com/paul-austin-oswego-csc480-hci521/oz-csc-480-hci-521-spring-2025/tree/main/frontend/src/main/frontend/"
    click Playwright "https://github.com/paul-austin-oswego-csc480-hci521/oz-csc-480-hci-521-spring-2025/blob/main/playwright.config.ts"
    click US "https://github.com/paul-austin-oswego-csc480-hci521/oz-csc-480-hci-521-spring-2025/tree/main/_backend/services/user-service/"
    click QS "https://github.com/paul-austin-oswego-csc480-hci521/oz-csc-480-hci-521-spring-2025/tree/main/_backend/services/quote-service/"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,stroke-width:2px
    classDef gateway fill:#DFFFE0,stroke:#28a745,stroke-width:2px
    classDef microservice fill:#FFE8C0,stroke:#d97706,stroke-width:2px
    classDef db fill:#E0E0E0,stroke:#6c757d,stroke-width:2px,stroke-dasharray: 5 5
    classDef external fill:#F0F0F0,stroke:#6c757d,stroke-width:2px,stroke-dasharray: 2 2
    classDef orchestration fill:#FFF3CD,stroke:#856404,stroke-width:2px,stroke-dasharray: 5 5
```
