# debeshghorui/econirvana architecture

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

- Interactive diagram: https://gitdiagram.com/debeshghorui/econirvana
- Repository: https://github.com/debeshghorui/econirvana

## Overview

##### Main components and their roles
- Frontend Interface – Represented by the Next.js application (folder: src/app). This includes pages for:
- Home, About, Blog, Contact, Dashboard, and other user-interactive pages.
- Specialized areas like Recycling (with sub-pages for business, drop-off, mail-in, and scheduling pickups), Rewards, and Services (e.g., Data Destruction).
- Reusable UI Components – Located in the src/components directory (Navbar, Footer, UI elements like Button, Card, etc.). These provide a consistent look and feel across pages.
- Authentication & Context Management – Handled via React Context providers in the src/context directory (e.g., AuthContext.tsx) and components in src/app/login and src/app/signup.
- Utility and Library Integration – The src/lib directory includes key integrations such as Firebase initialization and the Gemini (EcoBot AI) integration, which add dynamic functionalities (authentication, chat functionality, etc.).
- Static Assets – Served from the public directory for images and other assets.
- Configuration & Build Tools – Files like next.config.mjs, tailwind.config, package.json, and various ESLint/TS configuration files which outline build settings, style rules, and deployment configuration (e.g., Vercel via vercel.json).

##### Relationships and interactions between components
- User Interaction Flow – Rendered through the Next.js app’s folder structure. The layout.tsx files in src/app and src/app/about (and others) indicate shared layouts (with consistent Header, Footer, Navbar).
- Data and Authentication Flow – User data managed via Firebase as indicated by .env.local configuration settings and firebase integration code in src/lib/firebase.ts. The AuthContext supplies global authentication state to the app.
- External Service Integration – The Gemini API, referenced in src/lib/gemini.ts, is likely used by the EcoBot chat component (see src/components/chat/ChatBot.tsx) to provide intelligent responses.
- Internal Communication – Components interact with one another (for instance, layout components wrapping content pages) and may leverage context providers to share state.
- Recycle Services – The recycling service pages (in src/app/recycle) suggest distinct flows for different recycling options, each representing a focused service within the overall system.

##### Important architectural patterns and design principles
- Modular Design – The structure emphasizes modularity with clear separation between pages (views) and reusable components.
- Component-Based Architecture – Even within pages, the use of smaller UI and layout components (as seen in src/components/ui and src/components/layout) follows React’s component-based design, making the system scalable and maintainable.
- Context API – Use of React Context (see src/context) for global state management (e.g., authentication and chat state).
- Integration with External Services – Leveraging cloud-based services (Firebase and Gemini) to handle backend-as-a-service functions and AI capabilities.
- Responsive Design – TailwindCSS is used to ensure responsiveness and a modern UI design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Application
    subgraph "Frontend Application"
        FE("Next.js Frontend"):::frontend
    end

    %% Pages
    subgraph "Pages"
        HOME("Home Page"):::frontend
        ABOUT("About Page"):::frontend
        BLOG("Blog Page"):::frontend
        BLOG_S("Blog Detail Page"):::frontend
        CONTACT("Contact Page"):::frontend
        DASH("Dashboard"):::frontend
        RECYCLE("Recycling Services"):::frontend
        REWARDS("Rewards Page"):::frontend
        DATA_DEST("Data Destruction Service"):::frontend
    end

    %% UI Components
    subgraph "UI Components"
        UI("Reusable UI Components"):::ui
        LAYOUT("Layout Components"):::ui
        CHATBOT("EcoBot Chat Component"):::ui
    end

    %% Authentication & Context
    subgraph "Authentication & Context"
        AUTHCTX("Auth Context"):::context
        CHATCTX("Chat Context"):::context
        LOGIN("Login Page"):::context
        SIGNUP("Signup Page"):::context
        FIREAUTHCFG("Firebase Auth Config"):::context
    end

    %% Utility & Library Integration
    subgraph "Utility & Library Integration"
        FIREBASE("Firebase Integration"):::util
        GEMINI("Gemini API Integration"):::util
    end

    %% External Services
    subgraph "External Services"
        FIREBASE_EXT("Firebase Services"):::external
        GEMINI_EXT("Gemini AI"):::external
    end

    %% Static Assets
    subgraph "Static Assets"
        ASSETS("Public Assets"):::asset
    end

    %% Configuration & Build Tools
    subgraph "Configuration & Build Tools"
        NEXTCFG("Next.js Configuration"):::config
        TAILWIND("TailwindCSS Configuration"):::config
        VERCEL("Vercel Deployment Config"):::config
        ESLINT("ESLint Configuration"):::config
        TSCONFIG("TypeScript Configuration"):::config
        PKG("Package.json"):::config
    end

    %% Connections between Frontend and Pages
    FE -->|"renders"| HOME
    FE -->|"renders"| ABOUT
    FE -->|"renders"| BLOG
    BLOG -->|"details"| BLOG_S
    FE -->|"renders"| CONTACT
    FE -->|"renders"| DASH
    FE -->|"renders"| RECYCLE
    FE -->|"renders"| REWARDS
    FE -->|"renders"| DATA_DEST

    %% Connections between Frontend and UI Components
    FE -->|"uses"| UI
    FE -->|"provides layout to"| LAYOUT

    %% UI Components and Context
    LAYOUT -->|"integrates"| AUTHCTX
    UI -->|"accesses"| AUTHCTX
    UI -->|"accesses"| CHATCTX

    %% Authentication flow
    LOGIN -->|"updates"| AUTHCTX
    SIGNUP -->|"updates"| AUTHCTX
    LOGIN -->|"configured by"| FIREAUTHCFG
    SIGNUP -->|"configured by"| FIREAUTHCFG
    FIREAUTHCFG -->|"supports"| AUTHCTX

    %% Integration with Utility & Library
    FE -->|"interacts with"| FIREBASE
    AUTHCTX -->|"connects to"| FIREBASE
    FIREBASE -->|"communicates with"| FIREBASE_EXT

    CHATBOT -->|"queries"| GEMINI
    GEMINI -->|"serves"| GEMINI_EXT
    CHATBOT -->|"utilizes"| CHATCTX

    %% Static Assets usage
    FE -->|"loads"| ASSETS

    %% Configuration influence
    NEXTCFG -->|"configures"| FE
    TAILWIND -->|"styles"| FE
    VERCEL -->|"deploys"| FE
    ESLINT -->|"lints"| FE
    TSCONFIG -->|"types"| FE
    PKG -->|"manages deps for"| FE

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef ui fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef context fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef util fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef external fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef asset fill:#D6EAF8,stroke:#2471A3,stroke-width:2px;
    classDef config fill:#FDEBD0,stroke:#D35400,stroke-width:2px;

    %% Click Events
    click FE "https://github.com/debeshghorui/econirvana/tree/main/src/app"
    click HOME "https://github.com/debeshghorui/econirvana/blob/main/src/app/page.tsx"
    click ABOUT "https://github.com/debeshghorui/econirvana/blob/main/src/app/about/page.tsx"
    click BLOG "https://github.com/debeshghorui/econirvana/blob/main/src/app/blog/page.tsx"
    click BLOG_S "https://github.com/debeshghorui/econirvana/blob/main/src/app/blog/[slug]/page.tsx"
    click CONTACT "https://github.com/debeshghorui/econirvana/blob/main/src/app/contact/page.tsx"
    click DASH "https://github.com/debeshghorui/econirvana/blob/main/src/app/dashboard/page.tsx"
    click RECYCLE "https://github.com/debeshghorui/econirvana/tree/main/src/app/recycle"
    click REWARDS "https://github.com/debeshghorui/econirvana/blob/main/src/app/rewards/page.tsx"
    click DATA_DEST "https://github.com/debeshghorui/econirvana/blob/main/src/app/services/data-destruction/page.tsx"
    click UI "https://github.com/debeshghorui/econirvana/tree/main/src/components/ui"
    click LAYOUT "https://github.com/debeshghorui/econirvana/tree/main/src/components/layout"
    click CHATBOT "https://github.com/debeshghorui/econirvana/blob/main/src/components/chat/ChatBot.tsx"
    click AUTHCTX "https://github.com/debeshghorui/econirvana/blob/main/src/context/AuthContext.tsx"
    click CHATCTX "https://github.com/debeshghorui/econirvana/blob/main/src/context/ChatContext.tsx"
    click LOGIN "https://github.com/debeshghorui/econirvana/blob/main/src/app/login/page.tsx"
    click SIGNUP "https://github.com/debeshghorui/econirvana/blob/main/src/app/signup/page.tsx"
    click FIREAUTHCFG "https://github.com/debeshghorui/econirvana/blob/main/src/app/firebaseAuth/config.tsx"
    click FIREBASE "https://github.com/debeshghorui/econirvana/blob/main/src/lib/firebase.ts"
    click GEMINI "https://github.com/debeshghorui/econirvana/blob/main/src/lib/gemini.ts"
    click ASSETS "https://github.com/debeshghorui/econirvana/tree/main/public"
    click NEXTCFG "https://github.com/debeshghorui/econirvana/blob/main/next.config.js"
    click TAILWIND "https://github.com/debeshghorui/econirvana/blob/main/tailwind.config.mjs"
    click VERCEL "https://github.com/debeshghorui/econirvana/blob/main/vercel.json"
    click ESLINT "https://github.com/debeshghorui/econirvana/blob/main/.eslintrc.js"
    click TSCONFIG "https://github.com/debeshghorui/econirvana/blob/main/tsconfig.json"
    click PKG "https://github.com/debeshghorui/econirvana/blob/main/package.json"
```
