# rahulgpi/atharva_wetried architecture

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

- Interactive diagram: https://gitdiagram.com/rahulgpi/atharva_wetried
- Repository: https://github.com/rahulgpi/atharva_wetried

## Overview

##### Project type and purpose
- This is a full-stack web application combining a React-based frontend (“frontend/village”) with a Python/Flask backend (“backend/”).
- Purpose: provide a gamified, AI-driven mental wellness companion (virtual dog), where real-life tasks yield in-game rewards and AI-powered dialogue via the Gemini engine.

##### File structure
- Top level splits into two folders:
- backend/ – Flask service modules and requirements.txt
- frontend/village/ – React + Vite + Tailwind client code, public assets, config files
- Backend files indicate modular separation of concerns:
- User.py – user model or endpoints
- game.py – game logic
- survey.py – DASS-21 psychiatric survey logic
- avatar.py – companion state and assets
- gemini.py – AI service wrapper
- lifeline_manager.py – in-game lifeline or assistance functions
- config.py – configuration (DB URI, Gemini credentials)
- main.py and app.py – Flask app entrypoints
- Frontend has:
- src/pages/ – React page components (VillagePage, DogTTSAssistant, LangPage)
- src/assets/ & public/assets – audio, questions.json, static files
- package.json, vite.config.js, eslint.config.js – build & lint setup

##### README for additional insights
- Tech stack: React + Tailwind CSS, Flask, Gemini AI, MongoDB
- Features: gamification, AI therapy, real-life task ↔ in-game reward flow
- External dependencies: runs MongoDB locally or via cloud, calls Gemini AI API

a. Main components
- Client (React/Vite/Tailwind)
- Backend API (Flask service)
- AI Service (Gemini API)
- Database (MongoDB)
- Static Asset Store (public assets, audio, JSON) – could be a CDN or S3
b. Component relationships & data flow
1. User interacts in browser → React UI
2. React sends HTTP(S) requests (REST or GraphQL) to Flask API endpoints (/user, /game, /survey, /avatar, /lifeline)
3. Flask controller invokes business logic modules (User, Game, Survey, Avatar, LifelineManager)
4. Business logic may:
– Query/Update MongoDB via config’d client
– Call Gemini API via gemini.py to generate AI responses
5. Flask returns JSON responses to the frontend
6. React updates state, renders UI, plays audio/assets from public folder
c. Architectural patterns & design principles
- Modular monolith on backend (clear separation of domain modules)
- Single-page application (SPA) on frontend
- RESTful API layer between client and server
- External service integration (Gemini AI)
- Store static assets and configuration separately
d. Key technologies & frameworks
- React, Vite, Tailwind CSS – frontend
- Flask, Python – backend API
- Gemini AI – external LLM service
- MongoDB – document database
- Node.js (dev) – frontend build
- Virtual environment & pip – backend environment

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (React SPA)"
        direction TB
        Client["Browser / React UI"]:::frontend
        subgraph "Source Code"
            direction TB
            App["App.jsx"]:::frontend
            Main["main.jsx"]:::frontend
            Vite["vite.config.js"]:::frontend
            Package["package.json"]:::frontend
        end
        subgraph "Pages"
            direction TB
            VillagePage["VillagePage.jsx"]:::frontend
            DogTTSAssistant["DogTTSAssistant.jsx"]:::frontend
            LangPage["LangPage.jsx"]:::frontend
        end
        subgraph "Styles"
            direction TB
            LandingCSS["LandingPage.css"]:::frontend
            DogCSS["DogTTSAssistant.css"]:::frontend
            AppCSS["App.css"]:::frontend
        end
    end

    %% Static Assets
    subgraph "Static Asset Store"
        direction TB
        AssetsFolder["public/assets/"]:::frontend
        BGM["village-bgm.mp3"]:::frontend
        Questions["questions.json"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Flask API)"
        direction TB
        AppPy["app.py"]:::backend
        MainPy["main.py"]:::backend
        Requirements["requirements.txt"]:::backend
        subgraph "Domain Modules"
            direction TB
            UserMod["User.py"]:::backend
            GameMod["game.py"]:::backend
            SurveyMod["survey.py"]:::backend
            AvatarMod["avartar.py"]:::backend
            LifelineMod["lifeline_manager.py"]:::backend
            GeminiMod["gemini.py"]:::backend
            ConfigMod["config.py"]:::backend
        end
    end

    %% External Services & DB
    MongoDB[(MongoDB)]:::db
    Gemini["Gemini AI API"]:::external

    %% Data Flows
    Client -->|"HTTP GET/POST /user, /game, /survey, /avatar, /lifeline"| AppPy
    Client -->|"Fetch static assets"| AssetsFolder
    AppPy -->|"Uses domain modules"| UserMod
    AppPy -->|"Uses domain modules"| GameMod
    AppPy -->|"Uses domain modules"| SurveyMod
    AppPy -->|"Uses domain modules"| AvatarMod
    AppPy -->|"Uses domain modules"| LifelineMod
    AppPy -->|"LLM request/response"| GeminiMod
    GeminiMod -->|"Calls"| Gemini
    ConfigMod -->|"DB URI"| MongoDB
    UserMod -->|"Query/Update"| MongoDB
    GameMod -->|"Query/Update"| MongoDB
    SurveyMod -->|"Query/Update"| MongoDB
    AvatarMod -->|"Query/Update"| MongoDB
    LifelineMod -->|"Query/Update"| MongoDB

    %% Click Events - Frontend
    click Client "https://github.com/rahulgpi/atharva_wetried/tree/main/frontend/village/"
    click App "https://github.com/rahulgpi/atharva_wetried/blob/main/frontend/village/src/App.jsx"
    click Main "https://github.com/rahulgpi/atharva_wetried/blob/main/frontend/village/src/main.jsx"
    click Vite "https://github.com/rahulgpi/atharva_wetried/blob/main/frontend/village/vite.config.js"
    click Package "https://github.com/rahulgpi/atharva_wetried/blob/main/frontend/village/package.json"
    click VillagePage "https://github.com/rahulgpi/atharva_wetried/blob/main/frontend/village/src/pages/VillagePage.jsx"
    click DogTTSAssistant "https://github.com/rahulgpi/atharva_wetried/blob/main/frontend/village/src/pages/DogTTSAssistant.jsx"
    click LangPage "https://github.com/rahulgpi/atharva_wetried/blob/main/frontend/village/src/pages/LangPage.jsx"
    click LandingCSS "https://github.com/rahulgpi/atharva_wetried/blob/main/frontend/village/src/styles/LandingPage.css"
    click DogCSS "https://github.com/rahulgpi/atharva_wetried/blob/main/frontend/village/src/styles/DogTTSAssistant.css"
    click AppCSS "https://github.com/rahulgpi/atharva_wetried/blob/main/frontend/village/src/App.css"
    click AssetsFolder "https://github.com/rahulgpi/atharva_wetried/tree/main/frontend/village/public/assets/"
    click BGM "https://github.com/rahulgpi/atharva_wetried/blob/main/frontend/village/public/assets/village-bgm.mp3"
    click Questions "https://github.com/rahulgpi/atharva_wetried/blob/main/frontend/village/public/questions.json"

    %% Click Events - Backend
    click AppPy "https://github.com/rahulgpi/atharva_wetried/blob/main/backend/app.py"
    click MainPy "https://github.com/rahulgpi/atharva_wetried/blob/main/backend/main.py"
    click Requirements "https://github.com/rahulgpi/atharva_wetried/blob/main/backend/requirements.txt"
    click UserMod "https://github.com/rahulgpi/atharva_wetried/blob/main/backend/User.py"
    click GameMod "https://github.com/rahulgpi/atharva_wetried/blob/main/backend/game.py"
    click SurveyMod "https://github.com/rahulgpi/atharva_wetried/blob/main/backend/survey.py"
    click AvatarMod "https://github.com/rahulgpi/atharva_wetried/blob/main/backend/avartar.py"
    click LifelineMod "https://github.com/rahulgpi/atharva_wetried/blob/main/backend/lifeline_manager.py"
    click GeminiMod "https://github.com/rahulgpi/atharva_wetried/blob/main/backend/gemini.py"
    click ConfigMod "https://github.com/rahulgpi/atharva_wetried/blob/main/backend/config.py"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef db fill:#FFD580,stroke:#333,stroke-width:1px
    classDef external fill:#DDA0DD,stroke:#333,stroke-width:1px
```
