How mrsparkle-70/emotion-using-react works
Main Components Identification
• Frontend (ReactJS):
• Contains the main UI (files in emotion-recognition/src and public directories).
• Handles video capture from the webcam.
• Establishes a WebSocket connection to stream video frames to the backend and receive prediction responses.
• Backend (FastAPI server):
• The API server (main.py in the server directory) built with FastAPI.
• Responsible for receiving video frames via WebSocket, running the frame through the emotion prediction model, and returning a payload with both detailed prediction probabilities and the dominant emotion.
• Machine Learning Model:
• A pre-built TensorFlow Keras model that classifies the emotion into one of seven categories (happy, sad, neutral, disgusted, surprised, fear, and angry).
• Resides logically within the backend component.
• Communication Layer:
• WebSocket – enables bidirectional streaming between the ReactJS frontend and the FastAPI backend.
Relationships and Interactions
• An internal connection within the backend where the incoming data is processed by the TensorFlow Keras model.
Architectural Patterns and Design Principles
• Separation of Concerns: Clear division between presentation (ReactJS UI), business logic and API server (FastAPI), and data processing (ML model prediction).
• Real-time Data Flow: Use of WebSocket indicates a design that supports continuous, live data communication.
• Modular Design: The frontend and backend are self-contained, with their own dependencies (e.g., package.json for React; requirements.txt for FastAPI) and responsibilities.
• Extensibility: The pipeline could be improved by swapping the ML model for a more efficient or custom one.
Important Notes
• Be as detailed as possible – delineate even internal processes if they add to clarity (e.g., “Frame Processing” inside the backend).
• Placing a simplified version of the architecture from the README's provided HLD image as a starting point, then enhancing it with further details from the file structure and README.