# vaibhavsanmani/gobnb-stayfinder architecture

> Architecture diagram of the GitHub repository vaibhavsanmani/gobnb-stayfinder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vaibhavsanmani/gobnb-stayfinder
- Repository: https://github.com/vaibhavsanmani/gobnb-stayfinder

## Overview

This is an Express/Mongoose listings marketplace with account authentication, listing creation and editing, image uploads, and listing reviews. The main workflow is a browser request entering the app’s mounted routes, passing route-level validation or login checks, reaching a controller, and reading or changing MongoDB-backed listing, review, or user records before returning a rendered response or redirect. The graph also shows the documented-by-code upload configuration and seed-data path. Some controllers and configuration were indexed but not excerpted, so their internal behavior is represented only where the source index supports a relationship.

Main entry points: [`app.js`](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/app.js) (Express app), [`routes/listing.js`](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/routes/listing.js) (Listing routes), [`routes/review.js`](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/routes/review.js) (Review routes), [`controllers/review.js`](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/controllers/review.js) (Review controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Web application"]
  node_app["Express app<br/>[app.js]"]
  node_validation["Request schemas<br/>[schema.js]"]
  node_async_helper["Async wrapper<br/>[wrapAsync.js]"]
end

subgraph group_listing["Listings"]
  node_listing_routes["Listing routes<br/>[listing.js]"]
  node_listing_controller["Listing controller<br/>[listings.js]"]
  node_listing_views["Listing views"]
end

subgraph group_accounts["Accounts and reviews"]
  node_auth_middleware["Login middleware<br/>[middleware.js]"]
  node_review_routes["Review routes<br/>[review.js]"]
  node_review_controller["Review controller<br/>[review.js]"]
  node_user_routes["User routes<br/>[user.js]"]
  node_user_controller["User controller<br/>[usesr.js]"]
end

subgraph group_data["Persistence and uploads"]
  node_listing_model["Listing model<br/>[listing.js]"]
  node_review_model["Review model<br/>[review.js]"]
  node_user_model["User model<br/>[user.js]"]
  node_mongo[("MongoDB")]
  node_cloud_config["Image storage config<br/>[cloudConfig.js]"]
  node_seed["Seed listings<br/>[data.js]"]
  node_seed_runner["Seed runner<br/>[index.js]"]
end

node_browser(("Browser user"))

node_browser -->|"sends requests"| node_app
node_app -->|"connects"| node_mongo
node_app -->|"mounts routes"| node_listing_routes
node_app -->|"mounts routes"| node_review_routes
node_app -->|"mounts routes"| node_user_routes
node_app -->|"configures views"| node_listing_views
node_listing_routes -->|"dispatches"| node_listing_controller
node_listing_routes -->|"validates with"| node_validation
node_listing_routes -->|"checks login"| node_auth_middleware
node_listing_routes -->|"configures upload"| node_cloud_config
node_listing_routes -->|"wraps handlers"| node_async_helper
node_listing_controller -->|"uses"| node_listing_model
node_review_routes -->|"dispatches"| node_review_controller
node_review_routes -->|"validates with"| node_validation
node_review_routes -->|"checks login"| node_auth_middleware
node_review_routes -->|"wraps handlers"| node_async_helper
node_review_controller -->|"reads and updates"| node_listing_model
node_review_controller -->|"creates and deletes"| node_review_model
node_user_routes -->|"dispatches"| node_user_controller
node_user_routes -->|"preserves redirect"| node_auth_middleware
node_user_controller -->|"uses"| node_user_model
node_seed_runner -->|"loads data"| node_seed
node_seed_runner -->|"creates records"| node_listing_model

click node_app "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/app.js"
click node_listing_routes "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/routes/listing.js"
click node_listing_controller "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/controllers/listings.js"
click node_listing_views "https://github.com/vaibhavsanmani/gobnb-stayfinder/tree/main/views/listings"
click node_validation "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/schema.js"
click node_auth_middleware "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/middleware.js"
click node_review_routes "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/routes/review.js"
click node_review_controller "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/controllers/review.js"
click node_user_routes "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/routes/user.js"
click node_user_controller "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/controllers/usesr.js"
click node_listing_model "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/models/listing.js"
click node_review_model "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/models/review.js"
click node_user_model "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/models/user.js"
click node_cloud_config "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/cloudConfig.js"
click node_seed "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/init/data.js"
click node_seed_runner "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/init/index.js"
click node_async_helper "https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/utils/wrapAsync.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_validation,node_async_helper,node_browser toneBlue
class node_listing_routes,node_listing_controller,node_listing_views toneAmber
class node_auth_middleware,node_review_routes,node_review_controller,node_user_routes,node_user_controller toneMint
class node_listing_model,node_review_model,node_user_model,node_mongo,node_cloud_config,node_seed,node_seed_runner toneRose
```

## Components

### Web application

- [Express app](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/app.js): `app.js`
- [Request schemas](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/schema.js): `schema.js`
- [Async wrapper](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/utils/wrapAsync.js): `utils/wrapAsync.js`

### Listings

- [Listing routes](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/routes/listing.js): `routes/listing.js`
- [Listing controller](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/controllers/listings.js): `controllers/listings.js`
- [Listing views](https://github.com/vaibhavsanmani/gobnb-stayfinder/tree/main/views/listings): `views/listings`

### Accounts and reviews

- [Login middleware](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/middleware.js): `middleware.js`
- [Review routes](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/routes/review.js): `routes/review.js`
- [Review controller](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/controllers/review.js): `controllers/review.js`
- [User routes](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/routes/user.js): `routes/user.js`
- [User controller](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/controllers/usesr.js): `controllers/usesr.js`

### Persistence and uploads

- [Listing model](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/models/listing.js): `models/listing.js`
- [Review model](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/models/review.js): `models/review.js`
- [User model](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/models/user.js): `models/user.js`
- **MongoDB**
- [Image storage config](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/cloudConfig.js): `cloudConfig.js`
- [Seed listings](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/init/data.js): `init/data.js`
- [Seed runner](https://github.com/vaibhavsanmani/gobnb-stayfinder/blob/main/init/index.js): `init/index.js`

### Other components

- **Browser user**

## Connections

- Browser user → Express app: sends requests
- Express app → MongoDB: connects (evidence: `app.js`)
- Express app → Listing routes: mounts routes (evidence: `app.js`)
- Express app → Review routes: mounts routes (evidence: `app.js`)
- Express app → User routes: mounts routes (evidence: `app.js`)
- Express app → Listing views: configures views (evidence: `app.js`)
- Listing routes → Listing controller: dispatches (evidence: `routes/listing.js`)
- Listing routes → Request schemas: validates with (evidence: `routes/listing.js`)
- Listing routes → Login middleware: checks login (evidence: `routes/listing.js`)
- Listing routes → Image storage config: configures upload (evidence: `routes/listing.js`)
- Listing routes → Async wrapper: wraps handlers (evidence: `routes/listing.js`)
- Listing controller → Listing model: uses (evidence: `controllers/listings.js`)
- Review routes → Review controller: dispatches (evidence: `routes/review.js`)
- Review routes → Request schemas: validates with (evidence: `routes/review.js`)
- Review routes → Login middleware: checks login (evidence: `routes/review.js`)
- Review routes → Async wrapper: wraps handlers (evidence: `routes/review.js`)
- Review controller → Listing model: reads and updates (evidence: `controllers/review.js`)
- Review controller → Review model: creates and deletes (evidence: `controllers/review.js`)
- User routes → User controller: dispatches (evidence: `routes/user.js`)
- User routes → Login middleware: preserves redirect (evidence: `routes/user.js`)
- User controller → User model: uses (evidence: `controllers/usesr.js`)
- Seed runner → Seed listings: loads data (evidence: `init/index.js`)
- Seed runner → Listing model: creates records (evidence: `init/index.js`)
