# okkale/yaatrasarthi architecture

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

- Interactive diagram: https://gitdiagram.com/okkale/yaatrasarthi
- Repository: https://github.com/okkale/yaatrasarthi

## Overview

##### Project type and purpose
- This is a full-stack web application named MonumentPass for booking tickets to historical monuments in India.
- Frontend is built with React + TypeScript + Vite + Tailwind CSS, served as a single-page app (SPA).
- Backend is a RESTful API in Node.js + Express + TypeScript, using MongoDB via Mongoose.
- Key features: user authentication (JWT), monument discovery, ticket booking, user dashboard.

##### File structure
- Top-level directories and files:
- src/ – React source code (App.tsx, pages, components, contexts, main.tsx)
- server/ – Express API (index.ts, config.ts, routes, controllers likely under the hood)
- dist-server/ – Compiled backend (JS + maps + declarations) and config for production
- index.html, Vite and Tailwind config, package.json, tsconfigs, netlify.toml, vercel.json, DEPLOYMENT.md
- Patterns:
- Frontend uses component-based architecture with React Router for pages, Context API for auth state.
- Backend likely follows MVC or layered service pattern (config → routes → controllers → models).
- Separate build targets: Vite dev server on 3000, Express server on 5000; production builds in dist-server.
- Deployment configs hint at hosting SPA on Netlify/Vercel and serverless or Dockerized API.

##### README for additional insights
- Tech stack spells out the major frameworks/libraries: React, Express, MongoDB, JWT, bcryptjs, express-validator.
- README lists API endpoints for auth, monuments, bookings.
- Database schemas (User, Monument, Booking) define core data components.
- Scripts: concurrent dev of client+server, separate builds, production previews.

a. Main components
1. Client (Browser)
2. Frontend SPA (React/Vite)
3. API Gateway / Express Server
4. Database (MongoDB)
5. External services/libraries (JWT auth, bcrypt hashing, express-validator)
6. Deployment platform (Netlify/Vercel)
b. Relationships & interactions
- User → Browser UI → HTTP(S) to Frontend assets (index.html + JS bundle).
- Frontend issues AJAX calls (Axios) to backend API on `/api/*`.
- Express middleware verifies JWT, validates inputs, routes to controllers.
- Controllers interact with MongoDB via Mongoose models (User, Monument, Booking).
- On startup, backend seeds sample data if DB is empty.
c. Architectural patterns
- Separation of concerns: UI vs. business logic vs. data access
- Component hierarchy on frontend (pages → components → context providers)
- RESTful API design with resource-based endpoints
- Token-based stateless authentication (JWT)
d. Key technologies
- React 18, TypeScript, Vite, Tailwind CSS, React Router, Context API
- Node.js, Express, TypeScript, Mongoose, MongoDB, JWT, bcryptjs, express-validator

##### Detail without over-splitting
- Logical layers: Presentation (UI), Application (API), Data (DB).
- Auth flow: login/signup → JWT issuance → protected routes.
- Sample-data seeding as part of backend startup.
- Don’t omit deployment targets and environment config (netlify.toml, vercel.json, .env).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client (Browser)"
        direction TB
        Browser["User's Browser"]:::external
        HTML["index.html"]:::frontend
        Entry["src/main.tsx"]:::frontend
        App["src/App.tsx"]:::frontend
        subgraph "Pages" 
            direction TB
            Home["Home Page"]:::frontend
            Explore["Explore Page"]:::frontend
            BookingPg["Booking Page"]:::frontend
            DashboardPg["Dashboard Page"]:::frontend
            LoginSignup["Login/Signup Page"]:::frontend
        end
        Navbar["Navbar Component"]:::frontend
        AuthCtx["AuthContext"]:::frontend
    end

    Browser -->|"loads"| HTML
    HTML -->|"boots Vite"| Entry
    Entry -->|"renders"| App
    App -->|"renders"| Navbar
    App -->|"provides Context"| AuthCtx
    App -->|"routes to"| Home
    App -->|"routes to"| Explore
    App -->|"routes to"| BookingPg
    App -->|"routes to"| DashboardPg
    App -->|"routes to"| LoginSignup
    AuthCtx -->|"injects JWT"| App
    BookingPg -->|"calls API"| ExpressAPI
    DashboardPg -->|"calls API"| ExpressAPI
    Home -->|"fetch monuments"| ExpressAPI
    Explore -->|"fetch monuments"| ExpressAPI
    LoginSignup -->|"auth requests"| ExpressAPI

    %% Server Layer
    subgraph "Server (API)"
        direction TB
        ExpressAPI["Express API\n(server/index.ts)"]:::backend
        Config["Configuration\n(server/config.ts)"]:::backend
        MWAuth["Auth Middleware"]:::backend
        MWVal["Validation Middleware"]:::backend
        Routes["Routes\n(/auth,/monuments,/bookings)"]:::backend
        Controllers["Controllers"]:::backend
        Models["Mongoose Models"]:::backend
        Seed["Seed Data Initializer"]:::backend
        DB["MongoDB Atlas"]:::db
    end

    ExpressAPI -->|"loads"| Config
    ExpressAPI -->|"uses"| MWAuth
    ExpressAPI -->|"uses"| MWVal
    ExpressAPI -->|"routes to"| Routes
    Routes -->|"invokes"| Controllers
    Controllers -->|"queries"| Models
    Models -->|"interface with"| DB
    ExpressAPI -->|"on start"| Seed

    %% Deployment & Config
    subgraph "Deployment & Config"
        direction TB
        Netlify["netlify.toml"]:::external
        Vercel["vercel.json"]:::external
        Env[".env\n(Environment Variables)"]:::external
        Tailwind["tailwind.config.js"]:::external
        PostCSS["postcss.config.js"]:::external
        DistServer["dist-server/server/index.js"]:::external
    end

    HTML -->|"hosted on"| Netlify
    ExpressAPI -->|"deployed on"| Vercel
    ExpressAPI -->|"uses env"| Env
    Entry -->|"uses styles"| Tailwind
    Entry -->|"uses PostCSS"| PostCSS
    ExpressAPI -->|"production build"| DistServer

    %% Click Events
    click HTML "https://github.com/okkale/yaatrasarthi/blob/main/index.html"
    click Entry "https://github.com/okkale/yaatrasarthi/blob/main/src/main.tsx"
    click App "https://github.com/okkale/yaatrasarthi/blob/main/src/App.tsx"
    click Home "https://github.com/okkale/yaatrasarthi/blob/main/src/pages/Home.tsx"
    click Explore "https://github.com/okkale/yaatrasarthi/blob/main/src/pages/Explore.tsx"
    click BookingPg "https://github.com/okkale/yaatrasarthi/blob/main/src/pages/Booking.tsx"
    click DashboardPg "https://github.com/okkale/yaatrasarthi/blob/main/src/pages/Dashboard.tsx"
    click LoginSignup "https://github.com/okkale/yaatrasarthi/blob/main/src/pages/LoginSignup.tsx"
    click Navbar "https://github.com/okkale/yaatrasarthi/blob/main/src/components/Navbar.tsx"
    click AuthCtx "https://github.com/okkale/yaatrasarthi/blob/main/src/contexts/AuthContext.tsx"
    click ExpressAPI "https://github.com/okkale/yaatrasarthi/blob/main/server/index.ts"
    click Config "https://github.com/okkale/yaatrasarthi/blob/main/server/config.ts"
    click DistServer "https://github.com/okkale/yaatrasarthi/blob/main/dist-server/server/index.js"
    click Netlify "https://github.com/okkale/yaatrasarthi/blob/main/netlify.toml"
    click Vercel "https://github.com/okkale/yaatrasarthi/blob/main/vercel.json"
    click Tailwind "https://github.com/okkale/yaatrasarthi/blob/main/tailwind.config.js"
    click PostCSS "https://github.com/okkale/yaatrasarthi/blob/main/postcss.config.js"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef db fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
