# rushikeshsj/nlptosqlqueryconverter architecture

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

- Interactive diagram: https://gitdiagram.com/rushikeshsj/nlptosqlqueryconverter
- Repository: https://github.com/rushikeshsj/nlptosqlqueryconverter

## Overview

##### Main Components

a) Client Layer:
- React Frontend (Port 3000)
- Components: QueryInput and ResultDisplay
- Controllers: AppController
- Services: queryService
- Styles and Assets

b) Server Layer:
- Spring Boot Backend
- Controllers: DatabaseController
- Services: QueryService
- Models: QueryRequest, QueryResponse
- Application Properties (Configuration)

c) External Services:
- OpenAI API
- Database System (MySQL/PostgreSQL)

**┌─────────────────────────────────────┐**
- React Frontend (Port 3000)          │
- ┤
- Components                        │
- QueryInput                     │
- ResultDisplay                  │
- Controllers                       │
- AppController                  │
- Services                          │
- queryService                   │
- ┘

**┌─────────────────────────────────────┐**
- Spring Boot Backend                 │
- ┤
- Controllers                       │
- DatabaseController            │
- Services                         │
- QueryService                  │
- Models                           │
- QueryRequest                  │
- QueryResponse                 │
- ┘

**┌─────────────────┐    ┌─────────────┐**
- OpenAI API   │    │  Database   │
- ┘    └─────────────┘

##### Connection and Data Flow Indicators

- User input → Frontend Components → Backend Controller
- Backend Controller → OpenAI API → Backend Service
- Backend Service → Database
- Database → Backend Service → Frontend
- Frontend → User Display

##### Additional Elements

a) Configuration Details:
- API endpoints
- Database connection settings

b) Security Layer:
- API key handling
- Database credentials

c) Error Handling Flow:
- Error responses
- Fallback mechanisms

##### Specific Implementation Notes

- NLP processing flow from user input to SQL query
- Transformation stages
- Query execution and result return path
- Asynchronous operations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend["Frontend Layer (Port 3000)"]
        QI["QueryInput Component"]
        RD["ResultDisplay Component"]
        AC["AppController"]
        QS["queryService"]
        App["App.js"]
    end

    subgraph Backend["Spring Boot Backend"]
        DC["DatabaseController"]
        QSV["QueryService"]
        QReq["QueryRequest Model"]
        QRes["QueryResponse Model"]
        AP["Application Properties"]
        BE["NLPtoSqlQueryConverterApplication"]
    end

    subgraph External["External Services"]
        OAI["OpenAI API"]
        DB[(Database)]
    end

    %% Data Flow
    QI --> AC
    AC --> QS
    QS --> DC
    DC --> QSV
    QSV --> OAI
    OAI --> QSV
    QSV --> DB
    DB --> QSV
    QSV --> DC
    DC --> QS
    QS --> RD

    %% Request/Response Models
    DC --- QReq
    DC --- QRes

    %% Configuration
    AP --> BE
    BE --> DC

    %% Click Events
    click QI "https://github.com/RushikeshSJ/NLPtoSQLQueryConverter/blob/main/NLPtoSQLQueryConverterFrontEnd/nlptosql/src/components/QueryInput.js"
    click RD "https://github.com/RushikeshSJ/NLPtoSQLQueryConverter/blob/main/NLPtoSQLQueryConverterFrontEnd/nlptosql/src/components/ResultDisplay.js"
    click AC "https://github.com/RushikeshSJ/NLPtoSQLQueryConverter/blob/main/NLPtoSQLQueryConverterFrontEnd/nlptosql/src/controllers/AppController.js"
    click QS "https://github.com/RushikeshSJ/NLPtoSQLQueryConverter/blob/main/NLPtoSQLQueryConverterFrontEnd/nlptosql/src/models/queryService.js"
    click DC "https://github.com/RushikeshSJ/NLPtoSQLQueryConverter/blob/main/NLPtoSQLQueryConverterBackEnd/src/main/java/org/generativeai/nlptosqlqueryconverter/Controller/DatabaseController.java"
    click QSV "https://github.com/RushikeshSJ/NLPtoSQLQueryConverter/blob/main/NLPtoSQLQueryConverterBackEnd/src/main/java/org/generativeai/nlptosqlqueryconverter/Service/QueryService.java"
    click QReq "https://github.com/RushikeshSJ/NLPtoSQLQueryConverter/blob/main/NLPtoSQLQueryConverterBackEnd/src/main/java/org/generativeai/nlptosqlqueryconverter/Model/QueryRequest.java"
    click QRes "https://github.com/RushikeshSJ/NLPtoSQLQueryConverter/blob/main/NLPtoSQLQueryConverterBackEnd/src/main/java/org/generativeai/nlptosqlqueryconverter/Model/QueryResponse.java"
    click AP "https://github.com/RushikeshSJ/NLPtoSQLQueryConverter/blob/main/NLPtoSQLQueryConverterBackEnd/src/main/resources/application.properties"
    click App "https://github.com/RushikeshSJ/NLPtoSQLQueryConverter/blob/main/NLPtoSQLQueryConverterFrontEnd/nlptosql/src/App.js"
    click BE "https://github.com/RushikeshSJ/NLPtoSQLQueryConverter/blob/main/NLPtoSQLQueryConverterBackEnd/src/main/java/org/generativeai/nlptosqlqueryconverter/NlPtoSqlQueryConverterApplication.java"

    %% Styling
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef backend fill:#4CAF50,stroke:#2E7D32,color:white
    classDef external fill:#FFC107,stroke:#FFA000,color:black
    classDef database fill:#757575,stroke:#424242,color:white
    classDef config fill:#E91E63,stroke:#C2185B,color:white

    class QI,RD,AC,QS,App frontend
    class DC,QSV,QReq,QRes,BE backend
    class OAI external
    class DB database
    class AP config
```
