# d102-preview/preview architecture

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

- Interactive diagram: https://gitdiagram.com/d102-preview/preview
- Repository: https://github.com/d102-preview/preview

## Overview

##### High-Level Components
The system consists of three main services that should be prominently displayed:

a) Frontend Service
- React-based web application
- As the client-facing layer
- Features: Resume Upload, Interview Practice, Real Interview, Analysis Results

b) Backend Services (Split into two parts)
- Main Backend (Spring Boot)
- User Management
- Interview Management
- Resume Processing
- Question Management
- AI Backend (FastAPI)
- Face Analysis
- Answer Analysis
- Question Generation

c) Data Stores
- MariaDB (Main database)
- Redis (Cache and session management)
- File Storage (For resumes and recordings)

##### Component Relationships and Data Flow

- Frontend → Backend: REST API calls
- Backend → AI Service: Internal API calls
- Backend ↔ Databases: Data persistence
- AI Service ↔ ML Models: Model inference

##### External Services Integration

Connections to:
- OpenAI API (for question generation)
- FastAI API (for face analysis)
- Email Service

##### Infrastructure Layer

Deployment infrastructure:
- Docker containers
- Jenkins pipeline
- Nginx reverse proxy
- SSL/TLS termination

##### Specific Implementation Details

Technical stack indicators:
- Frontend: React, TypeScript, Tailwind CSS
- Backend: Spring Boot, JPA, QueryDSL
- AI: FastAPI, PyTorch, KoBERT
- Infrastructure: Docker, Jenkins, Nginx

##### Security Layer

Security components:
- JWT authentication
- API Gateway
- Security filters

##### Infrastructure Layer

Key Design Considerations:
- Microservices architecture
- Clear separation between AI and main backend services
- Real-time features (SSE for interview feedback)
- Monitoring and logging components
- Scalability points

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef ai fill:#9b59b6,stroke:#8e44ad,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef infrastructure fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef external fill:#1abc9c,stroke:#16a085,color:white

    %% Client Layer
    subgraph ClientLayer
        Frontend["Frontend Service"]:::frontend
        FE_Components["Components"]:::frontend
        FE_Pages["Pages"]:::frontend
        FE_Services["Services"]:::frontend
    end

    %% API Gateway Layer
    APIGateway["Nginx API Gateway"]:::infrastructure
    JWTAuth["JWT Authentication"]:::security

    %% Application Services Layer
    subgraph MainBackend
        UserMgmt["User Management"]:::backend
        InterviewMgmt["Interview Management"]:::backend
        ResumeMgmt["Resume Processing"]:::backend
        QuestionMgmt["Question Management"]:::backend
    end

    subgraph AIBackend
        FaceAnalysis["Face Analysis"]:::ai
        AnswerAnalysis["Answer Analysis"]:::ai
        QuestionGen["Question Generation"]:::ai
        MLModels["ML Models (KoBERT/ResNet)"]:::ai
    end

    %% Data Layer
    MariaDB[(MariaDB)]:::database
    Redis[(Redis Cache)]:::database
    FileStorage[(File Storage)]:::database

    %% External Services
    OpenAI["OpenAI API"]:::external
    FastAI["FastAI API"]:::external
    EmailService["Email Service"]:::external

    %% Infrastructure Layer
    subgraph Infrastructure
        Docker["Docker Containers"]:::infrastructure
        Jenkins["Jenkins Pipeline"]:::infrastructure
        SSL["SSL/TLS"]:::infrastructure
    end

    %% Relationships
    Frontend --> APIGateway
    APIGateway --> JWTAuth
    JWTAuth --> MainBackend
    JWTAuth --> AIBackend
    
    MainBackend --> MariaDB
    MainBackend --> Redis
    MainBackend --> FileStorage
    MainBackend --> AIBackend
    
    AIBackend --> MLModels
    AIBackend --> OpenAI
    AIBackend --> FastAI
    
    MainBackend --> EmailService

    %% Component Hierarchy
    Frontend --- FE_Components
    Frontend --- FE_Pages
    Frontend --- FE_Services

    %% Click Events
    click Frontend "https://github.com/d102-preview/preview/tree/main/frontend/src"
    click FE_Components "https://github.com/d102-preview/preview/tree/main/frontend/src/components"
    click FE_Pages "https://github.com/d102-preview/preview/tree/main/frontend/src/pages"
    click FE_Services "https://github.com/d102-preview/preview/tree/main/frontend/src/services"
    click UserMgmt "https://github.com/d102-preview/preview/blob/main/backend/d102-api/src/main/java/com/d102/api/controller/UserController.java"
    click InterviewMgmt "https://github.com/d102-preview/preview/blob/main/backend/d102-api/src/main/java/com/d102/api/controller/InterviewController.java"
    click ResumeMgmt "https://github.com/d102-preview/preview/blob/main/backend/d102-api/src/main/java/com/d102/api/controller/ResumeController.java"
    click QuestionMgmt "https://github.com/d102-preview/preview/blob/main/backend/d102-api/src/main/java/com/d102/api/controller/CommonQuestionController.java"
    click FaceAnalysis "https://github.com/d102-preview/preview/blob/main/api-ai/routes/analysis.py"
    click AnswerAnalysis "https://github.com/d102-preview/preview/blob/main/api-ai/service/analysis.py"
    click MLModels "https://github.com/d102-preview/preview/blob/main/api-ai/ai/kobert_proc.py"
    click JWTAuth "https://github.com/d102-preview/preview/blob/main/backend/d102-common/src/main/java/com/d102/common/security/JwtManager.java"
    click MariaDB "https://github.com/d102-preview/preview/tree/main/backend/d102-common/src/main/java/com/d102/common/repository/jpa"
    click Redis "https://github.com/d102-preview/preview/tree/main/backend/d102-common/src/main/java/com/d102/common/repository/redis"
    click OpenAI "https://github.com/d102-preview/preview/blob/main/backend/d102-common/src/main/java/com/d102/common/util/OpenAiApi.java"
    click FastAI "https://github.com/d102-preview/preview/blob/main/backend/d102-common/src/main/java/com/d102/common/util/FastAiApi.java"
```
