# timothyphan2/cs157a-coursebrief architecture

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

- Interactive diagram: https://gitdiagram.com/timothyphan2/cs157a-coursebrief
- Repository: https://github.com/timothyphan2/cs157a-coursebrief

## Overview

##### Project type and purpose
- CourseBrief is a full-stack web application for searching and discovering CS and CMPE courses at SJSU.
- Components:
- A React-based frontend (Vite).
- A Spring Boot REST API backend.
- A MySQL relational database.
- A Spring Shell–based admin CLI for course/tag management.

##### File structure
- Top level:
- backend/ – Maven project with src/main/java, resources, tests.
- frontend/CourseBrief/ – React (Vite) project.
- SQL scripts (createdb.sql, insertStatements.sql).
- backend structure:
- config/ – security and password configuration.
- controller/ – REST controllers for course, search, user.
- service/ – business logic services.
- repository/ – Spring Data JPA interfaces.
- model/ – JPA entities and embedded IDs.
- CourseBriefAdmin/ – separate CLI app using Spring Shell commands.
- frontend structure:
- src/api/axios.jsx – HTTP client.
- src/components/ – React pages and UI elements.
- src/userAuth/ – authentication context.

##### README for additional insights
- Confirms tech stack: React, Spring Boot, MySQL, Spring Shell.
- Describes startup steps: database scripts, running frontend, running backend, then inserting data, plus admin CLI.

##### Essential details
- Internal layers of the backend:
- Controllers (entry points)
- Services (business logic)
- Repositories (data access)
- Entities (database tables)
- User authentication context in the React app and the Spring Security layer in the backend config.
- Both runtime startup sequence (DB scripts → backend app → frontend server) and request-response flows.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        Browser["Browser Client"]:::ui
        subgraph "React Frontend"
            direction TB
            ReactSPA["Vite + React SPA"]:::ui
            EntryPoint["main.jsx"]:::ui
            RootComponent["App.jsx"]:::ui
            Components["Components"]:::ui
            Axios["axios.jsx"]:::ui
            AuthContext["AuthContext.jsx"]:::ui
            ViteConfig["vite.config.js"]:::ui
        end
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        subgraph "Spring Boot REST API"
            direction TB
            SpringBootApp["CourseBriefApplication.java"]:::server
            SecurityConfig["SecurityConfig.java"]:::server
            WebSecurityConfig["WebSecurityConfig.java"]:::server
            PasswordConfig["PasswordConfig.java"]:::server
            subgraph Controllers
                direction TB
                CourseController["CourseController.java"]:::server
                SearchController["SearchController.java"]:::server
                UserController["UserController.java"]:::server
            end
            ServiceLayer["Service Layer"]:::server
            RepositoryLayer["Repository Layer"]:::server
            ModelLayer["Model Entities"]:::server
        end
        subgraph "Spring Shell Admin CLI"
            direction TB
            CLIApp["CourseBriefAdmin.java"]:::server
            CLICommands["admin/commands"]:::server
            CLIHelpers["admin/helper"]:::server
        end
    end

    %% Database and Scripts
    subgraph "Database & Deployment"
        direction TB
        DB["MySQL Database"]:::db
        Scripts["SQL Scripts"]:::script
        Createdb["createdb.sql"]:::script
        InsertStatements["insertStatements.sql"]:::script
        Dropdb["dropdb.sql"]:::script
    end

    %% Connections
    Browser -->|"loads SPA"| ReactSPA
    ReactSPA -->|"entry point"| EntryPoint
    EntryPoint --> RootComponent
    RootComponent --> Components
    Components -->|"uses"| Axios
    Components -->|"uses"| AuthContext
    ReactSPA -->|"config via"| ViteConfig

    Axios -->|"HTTP/JSON API calls"| SpringBootApp
    SpringBootApp --> SecurityConfig
    SpringBootApp --> WebSecurityConfig
    SpringBootApp --> PasswordConfig
    SpringBootApp --> Controllers
    Controllers --> ServiceLayer
    ServiceLayer --> RepositoryLayer
    RepositoryLayer --> ModelLayer
    RepositoryLayer --> DB

    CLIApp -.->|"invokes beans"| ServiceLayer
    ServiceLayer --> DB

    Scripts --> Createdb
    Scripts --> InsertStatements
    Scripts --> Dropdb
    Createdb --> DB
    InsertStatements --> DB
    Dropdb --> DB

    %% Click Events
    click ReactSPA "https://github.com/timothyphan2/cs157a-coursebrief/tree/main/frontend/CourseBrief"
    click EntryPoint "https://github.com/timothyphan2/cs157a-coursebrief/blob/main/frontend/CourseBrief/src/main.jsx"
    click RootComponent "https://github.com/timothyphan2/cs157a-coursebrief/blob/main/frontend/CourseBrief/src/App.jsx"
    click Components "https://github.com/timothyphan2/cs157a-coursebrief/tree/main/frontend/CourseBrief/src/components"
    click Axios "https://github.com/timothyphan2/cs157a-coursebrief/blob/main/frontend/CourseBrief/src/api/axios.jsx"
    click AuthContext "https://github.com/timothyphan2/cs157a-coursebrief/blob/main/frontend/CourseBrief/src/userAuth/AuthContext.jsx"
    click ViteConfig "https://github.com/timothyphan2/cs157a-coursebrief/blob/main/frontend/CourseBrief/vite.config.js"
    click SpringBootApp "https://github.com/timothyphan2/cs157a-coursebrief/blob/main/backend/src/main/java/com/CS157AProject/CourseBrief/CourseBriefApplication.java"
    click SecurityConfig "https://github.com/timothyphan2/cs157a-coursebrief/blob/main/backend/src/main/java/com/CS157AProject/CourseBrief/config/SecurityConfig.java"
    click WebSecurityConfig "https://github.com/timothyphan2/cs157a-coursebrief/blob/main/backend/src/main/java/com/CS157AProject/CourseBrief/config/WebSecurityConfig.java"
    click PasswordConfig "https://github.com/timothyphan2/cs157a-coursebrief/blob/main/backend/src/main/java/com/CS157AProject/CourseBrief/config/PasswordConfig.java"
    click CourseController "https://github.com/timothyphan2/cs157a-coursebrief/blob/main/backend/src/main/java/com/CS157AProject/CourseBrief/controller/CourseController.java"
    click SearchController "https://github.com/timothyphan2/cs157a-coursebrief/blob/main/backend/src/main/java/com/CS157AProject/CourseBrief/controller/SearchController.java"
    click UserController "https://github.com/timothyphan2/cs157a-coursebrief/blob/main/backend/src/main/java/com/CS157AProject/CourseBrief/controller/UserController.java"
    click ServiceLayer "https://github.com/timothyphan2/cs157a-coursebrief/tree/main/backend/src/main/java/com/CS157AProject/CourseBrief/service"
    click RepositoryLayer "https://github.com/timothyphan2/cs157a-coursebrief/tree/main/backend/src/main/java/com/CS157AProject/CourseBrief/repository"
    click ModelLayer "https://github.com/timothyphan2/cs157a-coursebrief/tree/main/backend/src/main/java/com/CS157AProject/CourseBrief/model"
    click CLIApp "https://github.com/timothyphan2/cs157a-coursebrief/blob/main/backend/src/main/java/com/CS157AProject/CourseBriefAdmin/CourseBriefAdmin.java"
    click CLICommands "https://github.com/timothyphan2/cs157a-coursebrief/tree/main/backend/src/main/java/com/CS157AProject/CourseBriefAdmin/admin/commands"
    click CLIHelpers "https://github.com/timothyphan2/cs157a-coursebrief/tree/main/backend/src/main/java/com/CS157AProject/CourseBriefAdmin/admin/helper"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,color:#004085
    classDef server fill:#d4edda,stroke:#155724,color:#155724
    classDef db fill:#fff3cd,stroke:#856404,color:#856404
    classDef script fill:#e2e3e5,stroke:#6c757d,color:#6c757d
```
