# antabot/white-jotter architecture

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

- Interactive diagram: https://gitdiagram.com/antabot/white-jotter
- Repository: https://github.com/antabot/white-jotter

## Overview

##### Main Components
- Frontend: Represented by the “wj-vue” folder, this component contains the Vue.js code along with build scripts (webpack configurations, Babel, ESLint, etc.). Indicate the use of ElementUI for UI components and axios for API calls.
- Backend: Represented by the “wj” folder containing the Spring Boot application, it handles requests, business logic, and serves static assets when needed. This part includes controllers (e.g. LoginController, JotterController), services, data access (DAOs), and configurations for technologies like Apache Shiro (security), Log4j2 (logging), and Redis (caching).
- Database: Two major data stores are used – MySQL (as evidenced in the README and through the provided MySQL scripts) and Redis (for caching or session management).

##### Interactions & Data Flow
- Build & Deployment Flow: In the frontend component (wj-vue), illustrate the roles of webpack-based build scripts (located under the “build” directory). Optionally show how the “npm run build” command produces the final “dist” folder, whose static files are then deployed as part of the backend’s static resources.

##### Architectural Patterns and Design Principles
- MVC Pattern: The backend clearly follows an MVC-like approach with controllers, services, and DAOs.
- Frontend SPA: The Vue.js project is structured to work as a single-page application using Vue components, routing, and state management (via the Vuex store).
- Separation of Concerns & RESTful API: Emphasize that the frontend and backend are decoupled, with clear API boundaries and port forwarding (as shown in the README instructions about using port 8080 for development and a different port, 8443, for production after packaging).
- Security by Design: The integration of Apache Shiro emphasizes role-based access and user authentication.

##### Final Elements
- How users’ browsers interact with the Vue.js frontend.
- How AJAX/API calls flow from the frontend to the backend.
- How the backend communicates with databases and caches.
- Use annotations to delineate which sections pertain to authentication (Apache Shiro) and which to static content serving (backend’s /static resources).

This detailed approach ensures that every critical piece of architecture – the frontend, backend, databases, and supportive services – is well-documented and easy for any engaged engineer to understand and build upon.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser("User's Browser"):::external

    subgraph "Frontend Layer"
        FE_Vue("Frontend (Vue.js)"):::frontend
        FE_Build("Build & Build Scripts"):::build
        FE_Config("Config Scripts"):::build
    end

    subgraph "Backend Layer"
        BE("Backend (Spring Boot)"):::backend
        BE_Controllers("Controllers/Services/DAOs"):::backend
        subgraph "Security"
            ShiroConfig("ShiroConfiguration.java"):::security
            WJRealm("WJRealm.java"):::security
        end
        subgraph "Caching"
            RedisConfig("RedisConfig.java"):::security
            RedisService("RedisService.java"):::security
        end
        subgraph "Databases"
            MySQLSchema("schema.sql"):::database
            MySQLData("data.sql"):::database
            MySQLScript("wj.sql"):::database
            MySQL("MySQL Database"):::database
            Redis("Redis Instance"):::database
        end
        BE_Static("Static Assets (Packaged Frontend)"):::external
        BE_ES("Elasticsearch Service"):::external
    end

    %% Interactions & Data Flow
    Browser -->|"loads"| FE_Vue
    FE_Vue -->|"includes-scripts-from"| FE_Build
    FE_Vue -->|"uses"| FE_Config
    FE_Vue -->|"calls(API via axios)"| BE_Controllers

    BE --> BE_Controllers
    BE_Controllers -->|"securedBy"| ShiroConfig
    ShiroConfig -->|"uses"| WJRealm
    BE_Controllers -->|"persistsTo"| MySQL
    BE_Controllers -->|"cachesUsing"| Redis

    FE_Build -->|"npm_run_build_creates"| BE_Static

    BE_Controllers -->|"logs/search"| BE_ES

    %% Internal Database links
    MySQLSchema --> MySQL
    MySQLData --> MySQL
    MySQLScript --> MySQL

    RedisConfig --> Redis
    RedisService --> Redis

    %% Click Events for Component Mapping
    click FE_Vue "https://github.com/antabot/white-jotter/tree/master/wj-vue/"
    click FE_Build "https://github.com/antabot/white-jotter/tree/master/wj-vue/build/"
    click FE_Config "https://github.com/antabot/white-jotter/tree/master/wj-vue/config/"
    click BE "https://github.com/antabot/white-jotter/tree/master/wj/"
    click ShiroConfig "https://github.com/antabot/white-jotter/blob/master/wj/src/main/java/com/gm/wj/config/ShiroConfiguration.java"
    click WJRealm "https://github.com/antabot/white-jotter/blob/master/wj/src/main/java/com/gm/wj/realm/WJRealm.java"
    click RedisConfig "https://github.com/antabot/white-jotter/blob/master/wj/src/main/java/com/gm/wj/config/RedisConfig.java"
    click RedisService "https://github.com/antabot/white-jotter/blob/master/wj/src/main/java/com/gm/wj/redis/RedisService.java"
    click MySQLSchema "https://github.com/antabot/white-jotter/blob/master/wj/src/main/resources/schema.sql"
    click MySQLData "https://github.com/antabot/white-jotter/blob/master/wj/src/main/resources/data.sql"
    click MySQLScript "https://github.com/antabot/white-jotter/blob/master/wj/wj.sql"
    click BE_Static "https://github.com/antabot/white-jotter/tree/master/wj/src/main/resources/static"
    click BE_ES "https://github.com/antabot/white-jotter/tree/master/wj/data/elasticsearch"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:2px;
    classDef frontend fill:#b3e5fc,stroke:#0277bd,stroke-width:2px;
    classDef backend fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;
    classDef database fill:#fff9c4,stroke:#f57f17,stroke-width:2px;
    classDef security fill:#ffcdd2,stroke:#c62828,stroke-width:2px;
    classDef build fill:#d1c4e9,stroke:#512da8,stroke-width:2px;

    class Browser external;
    class FE_Vue,FE_Build,FE_Config frontend;
    class BE,BE_Controllers backend;
    class ShiroConfig,WJRealm,RedisConfig,RedisService security;
    class MySQL,Redis,MySQLSchema,MySQLData,MySQLScript database;
    class BE_Static,BE_ES external;
```
