# dks044/wordwave architecture

> Architecture diagram of the GitHub repository dks044/wordwave, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dks044/wordwave
- Repository: https://github.com/dks044/wordwave

## Overview

##### Main Components
- Frontend Client:
- The React application lives under the src/main/frontend folder and is built with modules, containers, and components. This module handles the UI, API communication, routing (React Router), state management (Redux and Redux Saga), and interacts with presentation libraries (styled-components, Bootstrap, etc.).
- Backend Server:
- The backend code is found in src/main/java/com/wordwave, using Spring Boot for REST services. Different modules such as grammar, voca, myvoca, myvocabook, and user (with JWT token handling, Spring Security, and email authentication) exist, organized by domain.
- Database & Caching:
- The application uses a MySQL RDBMS (as indicated by JPA and MySQL badges) and Redis for caching or session-related purposes (e.g., email authentication or refresh token management).
- External/Cloud Components:
- AWS S3 and CloudFront distribute the static frontend build.
- Docker is used to containerize the application (Dockerfile provided) and the CI/CD flow is orchestrated via GitHub Actions (.github/workflows).
- EC2 instances are used to host the backend container, with automated deployment steps (pulling new Docker images and running Docker Compose).

##### Relationships and Data Flow
- The backend validates JWTs and processes these requests by interacting with the MySQL database via JPA, and caching or auxiliary operations are handled via Redis.
- During authentication, the backend distinguishes between saving the refresh token on the server and issuing an access token stored in cookies on the frontend.
- The CI/CD pipeline (GitHub Actions) integrates with Docker to build images, push them to Docker Hub, and deploy to EC2.
- HTTPS is enforced throughout, and the entire communication (especially the API calls) is secured.
- The external build/deployment process shows a clear interaction where the Dockerfile and Gradle scripts compile and package the Java application, while the Node-based build tools work for the frontend.

##### Key Architectural Patterns
- Separation of Concerns: There is a clear division between frontend and backend.
- Modular Design: Both the frontend and backend are well segmented into components (e.g., grammar, myvoca, voca) and layers (controllers, services, repositories).
- CI/CD and Containerization: Automated integration, testing, and deployment pipelines, with containerized deployment ensuring consistency across environments.
- Security with JWT and Spring Security: Focus on secure authentication/authorization flows.

##### Technologies and Their Roles
- Frontend: React, Redux, Redux Saga, Axios, React Router.
- Backend: Java, Spring Boot, Spring Security, JPA, MySQL, Redis.
- Deployment and Infrastructure: Docker, AWS (EC2, S3, CloudFront), GitHub Actions.
- Additional: Swagger for API documentation, and Git for version control.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    UB("User Browser"):::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE("React Frontend (src/main/frontend)"):::frontend
        FEM("Frontend Modules (src/main/frontend/src)"):::frontend
        GrammarFE("Grammar Quiz FE"):::frontend
        VocaFE("Vocabulary Quiz FE"):::frontend
        MyVocaFE("MyVoca & MyVocaBook FE"):::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE("Spring Boot Backend (src/main/java/com/wordwave)"):::backend
        Auth("User & Auth (JWT,SpringSecurity)"):::backend
        GrammarBE("Grammar Quiz BE"):::backend
        VocaBE("Vocabulary Quiz BE"):::backend
        MyVocaBE("MyVoca & MyVocaBook BE"):::backend
        DB("MySQL Database"):::database
        Redis("Redis Cache"):::database
        Cloud("AWS S3/CloudFront"):::external
    end

    %% DevOps & Deployment
    subgraph "DevOps & Deployment"
        CI("GitHubActions CI/CD (.github/workflows)"):::ci
        Docker("Docker Container (Dockerfile)"):::ci
        EC2("EC2 Instance"):::ci
    end

    %% Connections - Client to Frontend and Cloud Distribution
    UB -->|"HTTPS"| FE
    Cloud -->|"Delivers static assets"| UB

    %% Frontend internal flows
    FE -->|"Load modules"| FEM
    FEM -->|"Uses"| GrammarFE
    FEM -->|"Uses"| VocaFE
    FEM -->|"Uses"| MyVocaFE
    FE -->|"RESTcalls"| BE

    %% Backend internal flows
    BE -->|"HandlesAuth"| Auth
    BE -->|"Executes"| GrammarBE
    BE -->|"Executes"| VocaBE
    BE -->|"Executes"| MyVocaBE
    BE -->|"JPAinteracts"| DB
    BE -->|"Cacheswith"| Redis

    %% DevOps flows
    CI -->|"Builds image"| Docker
    Docker -->|"Deploys container"| EC2
    CI -->|"Triggers deploy"| EC2
    EC2 -->|"Hosts"| BE

    %% Click Events for Frontend
    click FE "https://github.com/dks044/wordwave/tree/main/src/main/frontend"
    click FEM "https://github.com/dks044/wordwave/tree/main/src/main/frontend/src"
    click GrammarFE "https://github.com/dks044/wordwave/tree/main/src/main/frontend/src/components/grammar"
    click VocaFE "https://github.com/dks044/wordwave/tree/main/src/main/frontend/src/components/voca"
    click MyVocaFE "https://github.com/dks044/wordwave/tree/main/src/main/frontend/src/components/myVoca"

    %% Click Events for Backend
    click BE "https://github.com/dks044/wordwave/tree/main/src/main/java/com/wordwave"
    click Auth "https://github.com/dks044/wordwave/tree/main/src/main/java/com/wordwave/security"
    click GrammarBE "https://github.com/dks044/wordwave/tree/main/src/main/java/com/wordwave/grammar"
    click VocaBE "https://github.com/dks044/wordwave/tree/main/src/main/java/com/wordwave/voca"
    click MyVocaBE "https://github.com/dks044/wordwave/tree/main/src/main/java/com/wordwave/myvoca"
    click Redis "https://github.com/dks044/wordwave/blob/main/src/main/java/com/wordwave/redis/RedisConfig.java"
    click Cloud "https://github.com/dks044/wordwave/tree/main/src/main/java/com/wordwave/aws"

    %% Click Events for DevOps
    click CI "https://github.com/dks044/wordwave/tree/main/.github/workflows"
    click Docker "https://github.com/dks044/wordwave/tree/main/Dockerfile"

    %% Styling
    classDef frontend fill:#ffdddd,stroke:#d62728,stroke-width:2px;
    classDef backend fill:#ddeeff,stroke:#1f77b4,stroke-width:2px;
    classDef database fill:#ddffdd,stroke:#2ca02c,stroke-width:2px;
    classDef external fill:#ffffcc,stroke:#ff7f0e,stroke-width:2px;
    classDef ci fill:#e5ffe5,stroke:#9467bd,stroke-width:2px;
    class UB,Cloud external;
    class FE,FEM,GrammarFE,VocaFE,MyVocaFE frontend;
    class BE,Auth,GrammarBE,VocaBE,MyVocaBE backend;
    class DB,Redis database;
    class CI,Docker,EC2 ci;
```
