# shashank-gautam007/airbnb architecture

> Architecture diagram of the GitHub repository shashank-gautam007/airbnb, 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/shashank-gautam007/airbnb
- Repository: https://github.com/shashank-gautam007/airbnb

## Overview

This is a server-rendered listings marketplace with user accounts, listing management, image uploads, geocoding, and reviews. The main workflow routes browser requests through authentication/validation and domain controllers, which read or mutate MongoDB-backed models and render listing pages. Signup/login and review creation are separate branches. The source excerpts show route ownership and key model calls; unsampled user-controller, cloud-storage, and initialization internals are represented only where the source index supports them.

Main entry points: [`app.js`](https://github.com/shashank-gautam007/airbnb/blob/main/app.js) (Express app), [`middleware.js`](https://github.com/shashank-gautam007/airbnb/blob/main/middleware.js) (Auth and validation), [`routes/listing.js`](https://github.com/shashank-gautam007/airbnb/blob/main/routes/listing.js) (Listing routes), [`models/listing.js`](https://github.com/shashank-gautam007/airbnb/blob/main/models/listing.js) (Listing model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Express app<br/>[app.js]"]
  node_listing_routes["Listing routes<br/>[listing.js]"]
  node_user_routes["User routes<br/>[user.js]"]
  node_middleware["Auth and validation<br/>[middleware.js]"]
  node_views["Listing views"]
  node_schema["Request schemas<br/>[schema.js]"]
  node_async_wrapper["Async wrapper<br/>[wrapAsync.js]"]
end

subgraph group_listings["Listings"]
  node_listing_controller["Listing controller<br/>[listings.js]"]
  node_listing_model["Listing model<br/>[listing.js]"]
  node_geocoder["Geocoder config<br/>[geocoder.js]"]
  node_cloud_config["Cloud storage config<br/>[cloudConfig.js]"]
  node_seed_data["Listing seed data<br/>[data.js]"]
  node_seed_runner["Seed initializer<br/>[index.js]"]
end

subgraph group_accounts["Accounts"]
  node_user_controller["User controller<br/>[users.js]"]
  node_user_model["User model<br/>[user.js]"]
  node_user_views["Account views"]
end

subgraph group_reviews["Reviews"]
  node_review_routes["Review routes<br/>[review.js]"]
  node_review_controller["Review controller<br/>[reviews.js]"]
  node_review_model["Review model<br/>[review.js]"]
  node_review_views["Review display<br/>[show.ejs]"]
end

node_visitor(("Visitor"))
node_database[("MongoDB")]

node_visitor -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_listing_routes
node_app -->|"mounts routes"| node_review_routes
node_app -->|"mounts routes"| node_user_routes
node_app -->|"configures sessions"| node_user_model
node_app -->|"connects"| node_database
node_listing_routes -->|"checks access"| node_middleware
node_listing_routes -->|"wraps handlers"| node_async_wrapper
node_listing_routes -->|"dispatches"| node_listing_controller
node_listing_routes -->|"configures uploads"| node_cloud_config
node_listing_controller -->|"queries and saves"| node_listing_model
node_listing_controller -->|"geocodes location"| node_geocoder
node_listing_controller -->|"renders pages"| node_views
node_middleware -->|"checks ownership"| node_listing_model
node_middleware -->|"checks authorship"| node_review_model
node_middleware -->|"validates input"| node_schema
node_seed_runner -->|"loads data"| node_seed_data
node_seed_runner -->|"creates listings"| node_listing_model
node_user_routes -->|"saves redirect"| node_middleware
node_user_routes -->|"dispatches"| node_user_controller
node_user_controller -->|"uses accounts"| node_user_model
node_user_controller -.->|"renders forms"| node_user_views
node_review_routes -->|"checks access"| node_middleware
node_review_routes -->|"wraps handlers"| node_async_wrapper
node_review_routes -->|"dispatches"| node_review_controller
node_review_controller -->|"updates listing"| node_listing_model
node_review_controller -->|"saves review"| node_review_model
node_review_controller -->|"redirects to listing"| node_review_views
node_listing_model -->|"deletes related reviews"| node_review_model

click node_app "https://github.com/shashank-gautam007/airbnb/blob/main/app.js"
click node_listing_routes "https://github.com/shashank-gautam007/airbnb/blob/main/routes/listing.js"
click node_user_routes "https://github.com/shashank-gautam007/airbnb/blob/main/routes/user.js"
click node_middleware "https://github.com/shashank-gautam007/airbnb/blob/main/middleware.js"
click node_views "https://github.com/shashank-gautam007/airbnb/tree/main/views/listings"
click node_listing_controller "https://github.com/shashank-gautam007/airbnb/blob/main/controllers/listings.js"
click node_listing_model "https://github.com/shashank-gautam007/airbnb/blob/main/models/listing.js"
click node_geocoder "https://github.com/shashank-gautam007/airbnb/blob/main/config/geocoder.js"
click node_cloud_config "https://github.com/shashank-gautam007/airbnb/blob/main/cloudConfig.js"
click node_seed_data "https://github.com/shashank-gautam007/airbnb/blob/main/init/data.js"
click node_seed_runner "https://github.com/shashank-gautam007/airbnb/blob/main/init/index.js"
click node_user_controller "https://github.com/shashank-gautam007/airbnb/blob/main/controllers/users.js"
click node_user_model "https://github.com/shashank-gautam007/airbnb/blob/main/models/user.js"
click node_user_views "https://github.com/shashank-gautam007/airbnb/tree/main/views/users"
click node_review_routes "https://github.com/shashank-gautam007/airbnb/blob/main/routes/review.js"
click node_review_controller "https://github.com/shashank-gautam007/airbnb/blob/main/controllers/reviews.js"
click node_review_model "https://github.com/shashank-gautam007/airbnb/blob/main/models/review.js"
click node_review_views "https://github.com/shashank-gautam007/airbnb/blob/main/views/listings/show.ejs"
click node_schema "https://github.com/shashank-gautam007/airbnb/blob/main/schema.js"
click node_async_wrapper "https://github.com/shashank-gautam007/airbnb/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_listing_routes,node_user_routes,node_middleware,node_views,node_schema,node_async_wrapper toneBlue
class node_listing_controller,node_listing_model,node_geocoder,node_cloud_config,node_seed_data,node_seed_runner,node_database toneAmber
class node_user_controller,node_user_model,node_user_views toneMint
class node_review_routes,node_review_controller,node_review_model,node_review_views toneRose
class node_visitor toneIndigo
```

## Components

### Web application

- [Express app](https://github.com/shashank-gautam007/airbnb/blob/main/app.js): `app.js`
- [Listing routes](https://github.com/shashank-gautam007/airbnb/blob/main/routes/listing.js): `routes/listing.js`
- [User routes](https://github.com/shashank-gautam007/airbnb/blob/main/routes/user.js): `routes/user.js`
- [Auth and validation](https://github.com/shashank-gautam007/airbnb/blob/main/middleware.js): `middleware.js`
- [Listing views](https://github.com/shashank-gautam007/airbnb/tree/main/views/listings): `views/listings`
- [Request schemas](https://github.com/shashank-gautam007/airbnb/blob/main/schema.js): `schema.js`
- [Async wrapper](https://github.com/shashank-gautam007/airbnb/blob/main/utils/wrapAsync.js): `utils/wrapAsync.js`

### Listings

- [Listing controller](https://github.com/shashank-gautam007/airbnb/blob/main/controllers/listings.js): `controllers/listings.js`
- [Listing model](https://github.com/shashank-gautam007/airbnb/blob/main/models/listing.js): `models/listing.js`
- [Geocoder config](https://github.com/shashank-gautam007/airbnb/blob/main/config/geocoder.js): `config/geocoder.js`
- [Cloud storage config](https://github.com/shashank-gautam007/airbnb/blob/main/cloudConfig.js): `cloudConfig.js`
- [Listing seed data](https://github.com/shashank-gautam007/airbnb/blob/main/init/data.js): `init/data.js`
- [Seed initializer](https://github.com/shashank-gautam007/airbnb/blob/main/init/index.js): `init/index.js`

### Accounts

- [User controller](https://github.com/shashank-gautam007/airbnb/blob/main/controllers/users.js): `controllers/users.js`
- [User model](https://github.com/shashank-gautam007/airbnb/blob/main/models/user.js): `models/user.js`
- [Account views](https://github.com/shashank-gautam007/airbnb/tree/main/views/users): `views/users`

### Reviews

- [Review routes](https://github.com/shashank-gautam007/airbnb/blob/main/routes/review.js): `routes/review.js`
- [Review controller](https://github.com/shashank-gautam007/airbnb/blob/main/controllers/reviews.js): `controllers/reviews.js`
- [Review model](https://github.com/shashank-gautam007/airbnb/blob/main/models/review.js): `models/review.js`
- [Review display](https://github.com/shashank-gautam007/airbnb/blob/main/views/listings/show.ejs): `views/listings/show.ejs`

### Other components

- **Visitor**
- **MongoDB**

## Connections

- Visitor → Express app: sends requests (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 → User model: configures sessions (evidence: `app.js`)
- Express app → MongoDB: connects (evidence: `app.js`)
- Listing routes → Auth and validation: checks access (evidence: `routes/listing.js`)
- Listing routes → Async wrapper: wraps handlers (evidence: `routes/listing.js`)
- Listing routes → Listing controller: dispatches (evidence: `routes/listing.js`)
- Listing routes → Cloud storage config: configures uploads (evidence: `routes/listing.js`)
- Listing controller → Listing model: queries and saves (evidence: `controllers/listings.js`)
- Listing controller → Geocoder config: geocodes location (evidence: `controllers/listings.js`)
- Listing controller → Listing views: renders pages (evidence: `controllers/listings.js`)
- Auth and validation → Listing model: checks ownership (evidence: `middleware.js`)
- Auth and validation → Review model: checks authorship (evidence: `middleware.js`)
- Auth and validation → Request schemas: validates input (evidence: `middleware.js`)
- Seed initializer → Listing seed data: loads data (evidence: `init/index.js`)
- Seed initializer → Listing model: creates listings (evidence: `init/index.js`)
- User routes → Auth and validation: saves redirect (evidence: `routes/user.js`)
- User routes → User controller: dispatches (evidence: `routes/user.js`)
- User controller → User model: uses accounts (evidence: `controllers/users.js`)
- User controller → Account views: renders forms
- Review routes → Auth and validation: checks access (evidence: `routes/review.js`)
- Review routes → Async wrapper: wraps handlers (evidence: `routes/review.js`)
- Review routes → Review controller: dispatches (evidence: `routes/review.js`)
- Review controller → Listing model: updates listing (evidence: `controllers/reviews.js`)
- Review controller → Review model: saves review (evidence: `controllers/reviews.js`)
- Review controller → Review display: redirects to listing (evidence: `controllers/reviews.js`)
- Listing model → Review model: deletes related reviews (evidence: `models/listing.js`)
