# pablo389/oci-react-samples architecture

> Architecture diagram of the GitHub repository pablo389/oci-react-samples, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pablo389/oci-react-samples
- Repository: https://github.com/pablo389/oci-react-samples

## Overview

##### Project Type & Purpose
– This is a **full‐stack**, Cloud-Native to-do application:
- Frontend: React (SPA) under `backend/src/main/frontend`
- Backend: Spring Boot (Java) under `backend/src/main/java/...`
- Infrastructure as Code: Terraform (OCI) under `terraform/`
- CI/CD: GitHub Actions (`.github/workflows/ci.yml`) and OCI DevOps YAML
– Purpose: allow users to register/login, manage tasks, sprints, KPIs. Deployable to OCI container service.

##### Main Architectural Components
a. Developer & CI/CD
– Local developer machines running `mvnw`, Node/npm, Terraform, OCI-CLI, Python scripts (in `utils/python-scripts/`).
– GitHub repo triggers CI (`ci.yml`) on push → runs tests (`frontend/src/test`, backend unit tests) → builds artifacts.
– CI pushes Docker image to OCI Container Registry (OCIR).

b. Infrastructure Layer (Terraform)
– Modules in `terraform/`:
- `provider.tf` configures OCI provider
- `database.tf` provisions Autonomous DB or Oracle DB
- `containerengine.tf` creates OKE (Kubernetes) cluster
- `apigateway.tf` sets up OCI API Gateway
- `object_storage.tf` for blob storage (optional static assets)
- Outputs for Load Balancer, cluster kubeconfig, DB connection.

c. Runtime Environment (OCI)
– **OCI API Gateway**
- Exposes public HTTP(S) endpoint
- Routes `/api/*` to backend service on cluster
– **OKE (Kubernetes)**
- Kubernetes Deployment + Service running Spring Boot container (serving static React build + REST APIs)
- Horizontal scaling via replicas
– **Oracle Database**
- Persistent data store for Users, ToDoItems, KPIs, Sprints
– **Object Storage** (if used for assets back-up or logs)

d. Application Components
– **Frontend (React SPA)**
- Built by Vite (`vite.config.ts`)
- Components for Layout, Sidebar, TaskForm, TaskList, Theme Toggle
- Calls backend via `src/utils/api.ts`
– **Backend (Spring Boot Monolith)**
- Controllers: Auth, ToDoItem, Sprint, KPI, Bot
- Services & Repositories (JPA)
- Security: JWT filter, WebSecurityConfiguration
- Configuration classes: CORS, DB settings, Oracle config
- Utility classes: Bot commands & helpers

##### Relationships & Data Flows (
– **Developer → GitHub Actions**: push code → CI pipeline
– **CI → OCIR & Terraform**: build Docker image → push registry → apply Terraform
– **Terraform → OCI Resources**: provision OKE, API Gateway, DB, Object Storage
– **API Gateway → Kubernetes Service**: route HTTP requests
– **Kubernetes Pod (Spring Boot)**:
- Serves `index.html` + static assets
- Exposes REST endpoints consumed by SPA
- Interacts with Oracle DB over secure connection
– **Database**: persistent store
– **User → API Gateway**: user’s browser fetches SPA, then issues AJAX calls to backend

##### Architectural Patterns & Principles
– **Infrastructure as Code**: all OCI resources defined in Terraform modules
– **Containerization & Orchestration**: Docker + Kubernetes (OKE)
– **Monolithic Service**: single container serving both UI and API
– **CI/CD**: automated build/test/deploy via GitHub Actions and shell scripts (`build.sh`, `deploy.sh`, `dev.sh`)
– **Security**: JWT auth, CORS configuration

##### Essential Elements to Capture
– Source control & CI/CD flow (GitHub → build → registry)
– Terraform provisioning of OCI services
– OCI API Gateway as entry point
– Kubernetes cluster & pod deployment
– Monolithic container serving both SPA & API
– Oracle DB persistence layer
– User interaction flows (SPA load, API calls)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer & CI/CD
    subgraph "Developer & CI/CD" 
        classDef dev fill:#cce5ff,stroke:#004085,color:#004085;
        classDef ci fill:#d1ecf1,stroke:#0c5460,color:#0c5460;
        Dev["Developer"]:::dev
        GH["GitHub Actions"]:::ci
        OciDevOps["OCI DevOps"]:::ci
        MVN["Maven Wrapper"]:::ci
        MVNWDir[".mvn/"]:::ci
        BuildSh["build.sh"]:::ci
        DeploySh["deploy.sh"]:::ci
        DevSh["dev.sh"]:::ci
    end

    Dev -->|push code| GH
    GH -->|runs CI pipeline| MVN
    GH -->|runs CI pipeline| MVNWDir
    GH -->|runs build scripts| BuildSh
    GH -->|runs deploy scripts| DeploySh
    GH -->|runs dev scripts| DevSh
    Dev -->|uses| OciDevOps

    %% Infrastructure as Code
    subgraph "Terraform Modules" 
        classDef tf fill:#d4edda,stroke:#155724,color:#155724;
        Prov["provider.tf"]:::tf
        Core["core.tf"]:::tf
        Vars["main-var.tf"]:::tf
        AD["availability_domain.tf"]:::tf
        CE["containerengine.tf"]:::tf
        APIGW["apigateway.tf"]:::tf
        DBTF["database.tf"]:::tf
        OBJ["object_storage.tf"]:::tf
        RepoTF["repositories.tf"]:::tf
        OutTF["outputs.tf"]:::tf
    end

    GH -->|triggers terraform apply| Prov
    Prov --> Core --> Vars --> AD --> CE --> APIGW --> DBTF --> OBJ --> RepoTF --> OutTF

    %% OCI Cloud Resources
    subgraph "OCI Cloud" 
        classDef cloud fill:#f8d7da,stroke:#721c24,color:#721c24;
        APIGateway["API Gateway"]:::cloud
        subgraph "OKE (Kubernetes Cluster)"
            classDef kube fill:#fff3cd,stroke:#856404,color:#856404;
            Cluster["K8s Cluster"]:::kube
            Pod["Spring Boot + React Pod"]:::kube
            ContainerReg["OCIR (Container Registry)"]:::cloud
        end
        OracleDB["Oracle Database"]:::cloud
        ObjStorage["Object Storage"]:::cloud
    end

    OutTF --> APIGateway
    OutTF --> Cluster
    OutTF --> OracleDB
    OutTF --> ObjStorage
    GH -->|push image| ContainerReg
    APIGateway -->|routes /api/*| Cluster
    Cluster -->|runs Pod| Pod
    Pod -->|connects| OracleDB
    Pod -->|optionally uses| ObjStorage

    %% User Interaction
    User["User Browser"]:::dev
    User -->|HTTP GET SPA| APIGateway
    APIGateway -->|serves index.html| Pod
    User -->|AJAX calls| APIGateway

    %% Click Events
    click GH "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/.github/workflows/ci.yml"
    click BuildSh "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/backend/build.sh"
    click DeploySh "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/backend/deploy.sh"
    click DevSh "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/backend/dev.sh"
    click MVN "https://github.com/pablo389/oci-react-samples/tree/springboot-bot/MtdrSpring/backend/mvnw"
    click MVNWDir "https://github.com/pablo389/oci-react-samples/tree/springboot-bot/MtdrSpring/backend/.mvn/"
    click Prov "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/terraform/provider.tf"
    click Core "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/terraform/core.tf"
    click Vars "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/terraform/main-var.tf"
    click AD "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/terraform/availability_domain.tf"
    click CE "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/terraform/containerengine.tf"
    click APIGW "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/terraform/apigateway.tf"
    click DBTF "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/terraform/database.tf"
    click OBJ "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/terraform/object_storage.tf"
    click RepoTF "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/terraform/repositories.tf"
    click OutTF "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/terraform/outputs.tf"
    click OciDevOps "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/oci_devops.yml"
    click Dev "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/utils/python-scripts/generate-unique-key.py"
    click Dev "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/utils/python-scripts/process-cluster-ocid-json.py"
    click Dev "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/utils/terraform.sh"
    click Dev "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/utils/main-setup.sh"
    click Dev "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/utils/oke-setup.sh"
    click Dev "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/utils/main-destroy.sh"
    click Dev "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/utils/lb-destroy.sh"
    click Dev "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/utils/os-destroy.sh"
    click Dev "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/utils/repo-destroy.sh"
    click Dev "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/utils/db-setup.sh"
    click Dev "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/utils/java-builds.sh"
    click Dev "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/utils/kube_token_cache.sh"
    click Dev "https://github.com/pablo389/oci-react-samples/blob/springboot-bot/MtdrSpring/utils/state-functions.sh"
    click ContainerReg "https://github.com/pablo389/oci-react-samples/tree/springboot-bot/MtdrSpring/backend/Dockerfile"

    %% Styles
    classDef frontend fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef backend fill:#d6d8db,stroke:#1b1e21,color:#1b1e21;
    classDef database fill:#f5c6cb,stroke:#721c24,color:#721c24;
    classDef container fill:#c3e6cb,stroke:#155724,color:#155724;
    class UserBrowser dev
    class APIGateway cloud
    class Cluster kube
    class Pod container
    class ContainerReg container
    class OracleDB database
    class ObjStorage cloud
```
