How vigneshdevhub/campx works
Main Components
a. Client-Side Layer:
• Static Assets (public folder)
• JavaScript modules
• CSS stylesheets
• Views (EJS templates)
• Layouts
• Partials
• User pages
• Campground pages
b. Server-Side Layer:
• Express.js Application (app.js)
• Route Handlers
• Controllers
• Middleware
• Authentication System
c. External Services:
• MongoDB Atlas (Database)
• Cloudinary (Media Storage)
• Mapbox (Maps Integration)
Component Relationships
• Client Browser → Express.js Server
• Express.js Server → Route Handlers
• Route Handlers → Controllers
• Controllers → Models
• Models → MongoDB Atlas
• Media Upload Flow → Cloudinary
• Location Services → Mapbox
Architectural Pattern Representation
The project follows an MVC (Model-View-Controller) pattern:
• Models: /models directory (campground.js, review.js, user.js)
• Views: /views directory (EJS templates)
• Controllers: /controllers directory (campgrounds.js, reviews.js, users.js)
[Client Browser]
• ↕
[Frontend Layer]
• Static Assets
• EJS Templates
• ↕
[Express.js Server]
• Routes
• Middleware
• Controllers
• ↕
[Business Logic Layer]
• Models
• Utils
• Schemas
• ↕
[External Services]
• MongoDB Atlas
• Cloudinary
• Mapbox
Important Flows to Highlight
a. Authentication Flow:
• User Registration/Login → Users Controller → User Model → MongoDB
b. Campground Operations:
• CRUD Operations → Campgrounds Controller → Campground Model → MongoDB
• Image Upload → Cloudinary Integration
• Location Data → Mapbox Integration
c. Review System:
• Review Creation → Reviews Controller → Review Model → MongoDB
Additional Elements
Supporting components:
• Error Handling (utils/ExpressError.js)
• Async Operations (utils/catchAsync.js)
• Data Validation (schemas.js)
• Security Middleware (middleware.js)