# pkm69/tourism-jharkhand architecture

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

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

## Overview

##### Project type and purpose
- This is a full-stack monorepo for an interactive tourism platform (“Tourism-Jharkhand”).
- Frontend: Next.js 13 (app router), React components, SSR/SSG, client APIs under `app/api/*`.
- Backend: Node.js + Express REST API in `backend/` (MVC pattern with controllers, routes, services, middleware).
- Database: MongoDB with GridFS for image storage.
- External integrations: AI/chatbot, Razorpay (payments), a simple blockchain service for provenance, mapping (GeoJSON).

##### File structure
- Top-level `app/` → Next.js application source (pages, layouts, API routes, React components under `components/`).
- `.next/` → build output (SSR chunks, static assets).
- `backend/` → Express server:
- `config/` (DB connection)
- `controllers/` (business logic per resource)
- `routes/` (REST endpoints)
- `services/` (blockchainService, paymentService)
- `models/` (Mongoose schemas)
- `middleware/` (auth, error handling, upload)
- `db/` and `backend/scripts/` for seed data and DB initialization.
- `components/`, `hooks/`, `lib/` for shared UI widgets, React hooks, and client-side service wrappers.
- `public/` for static assets (maps, geoJSON).

##### Key README insights
- Platform features interactive maps, AR/VR previews, image management, search/filter, analytics.
- Tech: Node/Express, MongoDB/GridFS, Multer, Helmet/CORS.
- Execution: seed data, dev / production scripts.

##### Elements
- Clear labels for each component (e.g., “Next.js App”, “Express API”, “MongoDB/GridFS”)
- User → Next.js → API → Database
- Backend → External services
- Frontend → AI library
- Blue rectangles for application components

**Summary:**
- Tier 1: Next.js front-end (SSR + client components + built-in API)
- Tier 2: Express REST API (controllers, routes, middleware, services)
- Tier 3: MongoDB + GridFS data store

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Tier
    subgraph "Presentation Tier"
        direction TB
        User["User / Browser"]:::external
        NextJSApp["Next.js App"]:::presentation
        UIComponents["Shared UI Components"]:::presentation
        Hooks["React Hooks"]:::presentation
        Lib["Client‐side Service Wrappers"]:::presentation
        GlobalStyles1["Global Styles (styles/globals.css)"]:::presentation
        GlobalStyles2["Global Styles (app/globals.css)"]:::presentation
    end

    %% Application Tier
    subgraph "Application Tier"
        direction TB
        ExpressAPI["Express REST API"]:::application
        DBConfig["DB Config"]:::application
        Controllers["Controllers"]:::application
        Routes["Routes"]:::application
        Services["Service Layer"]:::application
        Middleware["Middleware"]:::application
        Models["Models"]:::application
        Scripts["Seed & Init Scripts"]:::application
    end

    %% Data Tier
    subgraph "Data Tier"
        direction TB
        MongoDB["MongoDB"]:::database
        GridFS["GridFS"]:::database
    end

    %% External Services
    subgraph "External Services"
        direction TB
        AIService["AI / Chatbot Service"]:::external
        Razorpay["Razorpay Gateway"]:::external
        Blockchain["Blockchain Service"]:::external
        MapData["Map Tiles / GeoJSON"]:::external
    end

    %% Presentation to Application
    User -->|"HTTP / SSR / CSR"| NextJSApp
    NextJSApp -->|"REST API Calls"| ExpressAPI
    NextJSApp -->|"Uses UI Components"| UIComponents
    NextJSApp -->|"Uses Hooks"| Hooks
    NextJSApp -->|"Uses Wrappers"| Lib
    NextJSApp -->|"Applies Styles"| GlobalStyles1
    NextJSApp -->|"Applies Styles"| GlobalStyles2

    %% Application internal structure
    ExpressAPI --> DBConfig
    ExpressAPI --> Controllers
    ExpressAPI --> Routes
    ExpressAPI --> Services
    ExpressAPI --> Middleware
    ExpressAPI --> Models
    ExpressAPI --> Scripts

    Routes --> Controllers
    Controllers --> Models
    Controllers --> MongoDB
    Controllers --> GridFS
    Controllers --> Services
    Controllers --> Middleware

    %% Services to external
    Services -->|"Call AI"| AIService
    Services -->|"Process Payment"| Razorpay
    Services -.->|"Async Write"| Blockchain
    Controllers -->|"Serve Map Data"| MapData

    %% Data Tier connections
    MongoDB --> GridFS

    %% Click Events
    click NextJSApp "https://github.com/pkm69/tourism-jharkhand/tree/main/app/"
    click UIComponents "https://github.com/pkm69/tourism-jharkhand/tree/main/components/"
    click Hooks "https://github.com/pkm69/tourism-jharkhand/tree/main/hooks/"
    click Lib "https://github.com/pkm69/tourism-jharkhand/tree/main/lib/"
    click GlobalStyles1 "https://github.com/pkm69/tourism-jharkhand/blob/main/styles/globals.css"
    click GlobalStyles2 "https://github.com/pkm69/tourism-jharkhand/blob/main/app/globals.css"
    click ExpressAPI "https://github.com/pkm69/tourism-jharkhand/tree/main/backend/"
    click DBConfig "https://github.com/pkm69/tourism-jharkhand/blob/main/backend/config/database.js"
    click Controllers "https://github.com/pkm69/tourism-jharkhand/tree/main/backend/controllers/"
    click Routes "https://github.com/pkm69/tourism-jharkhand/tree/main/backend/routes/"
    click Services "https://github.com/pkm69/tourism-jharkhand/tree/main/backend/services/"
    click Middleware "https://github.com/pkm69/tourism-jharkhand/tree/main/backend/middleware/"
    click Models "https://github.com/pkm69/tourism-jharkhand/tree/main/backend/models/"
    click Scripts "https://github.com/pkm69/tourism-jharkhand/tree/main/backend/scripts/"
    click Scripts "https://github.com/pkm69/tourism-jharkhand/blob/main/backend/init-mongo.js"
    click AIService "https://github.com/pkm69/tourism-jharkhand/blob/main/lib/ai-services.ts"
    click Razorpay "https://github.com/pkm69/tourism-jharkhand/blob/main/lib/razorpay.ts"
    click Blockchain "https://github.com/pkm69/tourism-jharkhand/blob/main/backend/services/blockchainService.js"
    click Blockchain "https://github.com/pkm69/tourism-jharkhand/blob/main/backend/services/test-blockchain.js"
    click MapData "https://github.com/pkm69/tourism-jharkhand/blob/main/public/JHARKHAND_DISTRICTS.geojson"

    %% Additional feature mappings
    click ChatbotController "https://github.com/pkm69/tourism-jharkhand/blob/main/backend/controllers/chatbotController.js"
    click ChatbotRoute "https://github.com/pkm69/tourism-jharkhand/blob/main/backend/routes/chatbot.js"
    click PaymentController "https://github.com/pkm69/tourism-jharkhand/blob/main/backend/controllers/paymentController.js"
    click PaymentRoute "https://github.com/pkm69/tourism-jharkhand/blob/main/backend/routes/payment.js"
    click InteractiveMap "https://github.com/pkm69/tourism-jharkhand/blob/main/components/interactive-map.tsx"
    click UploadMiddleware "https://github.com/pkm69/tourism-jharkhand/blob/main/backend/middleware/upload.js"
    click ImagesController "https://github.com/pkm69/tourism-jharkhand/blob/main/backend/controllers/imagesController.js"
    click ImagesRoute "https://github.com/pkm69/tourism-jharkhand/blob/main/backend/routes/images.js"
    click TravelPlannerPage "https://github.com/pkm69/tourism-jharkhand/blob/main/app/travel-planner/page.tsx"
    click TravelPlannerController "https://github.com/pkm69/tourism-jharkhand/blob/main/backend/controllers/travelPlannerController.js"
    click TravelPlannerRoute "https://github.com/pkm69/tourism-jharkhand/blob/main/backend/routes/travelPlanner.js"

    %% Styles
    classDef presentation fill:#AED6F1,stroke:#1B4F72,color:#154360
    classDef application fill:#ABEBC6,stroke:#1D8348,color:#145A32
    classDef database fill:#F9E79F,stroke:#B9770E,color:#7D6608
    classDef external fill:#F5B7B1,stroke:#C0392B,color:#641E16
```
