# plesnte25/into-the-wild architecture

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

- Interactive diagram: https://gitdiagram.com/plesnte25/into-the-wild
- Repository: https://github.com/plesnte25/into-the-wild

## Overview

##### Project Type and Purpose
- This is a full-stack web application called “IntoTheWilds,” providing property listings, tours, events, and bookings.
- The frontend (intoTheWilds-frontend-main) is a React/Vite/Tailwind SPA with both public user pages and an admin dashboard.
- The backend (intothewilds-backend-main) is a Node.js/Express monolith exposing RESTful APIs, using Mongoose models to persist data to MongoDB.

##### File-Structure Analysis
- Top-level modules:
- intoTheWilds-frontend-main – React code under src/, public assets, admin hooks/layout/pages, API client in api.js
- intothewilds-backend-main – Express server.js, config/db.js, MVC folders: models/, controller/, routes/, plus seed scripts
- Architectural patterns:
- Frontend: Component-based UI, React Context for application state, React Router (src/routers/router.jsx), UI library under components/ui.
- Backend: Layered MVC (routes → controllers → models), auth middleware, configuration separation, seed scripts.

a. Frontend Layer
- Web Browser / Mobile Browser
- React SPA:
- Public UI Components (pages: Home, Events, Tours, Booking flow)
- Admin UI Components (Dashboard, Reservation, Property management)
- State management: AppContext, BookingContext
- API client (src/api.js)
b. Backend Layer
- API Gateway: Express.js server.js
- Controllers (authController, bookingController, etc.)
- Business logic & validation (middleware/authMiddleware.js)
- Data Access: Mongoose models (User, Booking, Properties, ToursQuery, etc.)
- Seed scripts (scripts/seedAdmin.js, seedInventory.js)
c. Data Layer
- MongoDB instance (hosted or Docker container)
- Collections: users, bookings, properties, reviews, calendars, inventory, etc.
d. External Services
- Payment gateway (Razorpay integration via api.js/assets/razorpay.png)
- Email service (email.js in utils)
- Third-party APIs (e.g., Google Maps, if used)

##### Relationships and Data Flow
- User → Browser → React UI
- UI invokes API client (api.js) via HTTP/HTTPS →
- React UI → Express REST endpoints (/api/auth, /api/bookings, /api/properties, etc.)
- Express routes delegate to controllers → controllers invoke Mongoose models → MongoDB
- Controllers may call external service adapters:
- Payment service (Razorpay) for checkout
- Email utility for confirmations
- Responses flow back up: MongoDB → Mongoose → Controller → Express → React → Browser UI

##### Architectural Patterns & Principles
- Separation of Concerns: UI vs. business logic vs. data access
- MVC on the server, Component-based on the client
- Single SPA codebase serving both customer-facing and admin UIs
- Configuration-as-code: environment variables (.env), dockerfiles, build scripts (Vite, Docker)

##### Detail Level
- High-level modules without overwhelming file listings: group components/pages under “React UI”.
- Representative controllers and models rather than every route file.
- Essential architecture: SPA → REST API → DB, with admin and user flows, plus external integrations.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Users
    Customer["Customer (Web/Mobile Browser)"]:::external
    Admin["Admin User (Web Browser)"]:::external

    %% Frontend Layer
    subgraph "Frontend (React SPA)"
        Main["Entry Point: main.jsx & App.jsx"]:::frontend
        Router["Router\nrouter.jsx"]:::frontend
        APIClient["API Client\napi.js"]:::frontend
        PublicPages["Public Pages"]:::frontend
        AdminPages["Admin Pages"]:::frontend
        AdminLayout["Admin Layout\n(AdminLayout, Sidebar, Topbar)"]:::frontend
        Hooks["Admin Hooks\nuseReservation.js"]:::frontend
        Context["State Contexts\nAppContext.jsx"]:::frontend
        UIComponents["UI Component Library"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Express API)"
        Server["Express Server\nserver.js"]:::backend
        DBConfig["DB Config\ndb.js"]:::backend
        Routes["Routes"]:::backend
        Controllers["Controllers"]:::backend
        AuthMW["Auth Middleware"]:::backend
        Models["Mongoose Models"]:::backend
        Seed["Seed Scripts"]:::backend
    end

    %% Data and External Services
    subgraph "Data & External"
        MongoDB["MongoDB"]:::database
        Payment["Razorpay Gateway"]:::external
        Email["Email Service"]:::external
    end

    %% Relationships
    Customer -->|"Access SPA"| Main
    Admin -->|"Access SPA"| Main

    Main --> Router
    Router --> PublicPages
    Router --> AdminPages

    PublicPages -.-> UIComponents
    AdminPages -.-> UIComponents

    PublicPages --> Context
    AdminPages --> Context

    PublicPages --> APIClient
    AdminPages --> APIClient

    APIClient -->|"HTTP Requests"| Server
    Server --> Routes
    Routes --> Controllers
    Controllers --> Models
    Models --> MongoDB
    Controllers -->|uses| AuthMW
    Controllers -->|runs| Seed

    Controllers -->|calls| Payment
    Controllers -->|sends| Email

    %% Click Events
    click Main "https://github.com/plesnte25/into-the-wild/blob/main/intoTheWilds-frontend-main/src/main.jsx"
    click Router "https://github.com/plesnte25/into-the-wild/blob/main/intoTheWilds-frontend-main/src/routers/router.jsx"
    click APIClient "https://github.com/plesnte25/into-the-wild/blob/main/intoTheWilds-frontend-main/src/api.js"
    click PublicPages "https://github.com/plesnte25/into-the-wild/tree/main/intoTheWilds-frontend-main/src/pages/"
    click AdminPages "https://github.com/plesnte25/into-the-wild/tree/main/intoTheWilds-frontend-main/src/admin/pages/"
    click AdminLayout "https://github.com/plesnte25/into-the-wild/blob/main/intoTheWilds-frontend-main/src/admin/layout/AdminLayout.jsx"
    click Hooks "https://github.com/plesnte25/into-the-wild/blob/main/intoTheWilds-frontend-main/src/admin/hooks/useReservation.js"
    click Context "https://github.com/plesnte25/into-the-wild/blob/main/intoTheWilds-frontend-main/src/context/AppContext.jsx"
    click UIComponents "https://github.com/plesnte25/into-the-wild/tree/main/intoTheWilds-frontend-main/src/components/ui/"

    click Server "https://github.com/plesnte25/into-the-wild/blob/main/intothewilds-backend-main/server.js"
    click DBConfig "https://github.com/plesnte25/into-the-wild/blob/main/intothewilds-backend-main/config/db.js"
    click Routes "https://github.com/plesnte25/into-the-wild/tree/main/intothewilds-backend-main/routes/"
    click Controllers "https://github.com/plesnte25/into-the-wild/tree/main/intothewilds-backend-main/controller/"
    click AuthMW "https://github.com/plesnte25/into-the-wild/blob/main/intothewilds-backend-main/middleware/authMiddleware.js"
    click Models "https://github.com/plesnte25/into-the-wild/tree/main/intothewilds-backend-main/models/"
    click Seed "https://github.com/plesnte25/into-the-wild/blob/main/intothewilds-backend-main/scripts/seedAdmin.js"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#006064
    classDef backend fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32
    classDef database fill:#FFF3E0,stroke:#EF6C00,color:#EF6C00
    classDef external fill:#F3E5F5,stroke:#8E24AA,color:#8E24AA
```
