# pratham10805/tourism-jharkhand architecture

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

- Interactive diagram: https://gitdiagram.com/pratham10805/tourism-jharkhand
- Repository: https://github.com/pratham10805/tourism-jharkhand

## Overview

##### Project type and purpose
- This is a full-stack, monorepo application combining:
- A Next.js 13 “app/” front-end with server-side rendering (SSR), static asset hosting, React components, interactive maps, AR/VR views, and client-side API routes.
- A standalone Express.js backend (“backend/”) providing a RESTful API for data (places, images, payment, chatbot), user management, and business logic.
- A MongoDB database with GridFS for image storage.
- Integrations with external services: payment gateway (Razorpay), AI/chatbot service (OpenAI), and potentially blockchain data.

##### File structure
- Top-level “app/” folder: Next.js pages, API routes (chatbot widget, analytics export, etc.), AR/VR page, interactive map, reusable UI components (“components/” and “components/ui/”), global styles, hooks, and libs.
- “backend/”: Express server entry (server.js), controllers, routes (auth, places, payment, chatbot, travelPlanner), middleware (auth, errorHandler, upload), models (Mongoose schemas), services (blockchainService), and config/database.js.
- Config files: Dockerfile & docker-compose.yml for the backend, .env.example, tsconfig, next.config.mjs, postcss.config.mjs.
- Static assets & build outputs under “.next/” and “public/”.

##### Extract architecture from README
- Backend: Node.js, Express, MongoDB + GridFS, Multer for uploads, security via Helmet/CORS/rate-limiting.
- Frontend: Next.js with interactive maps (Leaflet), charts (Recharts), AR/VR previews, a chatbot widget, search/filter UIs.
- Features: upload/view images, search by proximity/district, AR/VR site preview, analytics export.

##### Main components & relationships
a. Frontend (Next.js app)
- UI Components (React pages, map, AR/VR, chatbot widget)
- Next API Routes (in app/api/) for light SSR-adjacent calls (e.g., analytics export)
- Static Asset Hosting via Next.js CDN (for CSS, JS, geoJSON, images)
b. Backend API (Express.js)
- Auth Service (login/registration endpoints)
- Places Service (CRUD places, search/filter)
- Images Service (GridFS file upload/download)
- Chatbot Service (message route → OpenAI)
- Payment Service (checkout/verify → Razorpay)
- Travel Planner Service (custom travel‐itinerary logic)
c. Database Layer
- MongoDB cluster for data collections (places, users, orders, feedback)
- GridFS for large images and AR/VR assets
d. External services
- Razorpay (payment processing)
- OpenAI (chatbot)
- Optional blockchain node (blockchain_data/)
e. Infrastructure
- Vercel (or similar) hosting for front-end
- Docker / Docker-Compose for backend deployment

##### How data flows
- User→Browser: loads SSR pages from Next.js → interacts with UI (map, listings, AR/VR, chatbot).
- Browser→Next API Routes: lightweight calls (e.g., analytics export), or directly to Express API.
- Next.js → Express API → MongoDB (via Mongoose) or GridFS.
- Express API → Razorpay for payment, → OpenAI for chatbot, → returns results to front-end.
- Static assets (geoJSON, images) served from Vercel/CDN or public/ folder.

##### Architectural patterns & principles
- Two-tier separation: Presentation (Next.js) vs. Business Logic + Data (Express + MongoDB).
- RESTful API design, layered controllers → services → models.
- SSR + SSG for performance, with client-side hydration.
- Modular controllers & middleware for cross-cutting concerns (auth, error handling, file upload).
- CI through Docker and docker-compose for backend, Vercel deployments for front-end.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Frontend Layer
    subgraph "User & Frontend Layer"
        Browser["User Browser"]:::frontend
        NextJS["Next.js SSR"]:::frontend
        APIgw["Next.js API Routes"]:::frontend
        subgraph "UI Components"
            UIComp["React Components"]:::frontend
            UIUI["UI Subcomponents"]:::frontend
            MapComp["Interactive Map"]:::frontend
            ChatComp["Chatbot Widget"]:::frontend
        end
        subgraph "Styles & Utils"
            Global1["Global Styles (app/globals.css)"]:::frontend
            Global2["Global Styles (styles/globals.css)"]:::frontend
            Hooks["React Hooks"]:::frontend
            Libs["Client-side Libs"]:::frontend
        end
        ARVR["AR/VR Page"]:::frontend
        AuthPage["Authentication Page"]:::frontend
        StaticAssets["Static Asset CDN"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Service (Express.js)" 
        Express["Express Entry"]:::backend
        DBConfig["DB Config"]:::backend
        subgraph "Controllers & Routes"
            subgraph AuthService
                AuthCtrl["Auth Controller"]:::backend
                AuthRoute["Auth Routes"]:::backend
            end
            subgraph PlacesService
                PlacesCtrl["Places Controller"]:::backend
                PlacesRoute["Places Routes"]:::backend
            end
            subgraph ImagesService
                ImagesCtrl["Images Controller"]:::backend
                ImagesRoute["Images Routes"]:::backend
            end
            subgraph ChatbotService
                ChatbotCtrl["Chatbot Controller"]:::backend
                ChatbotRoute["Chatbot Routes"]:::backend
            end
            subgraph PaymentService
                PaymentCtrl["Payment Controller"]:::backend
                PaymentRoute["Payment Routes"]:::backend
            end
            subgraph TravelPlannerService
                TravelPlannerCtrl["TravelPlanner Controller"]:::backend
                TravelPlannerRoute["TravelPlanner Routes"]:::backend
            end
        end
        Middleware["Middleware"]:::backend
        Models["Models (Schemas)"]:::backend
        BlockchainService["Blockchain Service"]:::backend
        subgraph "Deployment Config"
            Dockerfile["Dockerfile"]:::backend
            DockerCompose["docker-compose.yml"]:::backend
        end
    end

    %% Data Layer
    subgraph "Database Layer"
        MongoDB["MongoDB Cluster"]:::db
        GridFS["GridFS Storage"]:::db
    end

    %% External Services
    subgraph "External Services"
        Razorpay["Razorpay"]:::external
        OpenAI["OpenAI Chatbot"]:::external
        BlockchainNode["Blockchain Node"]:::external
    end

    %% Static Assets
    PublicAssets["Public Static Assets"]:::frontend
    BlockchainData["Blockchain Data Store"]:::db

    %% Connections
    Browser -->|SSR Pages| NextJS
    NextJS -->|API Calls| APIgw
    NextJS -->|Serves Assets| StaticAssets
    NextJS -->|Uses UI| UIComp
    NextJS -->|Uses UI| UIUI
    NextJS -->|Renders Map| MapComp
    NextJS -->|Renders Chatbot| ChatComp
    NextJS -->|Renders AR/VR| ARVR
    NextJS -->|Navigates Auth| AuthPage
    NextJS -->|Loads Styles| Global1
    NextJS -->|Loads Styles| Global2
    NextJS -->|Imports Hooks| Hooks
    NextJS -->|Imports Libs| Libs

    APIgw -->|HTTPS| Express
    Express -->|connects| MongoDB
    Express -->|uses| GridFS
    Express -->|loads config| DBConfig
    Express -->|applies| Middleware
    Express -->|registers| AuthService
    Express -->|registers| PlacesService
    Express -->|registers| ImagesService
    Express -->|registers| ChatbotService
    Express -->|registers| PaymentService
    Express -->|registers| TravelPlannerService
    Express -->|uses| Models
    Express -->|uses| BlockchainService

    Express -->|Dockerized| Dockerfile
    Express -->|Docker Compose| DockerCompose

    PlacesService -->|CRUD| MongoDB
    ImagesService -->|upload/download| GridFS
    ChatbotService -->|POST /chat| OpenAI
    PaymentService -->|POST /checkout| Razorpay
    PaymentService -->|Webhook| Razorpay
    TravelPlannerService -->|Logic| MongoDB

    PublicAssets -->|Served| StaticAssets
    BlockchainData -->|Optional| Express

    %% Click Events
    click UIComp "https://github.com/pratham10805/tourism-jharkhand/tree/main/components/"
    click UIUI "https://github.com/pratham10805/tourism-jharkhand/tree/main/components/ui/"
    click MapComp "https://github.com/pratham10805/tourism-jharkhand/blob/main/components/interactive-map.tsx"
    click ChatComp "https://github.com/pratham10805/tourism-jharkhand/blob/main/components/chatbot-widget.tsx"
    click Global1 "https://github.com/pratham10805/tourism-jharkhand/blob/main/app/globals.css"
    click Global2 "https://github.com/pratham10805/tourism-jharkhand/blob/main/styles/globals.css"
    click Hooks "https://github.com/pratham10805/tourism-jharkhand/tree/main/hooks/"
    click Libs "https://github.com/pratham10805/tourism-jharkhand/tree/main/lib/"
    click APIgw "https://github.com/pratham10805/tourism-jharkhand/tree/main/app/api/"
    click ARVR "https://github.com/pratham10805/tourism-jharkhand/blob/main/app/ar-vr/page.tsx"
    click AuthPage "https://github.com/pratham10805/tourism-jharkhand/blob/main/app/auth/page.tsx"
    click Express "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/server.js"
    click DBConfig "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/config/database.js"
    click AuthCtrl "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/controllers/authController.js"
    click AuthRoute "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/routes/auth.js"
    click PlacesCtrl "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/controllers/placesController.js"
    click PlacesRoute "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/routes/places.js"
    click ImagesCtrl "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/controllers/imagesController.js"
    click ImagesRoute "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/routes/images.js"
    click ChatbotCtrl "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/controllers/chatbotController.js"
    click ChatbotRoute "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/routes/chatbot.js"
    click PaymentCtrl "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/controllers/paymentController.js"
    click PaymentRoute "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/routes/payment.js"
    click TravelPlannerCtrl "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/controllers/travelPlannerController.js"
    click TravelPlannerRoute "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/routes/travelPlanner.js"
    click Middleware "https://github.com/pratham10805/tourism-jharkhand/tree/main/backend/middleware/"
    click Models "https://github.com/pratham10805/tourism-jharkhand/tree/main/backend/models/"
    click BlockchainService "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/services/blockchainService.js"
    click Dockerfile "https://github.com/pratham10805/tourism-jharkhand/tree/main/backend/Dockerfile"
    click DockerCompose "https://github.com/pratham10805/tourism-jharkhand/blob/main/backend/docker-compose.yml"
    click PublicAssets "https://github.com/pratham10805/tourism-jharkhand/tree/main/public/"
    click BlockchainData "https://github.com/pratham10805/tourism-jharkhand/tree/main/blockchain_data/"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#1E90FF,stroke-width:2px
    classDef backend fill:#E0F8E0,stroke:#2E8B57,stroke-width:2px
    classDef db fill:#FFE4B5,stroke:#FF8C00,stroke-width:2px
    classDef external fill:#E8D0FF,stroke:#8A2BE2,stroke-width:2px
```
