# lingraj1124/realtime-reactmui-springboot-chat-app architecture

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

- Interactive diagram: https://gitdiagram.com/lingraj1124/realtime-reactmui-springboot-chat-app
- Repository: https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app

## Overview

##### Main Components
- Frontend: Represented by the “frontend” directory, this part includes React components (e.g., ContactList.js, Messages.js, Message.js, TextInput.js) and style files. It will handle user interactions, connect to backend APIs, and render chat interfaces.
- Backend: Located under the “backend” directory. This is a Spring Boot application configured for real-time notifications and chat functionality. Key elements here include:
- Main Application: The core entry point (NotificationSystemApplication.java).
- Controllers: AuthController, NotificationController, and TestController that expose REST endpoints.
- WebSocket Configuration: WebSocketConfig.java sets up real-time communication, likely delivering live chat messages/notifications.
- Security Layer: Contains JWT-based authentication (AuthEntryPointJwt.java, AuthTokenFilter.java, JwtUtil.java, WebSecurityConfig.java), ensuring secure communication between the client and server.
- Service Layer: Provides business logic (UserService.java, CustomUserDetailsService.java).
- Persistence Layer: Consists of repositories (UserRepository.java) and models (User.java). A specific database script is also noted in the resources.
- Templates: Though the frontend is React, the backend also holds HTML templates (admin.html, client1.html, client2.html), perhaps for administrative views or legacy support.
- Database: While there isn’t an explicit “database” server component in the file tree, the presence of the SQL script in the resources suggests that a relational database is likely used for storing user data and chat history.
- External Integrations: Although not explicitly shown, consider that the authentication relies on JWT mechanisms and could interface with additional third-party services if needed.

##### Relationships and Interactions
- The React frontend will communicate with the Spring Boot backend via RESTful APIs and/or WebSocket connections (as indicated by the WebSocketConfig).
- The backend controllers handle authentication, chat message routing, and notifications, interacting with their respective services and repositories.
- The security components intercept HTTP requests to validate JWT tokens.
- The persistence layer (models and repositories) interacts with the database to store and retrieve data.
- Templates might be rendered directly or for fallback views.

##### Architectural Patterns and Design Principles
- MVC Pattern on the backend: Clearly defined controllers, models, and service layers.
- Separation of Concerns: Security configuration is neatly isolated from business logic and the presentation layer.
- Real-Time Communication: Use of WebSocket (as seen in WebSocketConfig.java) highlights a design that supports real-time messaging.
- Modular Design: The project separates frontend and backend concerns, allowing them to evolve independently.

##### Be Detailed
- Do not hesitate to add as many small components as needed to capture all essential architectural elements; it helps in understanding the data flow and responsibilities.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Subgraph
    subgraph "Frontend (React Frontend)"
        FE1["ContactList.js"]:::frontend
        FE2["Message.js"]:::frontend
        FE3["Messages.js"]:::frontend
        FE4["TextInput.js"]:::frontend
        FE5["SignInSide.js"]:::frontend
        FE6["SignUpSide.js"]:::frontend
        FE7["index.js"]:::frontend
        FE8["styles.css"]:::frontend
        FE9["index.html"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend (Spring Boot Application)"
        BA1["NotificationSystemApplication.java"]:::backend
        subgraph "Controllers"
            BC1["AuthController.java"]:::backend
            BC2["NotificationController.java"]:::backend
            BC3["TestController.java"]:::backend
        end
        BA2["WebSocketConfig.java"]:::backend
        subgraph "Security Layer"
            BS1["AuthEntryPointJwt.java"]:::backend
            BS2["AuthTokenFilter.java"]:::backend
            BS3["JwtUtil.java"]:::backend
            BS4["WebSecurityConfig.java"]:::backend
        end
        subgraph "Service Layer"
            BV1["CustomUserDetailsService.java"]:::backend
            BV2["UserService.java"]:::backend
        end
        subgraph "Persistence Layer"
            BP1["User.java"]:::backend
            BP2["UserRepository.java"]:::backend
        end
        subgraph "Templates"
            BT1["admin.html"]:::backend
            BT2["client1.html"]:::backend
            BT3["client2.html"]:::backend
        end
        subgraph "Configuration"
            BCfg1["application.properties"]:::backend
            BCfg2["user.sql"]:::backend
        end
    end

    %% Database Subgraph
    subgraph "Database"
        DB["Relational Database"]:::database
    end

    %% Interactions between Frontend and Backend
    FE7 -->|"REST_API_calls"| BC1
    FE7 -->|"REST_API_calls"| BC2
    FE7 -->|"REST_API_calls"| BC3
    FE7 -->|"WebSocket"| BA2

    %% Backend Internal Flow
    BC1 --> BV2
    BC2 --> BV2
    BC3 --> BV2
    BV2 --> BP2
    BP2 --> DB

    %% Security Flow
    BC1 -->|"JWT_validation"| BS2
    BS2 --> BS3

    %% Additional Service-Persistence Interaction
    BV1 --> BP1

    %% Click Events for Frontend Components
    click FE1 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/frontend/src/ContactList.js"
    click FE2 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/frontend/src/Message.js"
    click FE3 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/frontend/src/Messages.js"
    click FE4 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/frontend/src/TextInput.js"
    click FE5 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/frontend/src/SignInSide.js"
    click FE6 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/frontend/src/SignUpSide.js"
    click FE7 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/frontend/src/index.js"
    click FE8 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/frontend/src/styles.css"
    click FE9 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/frontend/public/index.html"

    %% Click Events for Backend Components
    click BA1 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/java/com/javatechie/NotificationSystemApplication.java"
    click BC1 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/java/com/javatechie/controller/AuthController.java"
    click BC2 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/java/com/javatechie/controller/NotificationController.java"
    click BC3 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/java/com/javatechie/controller/TestController.java"
    click BA2 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/java/com/javatechie/config/WebSocketConfig.java"
    click BS1 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/java/com/javatechie/security/AuthEntryPointJwt.java"
    click BS2 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/java/com/javatechie/security/AuthTokenFilter.java"
    click BS3 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/java/com/javatechie/security/JwtUtil.java"
    click BS4 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/java/com/javatechie/security/WebSecurityConfig.java"
    click BV1 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/java/com/javatechie/service/CustomUserDetailsService.java"
    click BV2 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/java/com/javatechie/service/UserService.java"
    click BP1 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/java/com/javatechie/model/User.java"
    click BP2 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/java/com/javatechie/repository/UserRepository.java"
    click BT1 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/resources/templates/admin.html"
    click BT2 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/resources/templates/client1.html"
    click BT3 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/resources/templates/client2.html"
    click BCfg1 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/resources/application.properties"
    click BCfg2 "https://github.com/lingraj1124/realtime-reactmui-springboot-chat-app/blob/main/backend/src/main/resources/database/user.sql"

    %% Styling Definitions
    classDef frontend fill:#CDEFFF,stroke:#0275d8,stroke-width:2px;
    classDef backend fill:#FFDAB9,stroke:#FF8C00,stroke-width:2px;
    classDef database fill:#E0FFE0,stroke:#008000,stroke-width:2px;
```
