# priyanshu-baghel/bhasha-ai architecture

> Architecture diagram of the GitHub repository priyanshu-baghel/bhasha-ai, 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/priyanshu-baghel/bhasha-ai
- Repository: https://github.com/priyanshu-baghel/bhasha-ai

## Overview

##### Project Type & Purpose
- Bhasha.ai is an AI-powered video translation platform aimed specifically at dubbing NPTEL courses into various Indian languages, generating subtitles, and creating lecture notes.
- It leverages a multi-component tech stack including a MERN-based web application (with React on the frontend, Node.js/Express.js on the backend), Python APIs for AI/ML tasks (using TTS, ASR, NLP), and a MongoDB database.

##### And Outline Main Components
a. Frontend (Client Side):
- Located in the “client” directory with React.js as the primary framework.
- Contains various pages and components for user interactions (e.g., Landing, Auth, Uploads, Profile, Payment, Courses, Chatbot, etc.).
- This layer manages the UI, routing, and connects to backend APIs using REST calls.

b. Backend (Server Side):
- Located in the “server” directory, built on Node.js with Express.js.
- Organized into controllers and routers for different functionalities such as authentication, admin operations, course management, media processing, email handling, payments, and user profiles.
- Contains middleware, validators, and models that facilitate business logic, data validation, and interaction with MongoDB.

c. Python-based API Services:
- Found in the “apis/uploads” directory.
- Handles AI/ML tasks such as dubbing (using deep learning for TTS), subtitle generation, and possibly note creation.
- File structure hints at separation between raw uploads, final dubbed outputs, and subtitles. This indicates a pipeline where videos are processed and outputs are stored in designated folders.

d. Database:
- MongoDB is used as the primary data store as indicated in the README and the project’s MERN architecture.

e. AI/ML Services:
- Although not explicitly named as a separate module in the file tree, the reference to deep learning models for ASR, TTS, and NLP should be clearly represented.
- This could be depicted as an “AI Processing Module” that interacts with the Python APIs as well as possibly the Node.js backend.

f. DevOps/Deployment Elements:
- Not in-depth in the file tree but the README references Docker, Kubernetes, and CI/CD. It’s useful to include an “Infrastructure” or “Deployment” component that touches on containerization and automated deployment pipelines.

##### Relationships & Data Flow
- The React frontend and the Node.js/Express backend (e.g., API calls for user authentication, course data, media uploads/downloads).
- The Node.js backend and MongoDB for data storage and retrieval.
- The backend and the Python APIs, which are called to process the video files (submission for dubbing, subtitle generation, and note extraction).
- External services (if applicable) such as payment gateways or email services should be represented as external integrations.

##### Architectural Patterns & Design Principles
- The project follows a modular and layered approach:
- Frontend and backend are clearly separated (MERN stack).
- A microservices-like separation exists for the Python APIs dedicated to media processing.
- The RESTful API design for backend routes with organized controllers and routers.
- Incorporate patterns such as MVC in the backend Node.js part (models, views/controllers, routes) and possibly a pipeline architecture for processing media assets in the Python API.

##### Technologies & Frameworks to Highlight
- Frontend: React.js (with components, state management, and routing).
- Backend: Node.js, Express.js; middleware for authentication and validation.
- Database: MongoDB.
- Python: Flask (or pure Python scripts, as suggested by the presence of app.py in the “apis/uploads” folder) for AI/ML processing.
- AI/ML: TTS, ASR, and NLP deep-learning modules for dubbing, subtitles, and notes.
- DevOps: Docker, Kubernetes, CI/CD (as per README) for deployment.

##### Elements
- Clearly labeled blocks for each component (e.g., "React Client", "Node.js/Express API", "Python AI Processing", "MongoDB Database", "External Services").
- From the client frontend to the backend (API calls).
- From the backend to the AI processing modules (for dubbing and subtitles).
- From the backend to the database.
- From the backend to external services (if applicable).
- Presentation (client-side UI)
- Business logic (backend controllers and services)
- Data storage (database)
- AI/ML processing units (Python modules)
- Infrastructure/deployment elements (CI/CD, Docker, etc.)

##### Detailed Representation
- Configuration nodes where necessary, such as “.env” files (for environment variables) and build configuration files (like package.json, vite.config.js) to indicate how the application layers are configured.
- That the Python API (located under “apis/uploads”) is a specialized component handling heavy media processing, working in tandem with the media-related controllers in the Node.js backend.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        FE["React Client"]:::frontend
    end

    subgraph "Application Layer"
        BE["Node.js/Express API"]:::backend
        ES["External Services"]:::external
    end

    subgraph "Processing Layer"
        PY["Python API (Media Process)"]:::processing
        AIML["AI/ML Models"]:::aiml
    end

    subgraph "Data Layer"
        DB["MongoDB Database"]:::database
    end

    subgraph "Infrastructure"
        DEV["CI/CD & Deployment Config"]:::infrastructure
    end

    FE -->|"APIcalls"| BE
    BE -->|"Videoprocessing"| PY
    BE -->|"Dataaccess"| DB
    BE -->|"Integrates"| ES
    PY -->|"AItasks"| AIML
    DEV ---|"Configures"| BE
    DEV ---|"Configures"| PY

    click FE "https://github.com/priyanshu-baghel/bhasha-ai/tree/main/client/"
    click BE "https://github.com/priyanshu-baghel/bhasha-ai/tree/main/server/"
    click PY "https://github.com/priyanshu-baghel/bhasha-ai/tree/main/apis/uploads/"
    click DB "https://github.com/priyanshu-baghel/bhasha-ai/blob/main/server/utils/db.js"
    click AIML "https://github.com/priyanshu-baghel/bhasha-ai/blob/main/apis/uploads/test_dub.py"
    click DEV "https://github.com/priyanshu-baghel/bhasha-ai/blob/main/README.md"

    classDef frontend fill:#f9c,stroke:#333,stroke-width:2px;
    classDef backend fill:#9f6,stroke:#333,stroke-width:2px;
    classDef processing fill:#ff9,stroke:#333,stroke-width:2px;
    classDef aiml fill:#fc9,stroke:#333,stroke-width:2px;
    classDef database fill:#cff,stroke:#333,stroke-width:2px;
    classDef external fill:#ccf,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#ffc,stroke:#333,stroke-width:2px;
```
