# han-dongil/ringle architecture

> Architecture diagram of the GitHub repository han-dongil/ringle, 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/han-dongil/ringle
- Repository: https://github.com/han-dongil/ringle

## Overview

##### Project type and purpose
- This is a full-stack Spring Boot web application for managing course registration (“수강신청 과제”).
- It exposes RESTful APIs secured by JWT tokens, serves a JSP-based UI for users, and includes Swagger UI for interactive API docs.
- User roles: “student” and “tutor”; login via /api/v1/login returns JWT, then clients must send “Authorization: Bearer <token>” for protected endpoints.

##### File structure
- Top-level:
- assignment/src/main/java/com/example/demo: Spring Boot entrypoints and Servlet initializer
- auth: JWT filter, entry point, handlers, user-details service, controllers
- config: OpenAPI (Swagger) and Spring Security config
- module: three domains (classes, members, registration), each with controller, service, dto, mapper
- util: JWT utils and common response wrapper
- resources: application.yml, log4jdbc properties, MyBatis XML mappers
- webapp/WEB-INF/jsp: main-page JSP
- Testing under src/test/java
- Build: Maven (pom.xml)

##### Review README for behavior
- Endpoints start with /api/v1/login (open), /api/v1/student (student only), /api/v1/tutor (tutor only).
- Swagger UI exposed at http://localhost:18089
- Postman or browser can be clients.

##### Main components
a. Clients
- Web Browser (JSP UI + Swagger UI)
- API Clients (Postman, Mobile)
b. API Gateway / Spring Security
- JwtAuthFilter, CustomEntryPoint, AccessDeniedHandler
c. Controllers
- AuthController
- ClassController, MemberController, RegistrationController
- MainViewController (serves JSP)
d. Service Layer
- ClassServiceImpl, MemberServiceImpl, RegistrationServiceImpl
e. Data Access
- MyBatis mappers (class-mapper.xml, members-mapper.xml, registration-mapper.xml)
- Mapper interfaces
f. Database
- Relational DB (e.g. MySQL)
g. Utility and Config
- JwtUtil, CustomResponse
- OpenApiConfig, SecurityConfig
- application.yml, log4jdbc

##### Relationships & interactions
- Client → Spring Security Filter Chain (JwtAuthFilter) → Controllers
- Controllers ↔ Service Layer → MyBatis Mappers → Database
- MainViewController → JSP (view rendering)
- Swagger UI ← OpenAPI config
- Errors handled by GlobalExceptionHandler → CustomExceptionResponse

##### Architectural patterns & principles
- Layered (Web → Controller → Service → DAO → DB)
- Role-based access control via JWT
- MyBatis for data mapping (XML + mapper interfaces)
- Dependency injection via Spring Boot
- Externalized config (YAML, Log4jdbc)

##### Essential elements
- Clear component labels (e.g., “JwtAuthFilter”, “RegistrationService”)
- Detail the MyBatis XML mappers as part of Data Layer

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Clients
    Browser["Web Browser (JSP UI)"]:::external
    APIClient["API Client (Postman/Mobile)"]:::external
    SwaggerUI["Swagger UI"]:::external

    %% Spring Boot Application Container
    subgraph "Spring Boot Application"
        direction TB

        %% Configuration & Entry Points
        AppEntry["ClassApplication"]:::config
        ServletInit["ServletInitializer"]:::config
        SecurityConf["SecurityConfig"]:::security
        OpenApiConf["OpenApiConfig"]:::config

        %% Security Layer
        subgraph "Security Layer"
            direction TB
            JwtFilter["JwtAuthFilter"]:::security
            EntryPoint["CustomEntryPoint"]:::security
            AccessDenied["CustomAccessDeniedHandler"]:::security
            UserDetailsSvc["CustomUserDetailsService"]:::security
        end

        %% Web Layer (Controllers)
        subgraph "Web Layer"
            direction TB
            AuthCtrl["AuthController"]:::web
            MainViewCtrl["MainViewController"]:::web
            ClassCtrl["ClassController"]:::web
            MemberCtrl["MemberController"]:::web
            RegistrationCtrl["RegistrationController"]:::web
        end

        %% Service Layer
        subgraph "Service Layer"
            direction TB
            ClassSvc["ClassServiceImpl"]:::service
            MemberSvc["MemberServiceImpl"]:::service
            RegistrationSvc["RegistrationServiceImpl"]:::service
        end

        %% Data Access Layer
        subgraph "Data Layer (MyBatis)"
            direction TB
            ClassMapper["ClassMapper"]:::data
            MembersMapper["MembersMapper"]:::data
            RegistrationMapper["RegistrationMapper"]:::data
            XMLClass["class-mapper.xml"]:::data
            XMLMembers["members-mapper.xml"]:::data
            XMLRegistration["registration-mapper.xml"]:::data
        end

        %% Utilities & Exception Handling
        subgraph "Utilities & Exceptions"
            direction TB
            JwtUtil["JwtUtil"]:::util
            CustomResp["CustomResponse"]:::util
            GlobalEx["GlobalExceptionHandler"]:::exception
            ExResp["CustomExceptionResponse"]:::exception
            ExAttr["ErrorAttribute"]:::exception
        end

        %% Database
        DB["Relational Database"]:::db
    end

    %% Connections: Client to Security
    Browser -->|"HTTP Request"| JwtFilter
    APIClient -->|"HTTP Request"| JwtFilter

    %% Security to Controllers
    JwtFilter -->|"JWT validated"| AuthCtrl
    JwtFilter --> ClassCtrl
    JwtFilter --> MemberCtrl
    JwtFilter --> RegistrationCtrl
    JwtFilter --> MainViewCtrl

    EntryPoint --> AuthCtrl
    AccessDenied --> AuthCtrl
    UserDetailsSvc --> JwtFilter
    SecurityConf --> JwtFilter
    SecurityConf --> EntryPoint
    SecurityConf --> AccessDenied
    SecurityConf --> UserDetailsSvc
    SecurityConf --> AuthCtrl

    %% Swagger UI
    OpenApiConf --> SwaggerUI

    %% Controllers to Services
    AuthCtrl -->|"POST /api/v1/login"| JwtUtil
    AuthCtrl --> CustomResp
    AuthCtrl --> MemberSvc
    MainViewCtrl -->|"Render main.jsp"| Browser
    ClassCtrl --> ClassSvc
    MemberCtrl --> MemberSvc
    RegistrationCtrl --> RegistrationSvc

    %% Services to Data Layer
    ClassSvc --> ClassMapper
    MemberSvc --> MembersMapper
    RegistrationSvc --> RegistrationMapper

    %% Data Layer to DB
    ClassMapper -->|"SQL Queries"| DB
    MembersMapper --> DB
    RegistrationMapper --> DB
    XMLClass --> ClassMapper
    XMLMembers --> MembersMapper
    XMLRegistration --> RegistrationMapper

    %% Exception Flow
    JwtFilter --> GlobalEx
    AuthCtrl --> GlobalEx
    ClassCtrl --> GlobalEx
    MemberCtrl --> GlobalEx
    RegistrationCtrl --> GlobalEx
    ClassSvc --> GlobalEx
    MemberSvc --> GlobalEx
    RegistrationSvc --> GlobalEx
    DB --> GlobalEx

    GlobalEx --> ExResp
    GlobalEx --> ExAttr

    %% Click Events
    click Browser "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/webapp/WEB-INF/jsp/main.jsp"
    click SwaggerUI "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/config/OpenApiConfig.java"
    click JwtFilter "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/auth/JwtAuthFilter.java"
    click EntryPoint "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/auth/CustomEntryPoint.java"
    click AccessDenied "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/auth/CustomAccessDeniedHandler.java"
    click UserDetailsSvc "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/auth/CustomUserDetailsService.java"
    click SecurityConf "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/config/SecurityConfig.java"
    click AuthCtrl "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/auth/controller/AuthController.java"
    click MainViewCtrl "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/MainViewController.java"
    click ClassCtrl "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/module/classes/controller/ClassController.java"
    click MemberCtrl "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/module/members/controller/MemberController.java"
    click RegistrationCtrl "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/module/registration/controller/RegistrationController.java"
    click ClassSvc "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/module/classes/service/ClassServiceImpl.java"
    click MemberSvc "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/module/members/service/MemberServiceImpl.java"
    click RegistrationSvc "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/module/registration/service/RegistrationServiceImpl.java"
    click ClassMapper "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/module/classes/mapper/ClassMapper.java"
    click MembersMapper "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/module/members/mapper/MembersMapper.java"
    click RegistrationMapper "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/module/registration/mapper/RegistrationMapper.java"
    click XMLClass "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/resources/mapper/class-mapper.xml"
    click XMLMembers "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/resources/mapper/members-mapper.xml"
    click XMLRegistration "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/resources/mapper/registration-mapper.xml"
    click JwtUtil "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/util/JwtUtil.java"
    click CustomResp "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/util/CustomResponse.java"
    click GlobalEx "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/exception/GlobalExceptionHandler.java"
    click ExResp "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/exception/CustomExceptionResponse.java"
    click ExAttr "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/exception/ErrorAttribute.java"
    click AppEntry "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/ClassApplication.java"
    click ServletInit "https://github.com/han-dongil/ringle/blob/master/assignment/src/main/java/com/example/demo/ServletInitializer.java"

    %% Styles
    classDef external fill:#D3D3D3,stroke:#333
    classDef security fill:#FFA500,stroke:#333
    classDef config fill:#FFE4B5,stroke:#333
    classDef web fill:#ADD8E6,stroke:#333
    classDef service fill:#87CEFA,stroke:#333
    classDef data fill:#00BFFF,stroke:#333
    classDef util fill:#F0E68C,stroke:#333
    classDef exception fill:#FFB6C1,stroke:#333
    classDef db fill:#32CD32,stroke:#333,stroke-width:2px
```
