# wootwoot1234/superhost-tools architecture

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

- Interactive diagram: https://gitdiagram.com/wootwoot1234/superhost-tools
- Repository: https://github.com/wootwoot1234/superhost-tools

## Overview

##### Project type and purpose
- This is a full-stack Node.js application (Express) with a static‐file frontend.
- Purpose: an open-source Airbnb auto-messaging and dynamic pricing tool for hosts.

##### File structure
Top-level artifacts
- app.js, routes.js – entry point and Express routing
- package.json, bower.json, .bowerrc, Makefile – build, dependency management
- README.md, LICENSE – project documentation and license
Backend folders
- email/ – templates (EJS), mailing logic, Mailgun config
- models/ – Mongoose models for users, accounts, listings, rules, messages, pricing
- routes/ – route handlers, index.js routes mapped in routes.js
Frontend (public/)
- public/pages – public user pages (login, register)
- public/admin – admin UI, CSS/JS, SB-Admin 2 theme, HTML modals and pages
- public/js/index.js – client-side logic for public UI
Views
- views/*.html – server-rendered views (login landing, admin wrapper)
Other
- test/ – basic unit tests for user logic
- app.json – Heroku config

##### README for additional insights
- Tech stack: Node, Express, MongoDB, Bower, Mailgun, UptimeRobot for cron
- Runtime: deployed on Heroku, ping two endpoints (/checkRules, /updatePricing) every 15 min
- Core functionality:
- Automated guest messaging (pre-check-in, post-check-out, upon booking)
- Automatic review posting
- Pricing engine layered on Airbnb Smart Pricing

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    Clients["Client Browsers (Hosts)"]:::external
    Clients -->|"HTTP(S)"| StaticServer
    Clients -->|"HTTP(S)"| ExpressApp

    %% Static Files Layer
    subgraph "Static Web Server"
      direction TB
      StaticServer["Static Web Server"]:::internal
      subgraph "Static Files" 
        direction TB
        JS["public/js/index.js"]:::static
        click JS "https://github.com/wootwoot1234/superhost-tools/blob/master/public/js/index.js"
        PLogin["public/pages/login.html"]:::static
        click PLogin "https://github.com/wootwoot1234/superhost-tools/blob/master/public/pages/login.html"
        PRegister["public/pages/register.html"]:::static
        click PRegister "https://github.com/wootwoot1234/superhost-tools/blob/master/public/pages/register.html"
        AdminCSS["public/admin/css/styles.css"]:::static
        click AdminCSS "https://github.com/wootwoot1234/superhost-tools/blob/master/public/admin/css/styles.css"
        AdminJS["public/admin/js/admin.js"]:::static
        click AdminJS "https://github.com/wootwoot1234/superhost-tools/blob/master/public/admin/js/admin.js"
        AdminDash["public/admin/pages/dashboard.html"]:::static
        click AdminDash "https://github.com/wootwoot1234/superhost-tools/blob/master/public/admin/pages/dashboard.html"
        AdminPages["public/admin/pages/*.html"]:::static
        click AdminPages "https://github.com/wootwoot1234/superhost-tools/tree/master/public/admin/pages/"
        SBAdmin["public/admin/sb-admin-2"]:::static
        click SBAdmin "https://github.com/wootwoot1234/superhost-tools/tree/master/public/admin/sb-admin-2"
      end
      StaticServer --> StaticFiles
    end

    %% Express Application
    subgraph "Express Application" 
      direction TB
      AppEntry["app.js"]:::internal
      click AppEntry "https://github.com/wootwoot1234/superhost-tools/blob/master/app.js"
      RoutesConfig["routes.js"]:::internal
      click RoutesConfig "https://github.com/wootwoot1234/superhost-tools/blob/master/routes.js"

      subgraph "Route Handlers"
        direction TB
        IndexRoutes["routes/index.js"]:::internal
        click IndexRoutes "https://github.com/wootwoot1234/superhost-tools/blob/master/routes/index.js"
      end

      subgraph "Models (Mongoose)"
        direction TB
        UserModel["models/user.js"]:::internal
        click UserModel "https://github.com/wootwoot1234/superhost-tools/blob/master/models/user.js"
        AccountModel["models/user.account.js"]:::internal
        click AccountModel "https://github.com/wootwoot1234/superhost-tools/blob/master/models/user.account.js"
        ListingModel["models/user.account.listing.js"]:::internal
        click ListingModel "https://github.com/wootwoot1234/superhost-tools/blob/master/models/user.account.listing.js"
        ReservationModel["models/user.account.reservation.js"]:::internal
        click ReservationModel "https://github.com/wootwoot1234/superhost-tools/blob/master/models/user.account.reservation.js"
        MessageModel["models/user.account.listing.message.js"]:::internal
        click MessageModel "https://github.com/wootwoot1234/superhost-tools/blob/master/models/user.account.listing.message.js"
        MessageRuleModel["models/user.account.listing.messageRule.js"]:::internal
        click MessageRuleModel "https://github.com/wootwoot1234/superhost-tools/blob/master/models/user.account.listing.messageRule.js"
        PriceModel["models/user.account.listing.price.js"]:::internal
        click PriceModel "https://github.com/wootwoot1234/superhost-tools/blob/master/models/user.account.listing.price.js"
        PriceRuleModel["models/user.account.listing.priceRule.js"]:::internal
        click PriceRuleModel "https://github.com/wootwoot1234/superhost-tools/blob/master/models/user.account.listing.priceRule.js"
      end

      subgraph "Email Module"
        direction TB
        EmailConfig["email/config.js"]:::internal
        click EmailConfig "https://github.com/wootwoot1234/superhost-tools/blob/master/email/config.js"
        EmailLogic["email/email.js"]:::internal
        click EmailLogic "https://github.com/wootwoot1234/superhost-tools/blob/master/email/email.js"
        FooterTpl["email/footer.ejs"]:::internal
        click FooterTpl "https://github.com/wootwoot1234/superhost-tools/blob/master/email/footer.ejs"
        HeaderTpl["email/header.ejs"]:::internal
        click HeaderTpl "https://github.com/wootwoot1234/superhost-tools/blob/master/email/header.ejs"
        MsgHTML["email/message/html.ejs"]:::internal
        click MsgHTML "https://github.com/wootwoot1234/superhost-tools/blob/master/email/message/html.ejs"
        MsgText["email/message/text.ejs"]:::internal
        click MsgText "https://github.com/wootwoot1234/superhost-tools/blob/master/email/message/text.ejs"
        StdHTML["email/standard/html.ejs"]:::internal
        click StdHTML "https://github.com/wootwoot1234/superhost-tools/blob/master/email/standard/html.ejs"
        StdText["email/standard/text.ejs"]:::internal
        click StdText "https://github.com/wootwoot1234/superhost-tools/blob/master/email/standard/text.ejs"
      end

      subgraph "Views"
        direction TB
        ViewIndex["views/index.html"]:::internal
        click ViewIndex "https://github.com/wootwoot1234/superhost-tools/blob/master/views/index.html"
        ViewAdmin["views/admin.html"]:::internal
        click ViewAdmin "https://github.com/wootwoot1234/superhost-tools/blob/master/views/admin.html"
      end

      subgraph "Build & Config"
        direction TB
        Package["package.json"]:::internal
        click Package "https://github.com/wootwoot1234/superhost-tools/blob/master/package.json"
        Bower["bower.json"]:::internal
        click Bower "https://github.com/wootwoot1234/superhost-tools/blob/master/bower.json"
        Bowerrc[".bowerrc"]:::internal
        click Bowerrc "https://github.com/wootwoot1234/superhost-tools/blob/master/.bowerrc"
        Makefile["Makefile"]:::internal
        click Makefile "https://github.com/wootwoot1234/superhost-tools/tree/master/Makefile"
        AppJson["app.json"]:::internal
        click AppJson "https://github.com/wootwoot1234/superhost-tools/blob/master/app.json"
      end

      subgraph "Tests"
        direction TB
        TestUser["test/test.user.js"]:::internal
        click TestUser "https://github.com/wootwoot1234/superhost-tools/blob/master/test/test.user.js"
      end

      AppEntry --> RoutesConfig
      RoutesConfig --> IndexRoutes
      IndexRoutes --> ModelsLayer["Models (Mongoose)"]
      IndexRoutes --> EmailModule["Email Module"]
      AppEntry --> Views
      AppEntry --> Build & Config
      AppEntry --> Tests
      StaticServer --> ExpressApp
    end

    %% Database and External Services
    MongoDB["MongoDB Atlas"]:::db
    ExpressApp -->|"queries/updates"| MongoDB

    Mailgun["Mailgun API"]:::external
    ExpressApp -->|"send emails"| Mailgun

    AirbnbAPI["Airbnb API"]:::external
    ExpressApp -->|"pricing/reviews/messaging"| AirbnbAPI

    %% Scheduler Trigger
    Uptime["UptimeRobot"]:::external
    Uptime -->|"cron ping /checkRules"| IndexRoutes
    Uptime -->|"cron ping /updatePricing"| IndexRoutes

    %% Styles
    classDef internal fill:#D0E6FF,stroke:#333,stroke-width:1px
    classDef static fill:#E6FFE6,stroke:#333,stroke-width:1px
    classDef external fill:#FFD6D6,stroke:#333,stroke-width:1px
    classDef db fill:#D0FFD6,stroke:#333,stroke-width:1px
    classDef scheduled fill:#FFE6CC,stroke:#333,stroke-width:1px
```
