This project demonstrates bidirectional communication and real-time response streaming using WebSocket between a React frontend, Spring Boot backend, and FastAPI backend. The setup allows users to send messages from the frontend, which are processed by FastAPI and streamed back letter by letter through Spring Boot to React for display.
Java 18 or Higher
Maven 3.6 or Higher
index.html: HTML file serving as the entry point for the React application.
App.js: React component handling WebSocket connections, user input, and message rendering.
WebSocketHandler.java: Java class in Spring Boot handling WebSocket connections, forwarding messages to FastAPI, and streaming responses.
main.py: FastAPI script processing incoming messages and generating responses based on predefined rules.
App.css: CSS file for styling the React components.
script.js: JavaScript file for WebSocket handling and UI interaction.
-
User Interaction: Users input messages in the frontend.
-
WebSocket Communication: Messages are sent via WebSocket from React to Spring Boot.
-
Spring Boot Handling: Spring Boot receives the message and forwards it to FastAPI using HTTP.
-
Processing in FastAPI: FastAPI processes the message and generates a response.
-
Response Streaming: FastAPI sends the response back letter by letter to Spring Boot.
-
Display in React: Spring Boot streams each letter to React, which renders them in real-time for the user.
Frontend: React
Backend: Spring Boot, FastAPI
Communication: WebSocket
This project is licensed under the MIT License.