# 2023-konkuk-graduation-project-aiku/answerlink architecture

> Architecture diagram of the GitHub repository 2023-konkuk-graduation-project-aiku/answerlink, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/2023-konkuk-graduation-project-aiku/answerlink
- Repository: https://github.com/2023-konkuk-graduation-project-aiku/answerlink

## Overview

##### Main Components Identification
The project has three distinct main components:
- Frontend (React-based web application)
- Backend (Spring Boot Java application)
- Data-AI (Python-based ML services)

##### Frontend Layer (Top)
- Sub-components:
- Chat Interface (QnAContainer)
- Headline Display (HeadlineContainer)
- User Input System (QInput)

##### Backend Layer (Middle)
- Sub-components:
- Chat Controller
- Headline Controller
- Question Answer Service

##### Data-AI Layer (Bottom)
a) Crawler System:
- News Downloader
- Trend Topic Analyzer
- Naver News Crawler
b) NLP Server:
- Generator
- Retriever
- Document Converter

##### User Interaction Flow
- Frontend → Backend: REST API calls
- Backend → NLP Server: RAG processing requests
- Crawler → Backend: News data updates

##### Data Processing Flow
- Crawler → Document Storage
- Document Storage → Retriever
- Retriever → Generator
- Generator → Backend → Frontend

C. Special Components:

##### Storage Systems
- Document Index Storage
- News Headlines Storage
- Context Storage

##### External Services
- News Sources (Naver News)
- OpenAI Integration (noted from OpenAIRestTemplateConfig)

- Blue: Frontend components
- Green: Backend services
- Purple: Data-AI components
- Yellow: Storage systems
- Gray: External services

E. Important Architectural Patterns to Highlight:

##### RAG Architecture
- Clear separation between retrieval and generation components
- Document processing pipeline

##### Microservices Architecture
- Separate services for NLP, crawling, and main backend
- Independent scaling capabilities

##### State Management
- Recoil atoms for frontend state
- Chat state flow

F. Technical Details to Include:

- WebSocket connections for real-time chat
- REST API endpoints
- Document processing pipeline
- News crawling schedule
- Data transformation flow

- Component types (Frontend, Backend, AI Services)
- Storage types
- External service connections

Remember to indicate the asynchronous nature of the news crawling and document processing pipeline, as this appears to be a key feature for maintaining up-to-date information in the RAG system.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef dataai fill:#9b59b6,stroke:#8e44ad,color:white
    classDef storage fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Frontend Layer
    subgraph Frontend
        UI["Frontend (React)"]
        QnA["Chat Interface"]
        Headlines["Headline Display"]
        Input["User Input System"]
        ChatState["Chat State Management"]
        
        UI --> QnA
        UI --> Headlines
        UI --> Input
        UI --> ChatState
    end

    %% Backend Layer
    subgraph Backend
        BE["Backend (Spring Boot)"]
        ChatCtrl["Chat Controller"]
        HeadlineCtrl["Headline Controller"]
        QAService["Question Answer Service"]
        OpenAIConfig["OpenAI Integration"]
        
        BE --> ChatCtrl
        BE --> HeadlineCtrl
        BE --> QAService
        BE --> OpenAIConfig
    end

    %% Data-AI Layer
    subgraph DataAI
        subgraph CrawlerSystem
            Crawler["Crawler Main"]
            NewsDownloader["News Downloader"]
            TrendAnalyzer["Trend Topic Analyzer"]
            NaverCrawler["Naver News Crawler"]
            
            Crawler --> NewsDownloader
            Crawler --> TrendAnalyzer
            Crawler --> NaverCrawler
        end

        subgraph NLPServer
            NLPMain["NLP Server Main"]
            Generator["Generator"]
            Retriever["Retriever"]
            DocConverter["Document Converter"]
            DocIndexing["Document Indexing"]
            
            NLPMain --> Generator
            NLPMain --> Retriever
            Retriever --> DocConverter
            Retriever --> DocIndexing
        end
    end

    %% Storage
    HeadlineStorage[("Headlines Storage")]:::storage
    DocStorage[("Document Index")]:::storage
    ContextStorage[("Context Storage")]:::storage

    %% External Services
    NaverNews["Naver News API"]:::external
    OpenAI["OpenAI Service"]:::external

    %% Connections
    Input --> ChatCtrl
    Headlines --> HeadlineCtrl
    ChatCtrl --> QAService
    QAService --> NLPMain
    NaverCrawler --> NaverNews
    OpenAIConfig --> OpenAI
    Crawler --> HeadlineStorage
    DocIndexing --> DocStorage
    Retriever --> DocStorage
    Generator --> ContextStorage

    %% Click Events
    click QnA "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/front-end/src/components/QnAContainer.tsx"
    click Headlines "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/front-end/src/components/HeadlineContainer.tsx"
    click Input "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/front-end/src/components/QInput.tsx"
    click ChatState "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/front-end/src/atoms/chatAtoms.ts"
    click ChatCtrl "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/back-end/src/main/java/com/example/test/controller/ChatController.java"
    click HeadlineCtrl "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/back-end/src/main/java/com/example/test/controller/headLineController.java"
    click QAService "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/back-end/src/main/java/com/example/test/service/QuestionAnswerService.java"
    click OpenAIConfig "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/back-end/src/main/java/com/example/test/service/OpenAIRestTemplateConfig.java"
    click NewsDownloader "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/data-ai/crawler/download_news.py"
    click TrendAnalyzer "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/data-ai/crawler/trend_topic.py"
    click NaverCrawler "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/data-ai/crawler/naver_news.py"
    click Crawler "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/data-ai/crawler/run.py"
    click Generator "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/data-ai/nlp-server/generator/generator.py"
    click Retriever "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/data-ai/nlp-server/retriever/retriever.py"
    click DocConverter "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/data-ai/nlp-server/retriever/convert_document.py"
    click DocIndexing "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/data-ai/nlp-server/retriever/create_index.py"
    click NLPMain "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/data-ai/nlp-server/main.py"
    click HeadlineStorage "https://github.com/2023-Konkuk-Graduation-Project-AIKU/AnswerLink/blob/main/back-end/src/main/java/com/example/test/storage/headLine_list.txt"

    %% Legend
    subgraph Legend
        FE["Frontend Component"]:::frontend
        BK["Backend Component"]:::backend
        DA["Data-AI Component"]:::dataai
        ST["Storage"]:::storage
        EX["External Service"]:::external
    end
```
