# longwater1234/wedemyclient architecture

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

- Interactive diagram: https://gitdiagram.com/longwater1234/wedemyclient
- Repository: https://github.com/longwater1234/wedemyclient

## Overview

The WedemyClient project is a modern, progressive web app (PWA) built as a frontend clone of Udemy. It leverages Vue 3, Vite, and TypeScript and uses a component-based architecture alongside centralized state management (via Pinia). The app is designed to handle online course browsing, enrollment, and checkout with integration to external services like Braintree for payments and Google for OAuth-based login.

##### Main Components
- Frontend/UI Layer:
- Vue Components (found in src/components and src/views). These include visual parts such as the Navbar, Footer, Cart Summary, Course Details, and the various pages (Home, Login, Signup, Checkout, etc.).
- Routing:
- Vue Router system (located under src/router) that manages how users navigate between views.
- State Management:
- Pinia store (located in src/stores) that maintains application state across multiple components.
- Service Layer:
- Service modules (in src/service) providing API calls and business logic. These include authentication, course management, checkout processing, enrollment, profile handling, etc.
- Assets & Interfaces:
- Assets (images, logos, and styles) and interface definitions (in src/interfaces) that define TypeScript types for ensuring consistency.
- External Integrations:
- Braintree Payments for checkout.
- Google OAuth for sign-in functionality.
- YouTube (for embedded video playback).
- Environment & Configurations:
- Environment variables (.env file based on .env.sample) and build configuration (vite.config.ts) for setting up deployments.

##### Relationships and Interactions
- The UI components (Views and Components) interact with the centralized state (Pinia) to reflect dynamic data and trigger service calls.
- The Vue Router mediates screen-level navigation; each route is associated with a specific view.
- Service modules are responsible for handling business logic and API interactions. They communicate with backend endpoints (which are provided by a separate Java Springboot application) and external services (Braintree, Google OAuth).
- The interfaces in src/interfaces ensure data consistency between API responses and the application’s internal state.
- Assets, styles, and configuration files bind the look-and-feel of the application, underpinning the user experience.

##### Architectural Patterns & Design Principles
- Component-Based Architecture: Each Vue component is a distinct, reusable part of the User Interface.
- Centralized State Management: Use of Pinia enables global state sharing and modularized management of application data.
- Separation of Concerns: Splitting the project into services (business logic), components (UI), and state stores (data management) to keep the codebase organized.
- API Abstraction: Service modules abstract away the direct REST calls to the backend and to third-party services (e.g., Braintree, Google OAuth), making integration and future modifications easier.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global User
    User("User"):::ui

    %% Frontend Client
    subgraph "Frontend Client"
        %% Presentation Layer
        subgraph "Presentation Layer"
            Navbar("Navbar"):::ui
            Footer("Footer"):::ui
            CartSummary("Cart Summary"):::ui
            CourseDetails("Course Details"):::ui
            HomeView("Home"):::ui
            LoginView("Login"):::ui
            SignupView("Signup"):::ui
            CheckoutView("Checkout"):::ui
            subgraph "Static Assets & Interfaces"
                Assets("Assets"):::ui
                CustomInterface("custom.ts"):::ui
                WedemyInterface("wedemy.ts"):::ui
            end
        end
        %% Navigation & State Management
        subgraph "Navigation & State Management"
            Router("Vue Router"):::state
            Pinia("Pinia Store"):::state
        end
    end

    %% Service Layer
    subgraph "Service Layer"
        AuthService("AuthService"):::service
        CourseService("CourseService"):::service
        CheckoutService("CheckoutService"):::service
    end

    %% External Services
    subgraph "External Services"
        Braintree("Braintree Payment"):::external
        GoogleOAuth("Google OAuth"):::external
        YouTube("YouTube"):::external
    end

    %% Backend API
    Backend("Backend API (Java Springboot)"):::external

    %% Configurations
    subgraph "Configurations"
        Env(".env Config"):::config
        Build("Build Config"):::config
    end

    %% Connections
    User -->|"triggers"| Navbar
    User -->|"triggers"| CartSummary

    %% Frontend Client: Routing and Views
    Navbar -->|"navigates"| Router
    HomeView -->|"routed by"| Router
    LoginView -->|"routed by"| Router
    SignupView -->|"routed by"| Router
    CheckoutView -->|"routed by"| Router

    Router -->|"updates"| Pinia
    Pinia -->|"reactively updates"| HomeView
    Pinia -->|"reactively updates"| CourseDetails

    %% UI to Service Calls
    LoginView -->|"calls"| AuthService
    CourseDetails -->|"fetches data"| CourseService
    CheckoutView -->|"initiates checkout"| CheckoutService

    %% Service Layer to External Services and Backend
    AuthService -->|"authenticates via"| GoogleOAuth
    AuthService -->|"fetches user data from"| Backend

    CourseService -->|"retrieves course info from"| Backend
    CourseService -->|"embeds video from"| YouTube

    CheckoutService -->|"processes payment via"| Braintree
    CheckoutService -->|"updates order in"| Backend

    %% Configurations influence Frontend and Service Layers
    Env -->|"configures"| Navbar
    Env -->|"configures"| AuthService
    Build -->|"builds"| Pinia
    Build -->|"builds"| CheckoutService

    %% Static Assets & Interfaces
    Assets -->|"provide visuals to"| Navbar
    Assets -->|"provide visuals to"| Footer
    CustomInterface -->|"defines types for"| CourseService
    WedemyInterface -->|"defines types for"| AuthService

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px,color:#000;
    classDef state fill:#90EE90,stroke:#000,stroke-width:1px,color:#000;
    classDef service fill:#98FB98,stroke:#000,stroke-width:1px,color:#000;
    classDef external fill:#FFC0CB,stroke:#000,stroke-width:1px,color:#000;
    classDef config fill:#FFD700,stroke:#000,stroke-width:1px,color:#000;

    %% Click Events
    click Navbar "https://github.com/longwater1234/wedemyclient/blob/main/src/components/Navbar.vue"
    click Footer "https://github.com/longwater1234/wedemyclient/blob/main/src/components/Footer.vue"
    click CartSummary "https://github.com/longwater1234/wedemyclient/blob/main/src/components/CartSummary.vue"
    click CourseDetails "https://github.com/longwater1234/wedemyclient/blob/main/src/components/CourseDetails.vue"
    click HomeView "https://github.com/longwater1234/wedemyclient/blob/main/src/views/Home.vue"
    click LoginView "https://github.com/longwater1234/wedemyclient/blob/main/src/views/Login.vue"
    click SignupView "https://github.com/longwater1234/wedemyclient/blob/main/src/views/Signup.vue"
    click CheckoutView "https://github.com/longwater1234/wedemyclient/blob/main/src/views/Checkout.vue"
    click Router "https://github.com/longwater1234/wedemyclient/blob/main/src/router/index.ts"
    click Pinia "https://github.com/longwater1234/wedemyclient/blob/main/src/stores/modules/studentStore.ts"
    click AuthService "https://github.com/longwater1234/wedemyclient/blob/main/src/service/AuthService.ts"
    click CourseService "https://github.com/longwater1234/wedemyclient/blob/main/src/service/CourseService.ts"
    click CheckoutService "https://github.com/longwater1234/wedemyclient/blob/main/src/service/CheckoutService.ts"
    click Assets "https://github.com/longwater1234/wedemyclient/tree/main/src/assets"
    click CustomInterface "https://github.com/longwater1234/wedemyclient/blob/main/src/interfaces/custom.ts"
    click WedemyInterface "https://github.com/longwater1234/wedemyclient/blob/main/src/interfaces/wedemy.ts"
    click Env "https://github.com/longwater1234/wedemyclient/blob/main/.env.sample"
    click Build "https://github.com/longwater1234/wedemyclient/blob/main/vite.config.ts"
```
