# joel112003/wanderlust architecture

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

- Interactive diagram: https://gitdiagram.com/joel112003/wanderlust
- Repository: https://github.com/joel112003/wanderlust

## Overview

##### Project Type & Purpose
- WanderLust is a full-stack application. Its primary purpose is to allow users to browse, book, and review holiday rental properties with interactive map features.
- The README confirms backend technologies (Node.js, Express, MongoDB, Passport.js, Cloudinary for image management) and frontend technologies (HTML, CSS, JavaScript, EJS templates as mentioned, although the file tree also indicates a modern JS frontend structure).

##### File Structure
- The project is clearly divided into two major parts: the "backend" and the "frontend."
- The backend folder contains key components:
- app.js and cloudConfig.js for application setup and cloud integration.
- Configuration files (config folder with passport.js and secretGenerator.js) indicating authentication and security setups.
- Controllers (e.g., listing.js, user.js, review.js, notification.js) suggesting a RESTful style.
- Routes that directly link HTTP endpoints to controller logic.
- Models directory representing the data layer, likely using MongoDB schemas.
- Utility files and a cloud-related secret token generator.
- The frontend folder has:
- A public directory with static assets (HTML file, styles, manifest).
- A src directory with React-like components and views (e.g., BookingConfirmation, Map, Navbar, Signup, etc.) which control the UI and user interactions.
- Custom CSS and JS utilities for styling and additional functionality.
- This separation into distinct frontend and backend directories reinforces a modern full-stack architecture with clearly separated concerns.

a. Components to Include:
- Frontend Client: Represent the user interface and components (Navigation, Authentication screens, Listing details, Interactive map, etc.).
- Backend Server: API server handling business logic, controllers, routing, authentication (Passport.js), and error handling.
- Database: MongoDB (storing user data, listings, reviews, notifications, tokens, bookings).
- Third-Party Services: Cloudinary for image management, interactive Maps integration.
b. Relationships:
- The Frontend interacts with the Backend via HTTP API calls.
- The Backend communicates with the Database for CRUD operations.
- The Backend integrates with third-party services (Cloudinary for image uploads and a Maps API for geolocation services).
c. Architectural Patterns:
- The backend follows a standard MVC (Model-View-Controller) or similar RESTful pattern with controllers, models, and routes.
- Authentication is handled using middleware (Passport.js), ensuring secure user sessions.
- The separation of frontend and backend demonstrates the decoupling of concerns.
d. Technologies Highlight:
- Backend: Node.js, Express, Passport.js, and MongoDB.
- Frontend: JavaScript, EJS/HTML, CSS (with Tailwind for styling support from tailwind.config.js), and potentially a React-like structure.
- Third-party: Cloudinary and mapping services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend"
        UI_Components["UI Components"]:::frontend
        Views["Views Components"]:::frontend
        Layouts["Layout Components"]:::frontend
        Assets["Static Assets"]:::frontend
        JS_Util["JS Utilities"]:::frontend
        CSS_Util["CSS Utilities"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend"
        ExpressServer["Express Server"]:::backend
        CloudIntegration["Cloud Integration"]:::backend
        Passport["Auth: Passport"]:::backend
        SecretGen["Secret Generation"]:::backend
        SecretToken["Secret Token Utility"]:::backend
        Routes["API Routes"]:::backend
        ListingCtrl["Listing Controller"]:::backend
        UserCtrl["User Controller"]:::backend
        ReviewCtrl["Review Controller"]:::backend
        NotificationCtrl["Notification Controller"]:::backend
        Models["Data Models"]:::backend
    end

    %% External Components
    Database["Database (MongoDB)"]:::database
    MapsAPI["Maps API"]:::external

    %% Relationships: Frontend to Backend
    UI_Components -->|"APIRequests"| ExpressServer
    Views -->|"APIRequests"| ExpressServer
    Layouts -->|"APIRequests"| ExpressServer
    Assets -->|"DeliversAssets"| UI_Components

    %% Relationships within Backend
    ExpressServer -->|"routes"| Routes
    ExpressServer -->|"auth"| Passport
    ExpressServer -->|"tokenGen"| SecretGen
    ExpressServer -->|"imageUpload"| CloudIntegration
    ExpressServer -->|"mapData"| MapsAPI

    Routes -->|"calls"| ListingCtrl
    Routes -->|"calls"| UserCtrl
    Routes -->|"calls"| ReviewCtrl
    Routes -->|"calls"| NotificationCtrl

    ListingCtrl -->|"CRUD"| Models
    UserCtrl -->|"CRUD"| Models
    ReviewCtrl -->|"CRUD"| Models
    NotificationCtrl -->|"CRUD"| Models

    %% Relationship: Backend Models to Database
    Models -->|"persists"| Database

    %% Additional Internal Relationships
    SecretGen -->|"utilizes"| SecretToken

    %% Click Events for Frontend Components
    click UI_Components "https://github.com/joel112003/wanderlust/tree/main/frontend/src/components"
    click Views "https://github.com/joel112003/wanderlust/tree/main/frontend/src/components/views"
    click Layouts "https://github.com/joel112003/wanderlust/tree/main/frontend/src/components/layouts"
    click Assets "https://github.com/joel112003/wanderlust/tree/main/frontend/public"
    click JS_Util "https://github.com/joel112003/wanderlust/tree/main/frontend/src/utilis/js"
    click CSS_Util "https://github.com/joel112003/wanderlust/tree/main/frontend/src/utilis/css"

    %% Click Events for Backend Components
    click ExpressServer "https://github.com/joel112003/wanderlust/blob/main/backend/app.js"
    click CloudIntegration "https://github.com/joel112003/wanderlust/blob/main/backend/cloudConfig.js"
    click Passport "https://github.com/joel112003/wanderlust/blob/main/backend/config/passport.js"
    click SecretGen "https://github.com/joel112003/wanderlust/blob/main/backend/config/secretGenerator.js"
    click SecretToken "https://github.com/joel112003/wanderlust/blob/main/backend/util/SecretToken.js"
    click ListingCtrl "https://github.com/joel112003/wanderlust/blob/main/backend/controllers/listing.js"
    click UserCtrl "https://github.com/joel112003/wanderlust/blob/main/backend/controllers/user.js"
    click ReviewCtrl "https://github.com/joel112003/wanderlust/blob/main/backend/controllers/review.js"
    click NotificationCtrl "https://github.com/joel112003/wanderlust/blob/main/backend/controllers/notification.js"
    click Routes "https://github.com/joel112003/wanderlust/tree/main/backend/routes"
    click Models "https://github.com/joel112003/wanderlust/tree/main/backend/models"

    %% Styles
    classDef frontend fill:#AEE1F9,stroke:#333,stroke-width:2px;
    classDef backend fill:#C1E1C1,stroke:#333,stroke-width:2px;
    classDef database fill:#F9E79F,stroke:#333,stroke-width:2px;
    classDef external fill:#fcd5ce,stroke:#333,stroke-width:2px;
```
