# abhinavd1605/emoticare architecture

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

- Interactive diagram: https://gitdiagram.com/abhinavd1605/emoticare
- Repository: https://github.com/abhinavd1605/emoticare

## Overview

##### Main Components
- Client Layer: Represent the React SPA built with React, TypeScript, TailwindCSS, and various UI libraries (Shadcn/UI, Framer Motion, Recharts). This layer handles UI rendering, state management, form validations, animations, and overall client-side logic.
- Application/Backend Layer: Highlight Firebase’s role that encompasses Authentication, Firestore (real-time data persistence), Storage, Hosting, and possibly Cloud Functions for serverless logic. This layer is responsible for data management, security (using Firebase Security Rules), and session handling.
- Service/Integration Layer: Detail the external and in-house services:
– Groq API for high-performance conversational AI.
– Deepgram API for voice recognition and text-to-speech conversion.
– Local sentiment analysis, emotion recognition, and recommendation algorithms.
- AI & Machine Learning Components: Note how the platform processes natural language (NLP), emotion detection, and personalized recommendation systems to deliver adaptive user interactions.
- Media & Assets: Include the public folder which contains audio/visual elements (background videos, ambient sounds, robo configuration JSON files) supporting the “Safe Space” and multi-modal interaction experience.

##### Relationships and Interactions
- If applicable, indicate bi-directional communication where Firebase might push real-time updates back to the client (using Firestore’s real-time capabilities).

##### Architectural Patterns and Design Principles
- Client-Server & Serverless Architecture: Emphasize how the React SPA (client) communicates with a serverless backend (Firebase) and leverages external services.
- Component-Based Architecture: Include components (UI elements, specialized 3D robo components, various UI library components) from the “src/components” folder.
- Modular and Extensible Design: Showcase how features (text-based chat, voice support, analytics dashboard, guided breathing exercises) are implemented as separate modules.

##### Relevant Technologies and Frameworks
- Frontend: React, TypeScript, TailwindCSS, Vite, React Router, Recharts, Framer Motion.
- Backend/Services: Firebase Authentication, Firestore, Cloud Storage, Groq API, Deepgram API.
- AI & Data Processing: Sentiment analysis and NLP services.
- Utility Libraries and Tools: ESLint, PostCSS, various configuration files that assist in environment setup and project builds.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer (React SPA)"
        clientApp["React SPA (src/App.tsx)"]:::frontend
        components["UI Components (src/components/)"]:::frontend
        robo["3D RoboCharacter (src/components/3d/RoboCharacter.tsx)"]:::frontend
        voiceRobo["VoiceRoboCharacter (src/components/3d/VoiceRoboCharacter.tsx)"]:::frontend
        chatbot["Chatbot Page (src/pages/Chatbot.tsx)"]:::frontend
        safeSpace["SafeSpace Page (src/pages/SafeSpace.tsx)"]:::frontend
        voiceChat["VoiceChat Page (src/pages/VoiceChat.tsx)"]:::frontend
    end

    subgraph "Application Layer (Firebase)"
        firebase["Firebase (src/lib/firebase.ts)"]:::backend
    end

    subgraph "Service Layer (External APIs & In-House Services)"
        groq["Groq API (src/lib/groqClient.ts)"]:::service
        deepgram["Deepgram API (src/lib/deepgramClient.ts)"]:::service
        sentiment["Local Sentiment Analysis (src/lib/sentimentAnalysis.ts)"]:::ai
        chatService["Chat Service (src/lib/chatService.ts)"]:::service
        chatAnalytics["Chat Analytics (src/lib/chatAnalytics.ts)"]:::ai
    end

    subgraph "Media & Assets"
        media["Media & Assets (public/)"]:::media
    end

    %% Data Flow Connections
    clientApp -->|"userActions"| firebase
    firebase -->|"apiCalls"| groq
    firebase -->|"apiCalls"| deepgram
    firebase -->|"apiCalls"| sentiment
    firebase -->|"apiCalls"| chatService
    firebase -->|"apiCalls"| chatAnalytics
    firebase -->|"realTimeUpdates"| clientApp
    clientApp -->|"loadsMedia"| media

    %% Additional Relationships within Client Layer
    chatbot --> clientApp
    safeSpace --> clientApp
    voiceChat --> clientApp
    components --> clientApp
    robo --> components
    voiceRobo --> components

    %% Click Events
    click clientApp "https://github.com/abhinavd1605/emoticare/blob/main/src/App.tsx"
    click components "https://github.com/abhinavd1605/emoticare/tree/main/src/components/"
    click robo "https://github.com/abhinavd1605/emoticare/blob/main/src/components/3d/RoboCharacter.tsx"
    click voiceRobo "https://github.com/abhinavd1605/emoticare/blob/main/src/components/3d/VoiceRoboCharacter.tsx"
    click chatbot "https://github.com/abhinavd1605/emoticare/blob/main/src/pages/Chatbot.tsx"
    click safeSpace "https://github.com/abhinavd1605/emoticare/blob/main/src/pages/SafeSpace.tsx"
    click voiceChat "https://github.com/abhinavd1605/emoticare/blob/main/src/pages/VoiceChat.tsx"
    click firebase "https://github.com/abhinavd1605/emoticare/blob/main/src/lib/firebase.ts"
    click groq "https://github.com/abhinavd1605/emoticare/blob/main/src/lib/groqClient.ts"
    click deepgram "https://github.com/abhinavd1605/emoticare/blob/main/src/lib/deepgramClient.ts"
    click sentiment "https://github.com/abhinavd1605/emoticare/blob/main/src/lib/sentimentAnalysis.ts"
    click chatService "https://github.com/abhinavd1605/emoticare/blob/main/src/lib/chatService.ts"
    click chatAnalytics "https://github.com/abhinavd1605/emoticare/blob/main/src/lib/chatAnalytics.ts"
    click media "https://github.com/abhinavd1605/emoticare/tree/main/public/"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef service fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef ai fill:#e2e3e5,stroke:#383d41,stroke-width:2px;
    classDef media fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
