# shreyagarg72/ecotravels architecture

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

- Interactive diagram: https://gitdiagram.com/shreyagarg72/ecotravels
- Repository: https://github.com/shreyagarg72/ecotravels

## Overview

##### Project type and purpose
- From the README and file tree, this is a full-stack web application (“EcoTravels”) that generates AI-driven travel itineraries.
- Frontend: React.js + Vite + TailwindCSS, handling UI and user input.
- Backend: Node.js + Express.js, providing RESTful endpoints.
- Database: MongoDB via Mongoose models.
- Authentication: Firebase Auth.
- External services: GeoApify (geocoding), Gemini dev AI API (itinerary and recommendations).

##### File structure
- Top-level dirs “frontend/” and “backend/” clearly separate client and server.
- Backend:
- config/db.js – MongoDB connection.
- model/Trip.js, User.js – Mongoose schemas.
- routes/…Router.js – Express routers for trips, users, rewards.
- index.js – Express app entry point.
- Frontend:
- src/components – React components organized by feature (Itinerary, PopularTrips, Pricing, InbuiltTrips, etc.).
- src/service/AIModal.jsx – likely the hook or component wrapping AI API calls.
- firebaseConfig.jsx – Firebase initialization for auth.
- vite.config.js, tailwind.config.js – build and styling setup.

##### README for additional insights
- The README highlights the AI itinerary generator, cost estimates, carbon footprint calculator, and tech stack.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (User Browser)"
        ReactApp["React SPA"]:::frontend
        UIComp["UI Components"]:::frontend
        FirebaseInit["Firebase Auth Init"]:::auth
        AIService["AI Service Wrapper"]:::service
    end

    %% Backend Layer
    subgraph "Backend (Server)"
        ExpressAPI["Express API"]:::backend

        subgraph "Auth"
            FirebaseSDK["Firebase Auth SDK"]:::auth
        end

        subgraph "API Layer"
            TripRouter["Trip Routes"]:::backend
            UserRouter["User Routes"]:::backend
            RewardsRouter["Rewards Routes"]:::backend
        end

        subgraph "Data Layer"
            DBConfig["DB Config"]:::backend
            TripModel["Trip Model"]:::model
            UserModel["User Model"]:::model
            MongoDB["MongoDB"]:::db
        end
    end

    %% External Services
    GeoAPI["GeoApify API"]:::external
    GeminiAPI["Gemini Dev AI API"]:::external

    %% Connections
    ReactApp -->|"renders"| UIComp
    ReactApp -->|"calls REST"| ExpressAPI
    ReactApp -->|"sends token"| FirebaseInit

    ExpressAPI -->|"verifies token"| FirebaseSDK
    ExpressAPI -->|"uses routes"| TripRouter
    ExpressAPI -->|"uses routes"| UserRouter
    ExpressAPI -->|"uses routes"| RewardsRouter
    ExpressAPI -->|"connects"| DBConfig
    ExpressAPI -->|"generate itinerary"| GeminiAPI
    ExpressAPI -->|"geocode"| GeoAPI

    TripRouter -->|"CRUD operations"| TripModel
    UserRouter -->|"CRUD operations"| UserModel
    RewardsRouter -->|"CRUD operations"| UserModel

    DBConfig -->|"connects to"| MongoDB
    TripModel -->|"collection"| MongoDB
    UserModel -->|"collection"| MongoDB

    %% Click Events
    click ReactApp "https://github.com/shreyagarg72/ecotravels/blob/main/frontend/src/App.jsx"
    click ReactApp "https://github.com/shreyagarg72/ecotravels/blob/main/frontend/src/main.jsx"
    click UIComp "https://github.com/shreyagarg72/ecotravels/tree/main/frontend/src/components/"
    click FirebaseInit "https://github.com/shreyagarg72/ecotravels/blob/main/frontend/firebaseConfig.jsx"
    click AIService "https://github.com/shreyagarg72/ecotravels/blob/main/frontend/src/service/AIModal.jsx"
    click ExpressAPI "https://github.com/shreyagarg72/ecotravels/blob/main/backend/index.js"
    click DBConfig "https://github.com/shreyagarg72/ecotravels/blob/main/backend/config/db.js"
    click TripModel "https://github.com/shreyagarg72/ecotravels/blob/main/backend/model/Trip.js"
    click UserModel "https://github.com/shreyagarg72/ecotravels/blob/main/backend/model/User.js"
    click TripRouter "https://github.com/shreyagarg72/ecotravels/blob/main/backend/routes/TripRouter.js"
    click UserRouter "https://github.com/shreyagarg72/ecotravels/blob/main/backend/routes/UserRouter.js"
    click RewardsRouter "https://github.com/shreyagarg72/ecotravels/blob/main/backend/routes/RewadsRouter.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#2B6CB0,color:#1A365D
    classDef backend fill:#E6F6FF,stroke:#3182CE,color:#2A4365
    classDef auth fill:#FFE8D0,stroke:#DD6B20,color:#7B341E
    classDef service fill:#E6FFFA,stroke:#38B2AC,color:#2C7A7B
    classDef model fill:#F3E8FF,stroke:#805AD5,color:#553C9A
    classDef db fill:#DFFDE0,stroke:#38A169,color:#22543D
    classDef external fill:#EDF2F7,stroke:#718096,color:#2D3748
```
