# prashant1177/notesbot architecture

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

- Interactive diagram: https://gitdiagram.com/prashant1177/notesbot
- Repository: https://github.com/prashant1177/notesbot

## Overview

##### Project type and purpose
- From the file tree and README, this is a full-stack web application with:
- A Node.js/Express backend (`backend/`)
- Two frontends:
– A Next.js site in `frontend-next/` (marketing, blog, docs, user flows)
– A standalone React/Vite app in `frontend/` (the in-browser LaTeX editor)
- A MongoDB database (inferred from Mongoose-style `models/*.js`)
- External services: Google Gemini API (AI note generation), email/SMS, payment gateway (Razorpay), WebSocket for real-time updates

##### File structure
- `backend/`
- `index.js`, `routes/`, `models/`, `middleware/` → REST API + auth + data models
- `socket.js` → real-time collaboration (WebSocket server)
- `templates/` → code/document templates
- `utils/` → OTP/email helpers
- `frontend-next/`
- Next.js app for landing, blogs, docs, user auth, subscription management
- `src/app/` follows the app-router paradigm
- UI components, public assets, API wrappers (`lib/api.js`)
- `frontend/`
- React + Vite for the LaTeX editor UI
- Pages for editor, file/folder view, versioning, AI chat, PDF viewer
- Shared UI library under `src/ui`
- `nginx/`, `docker-compose.yml`
- Deployment configs for Docker, nginx reverse proxy

##### README for additional insights
- Description of AI-powered note generation (Gemini API)
- Deployment targets: Vercel (Next.js), Render (backend)
- Tech stack summary confirms major frameworks and external services

##### Main components & interactions
a. Components
- Next.js Frontend (Marketing & Documentation)
- React/Vite Frontend (In-browser LaTeX editor & project dashboard)
- Node/Express API Server
- WebSocket Server (real-time)
- MongoDB Atlas (persistence)
- Google Gemini API (AI)
- Email/SMS Service (OTP, notifications)
- Payment Gateway (Razorpay)
- Deployment/Infra (Docker, nginx, Vercel, Render)
b. Relationships
- Browsers ⇄ Next.js (public site, blogs, docs, auth flows)
- Browsers ⇄ React/Vite (editor UI)
- Both frontends → REST API (backend routes)
- Editor UI ↔ WebSocket Server (real-time collaboration)
- API Server → MongoDB (CRUD for users, projects, versions)
- API Server → Gemini API (generate notes or suggestions)
- API Server → Email/SMS service (send OTP)
- Frontend Next → Razorpay Script → Payment Gateway API
c. Architectural patterns
- Modular MVC in backend (models, routes, middleware)
- Client-side routing in React and Next.js (app router)
- Micro-frontend style (two distinct UIs)
- Real-time collaboration via WebSockets
- Containerized deployment (Docker + nginx)
d. Technologies
- Node.js, Express, Mongoose
- React, Vite, Tailwind, Next.js
- WebSockets (socket.io or native)
- MongoDB Atlas
- Google Gemini API
- Razorpay
- Docker, nginx, Vercel, Render

##### Key advice
- Logical layers: UI, application logic, data persistence, external integrations, and infra
- Keep it modular so that each subteam can understand their scope at a glance

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer" 
        direction TB
        NextJS["Next.js Frontend"]:::frontend
        ReactFE["React/Vite Frontend"]:::frontend
    end

    %% Next.js internals
    subgraph "Next.js Internals"
        direction TB
        AppRouter["App Router (landing, blog, docs, auth)"]:::frontend
        APIWrapper["API Wrappers (lib/api.js)"]:::frontend
        UIComponentsNext["UI Components"]:::frontend
        DesignSystemNext["Design System (src/ui/)"]:::frontend
        StaticAssets["Public Assets"]:::frontend
        NJSDocker["Dockerfile"]:::infra
    end

    click AppRouter "https://github.com/prashant1177/notesbot/tree/main/frontend-next/src/app/"
    click APIWrapper "https://github.com/prashant1177/notesbot/blob/main/frontend-next/src/lib/api.js"
    click UIComponentsNext "https://github.com/prashant1177/notesbot/tree/main/frontend-next/src/components/"
    click DesignSystemNext "https://github.com/prashant1177/notesbot/tree/main/frontend-next/src/ui/"
    click StaticAssets "https://github.com/prashant1177/notesbot/tree/main/frontend-next/public/"
    click NJSDocker "https://github.com/prashant1177/notesbot/tree/main/frontend-next/Dockerfile"

    NextJS --> AppRouter
    NextJS --> APIWrapper
    NextJS --> UIComponentsNext
    NextJS --> DesignSystemNext
    NextJS --> StaticAssets
    NextJS --> NJSDocker

    %% React/Vite internals
    subgraph "React/Vite Internals"
        direction TB
        EditorPages["Latex Editor Pages"]:::frontend
        ProjectPages["Projects Pages"]:::frontend
        PremiumPages["Premium Pages (Razorpay)"]:::frontend
        UserAuthPages["UserAuth Pages"]:::frontend
        SharedUI["Shared UI (src/ui/)"]:::frontend
        APIClient["API Client (api.js)"]:::frontend
        RVDocker["Dockerfile"]:::infra
        ViteConfig["Vite Config"]:::infra
    end

    click EditorPages "https://github.com/prashant1177/notesbot/tree/main/frontend/src/Pages/LatexEditor/"
    click ProjectPages "https://github.com/prashant1177/notesbot/tree/main/frontend/src/Pages/Projects/"
    click PremiumPages "https://github.com/prashant1177/notesbot/blob/main/frontend/src/Pages/Premium/loadRazorpayScript.js"
    click UserAuthPages "https://github.com/prashant1177/notesbot/tree/main/frontend/src/Pages/UserAuth/"
    click SharedUI "https://github.com/prashant1177/notesbot/tree/main/frontend/src/ui/"
    click APIClient "https://github.com/prashant1177/notesbot/blob/main/frontend/src/api.js"
    click RVDocker "https://github.com/prashant1177/notesbot/tree/main/frontend/Dockerfile"
    click ViteConfig "https://github.com/prashant1177/notesbot/blob/main/frontend/vite.config.js"

    ReactFE --> EditorPages
    ReactFE --> ProjectPages
    ReactFE --> PremiumPages
    ReactFE --> UserAuthPages
    ReactFE --> SharedUI
    ReactFE --> APIClient
    ReactFE --> RVDocker
    ReactFE --> ViteConfig

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        APIServer["Node/Express API Server"]:::backend
        SocketSrv["WebSocket Server"]:::backend
    end

    APIServer --> SocketSrv

    %% API Internals
    subgraph "API Internals"
        direction TB
        APIEntry["index.js"]:::backend
        Routes["Routes (routes/)"]:::backend
        Models["Models (models/)"]:::backend
        Middleware["Middleware"]:::backend
        Utils["Utils (generateOtp, sendEmail)"]:::backend
        Templates["Templates"]:::backend
        Seed["Seed Scripts"]:::backend
        BkdDocker["Dockerfile"]:::infra
    end

    click APIEntry "https://github.com/prashant1177/notesbot/blob/main/backend/index.js"
    click Routes "https://github.com/prashant1177/notesbot/tree/main/backend/routes/"
    click Models "https://github.com/prashant1177/notesbot/tree/main/backend/models/"
    click Middleware "https://github.com/prashant1177/notesbot/tree/main/backend/middleware/"
    click Utils "https://github.com/prashant1177/notesbot/tree/main/backend/utils/"
    click Templates "https://github.com/prashant1177/notesbot/tree/main/backend/templates/"
    click Seed "https://github.com/prashant1177/notesbot/blob/main/backend/seed.js"
    click BkdDocker "https://github.com/prashant1177/notesbot/tree/main/backend/Dockerfile"

    APIServer --> APIEntry
    APIServer --> Routes
    APIServer --> Models
    APIServer --> Middleware
    APIServer --> Utils
    APIServer --> Templates
    APIServer --> Seed
    APIServer --> BkdDocker

    %% Data Layer
    MongoDB["MongoDB Atlas"]:::database

    %% External Services
    Gemini["Google Gemini API"]:::external
    EmailSMS["Email/SMS Service"]:::external
    RazorpayExt["Razorpay Payment Gateway"]:::external

    %% Infrastructure
    subgraph "Infrastructure"
        direction TB
        Nginx["Nginx Reverse Proxy"]:::infra
        DockerComp["docker-compose.yml"]:::infra
        Vercel["Vercel Hosting"]:::infra
        Render["Render Hosting"]:::infra
    end

    click Nginx "https://github.com/prashant1177/notesbot/blob/main/nginx/nginx.conf"
    click DockerComp "https://github.com/prashant1177/notesbot/blob/main/docker-compose.yml"
    click Vercel "https://github.com/prashant1177/notesbot/blob/main/frontend/vercel.json"

    %% Connections
    Browser1["User Browser"]:::external
    Browser1 -->|HTTP/HTTPS| NextJS
    Browser1 -->|HTTP/HTTPS| ReactFE
    ReactFE -->|WebSocket| SocketSrv
    NextJS -->|REST API| APIServer
    ReactFE -->|REST API| APIServer
    APIServer -->|CRUD| MongoDB
    APIServer -->|REST| Gemini
    APIServer -->|SMTP/SMS| EmailSMS
    APIServer -->|REST| RazorpayExt
    NextJS -->|Load Razorpay Script| RazorpayExt

    APIServer -->|docker network| Nginx
    ReactFE -->|docker network| Nginx
    NextJS -->|docker network| Nginx
    Nginx -->|routes| DockerComp

    DockerComp --> Render
    NextJS --> Vercel

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#0056b3,stroke-width:1px
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:1px
    classDef database fill:#fff3cd,stroke:#856404,stroke-width:1px
    classDef external fill:#e2e3e5,stroke:#6c757d,stroke-width:1px
    classDef infra fill:#f8f9fa,stroke:#343a40,stroke-width:1px
```
