An Express + MongoDB MVC web app for creating car events, managing attendees, and tracking RSVP status.
- Node.js
- Express.js
- MongoDB + Mongoose
- EJS templating
- Express Session + Connect Mongo
- Multer (image upload)
- Express Validator
- Express Rate Limit
- Method Override
- Connect Flash
- User signup with validation
- User login/logout
- Password hashing using
bcryptjs - Session-based authentication with Mongo-backed session store
- Guest-only and logged-in-only route guards
- Create account with unique email check
- Login with email/password verification
- Profile page showing:
- Hosted events
- RSVPed events
- Create event (host must be logged in)
- Read all events and event details
- Update event (host only)
- Delete event (host only)
- Car category validation (enum-based)
- Date validation, including end date after start date
- Event image upload (
jpeg/png/gif, size limit)
- Logged-in users can RSVP to events with:
YESNOMAYBE- Host cannot RSVP to their own event
- RSVP is upserted (create if missing, update if existing)
- Event detail page shows count of
YESRSVPs
- Request payload validation and sanitization (
express-validator) - Mongo ObjectId validation middleware
- Login rate limiting (5 attempts per 2 minutes)
- Protected routes for auth and host authorization
- Flash messages for success/error states
- 404 error handler for unknown routes
- 500 error handler for server errors
GET /Home pageGET /aboutAbout pageGET /contactContact page
GET /users/newSignup form (guest only)POST /usersCreate accountGET /users/loginLogin form (guest only)POST /users/loginAuthenticate user (rate-limited)GET /users/profileUser profile (logged in)GET /users/logoutLogout user
GET /eventsList all eventsGET /events/newNew event form (logged in)POST /eventsCreate event (logged in, validated, image upload)GET /events/:idEvent detailGET /events/:id/editEdit form (host only)PUT /events/:idUpdate event (host only)DELETE /events/:idDelete event (host only)POST /events/rsvp/:idRSVP to event (logged in)
firstNamelastNameemail(unique)password(hashed before save)
category(enum)titlehost(User reference)imagedetailslocationstartDateendDate
user(User reference)event(Event reference)status(YES | NO | MAYBE)
app.jsApp setup, DB connection, session config, middleware mount, route mountcontrollers/Business logic for main, user, and event flowsroutes/Route definitionsmodels/Mongoose schemasmiddleware/Auth, validators, upload, and rate limitingviews/EJS templatespublic/Static assets (CSS/images)
- Install dependencies:
npm install- Configure MongoDB connection:
- Current code uses a hardcoded Mongo URI in
app.js. - Recommended: move URI to environment variable (
MONGO_URI) and load it from code.
This project uses a MongoDB Atlas style connection string (mongodb+srv) for both:
- Mongoose DB connection
- Session store (
connect-mongo)
Current location in code:
app.js(const mongUri = "...")app.js(store: new MongoStore({ mongoUrl: "..." }))
Atlas format:
mongodb+srv://<username>:<password>@<cluster-host>/<database>?retryWrites=true&w=majority
Example:
mongodb+srv://myUser:myPass@cluster0.xxxxx.mongodb.net/car_community?retryWrites=true&w=majority
Local MongoDB format:
mongodb://127.0.0.1:27017/car_community
Important notes:
- If Atlas cluster is paused/deleted, app startup will fail with DNS/connection errors.
- Ensure your Atlas IP access list allows your current machine IP.
- Ensure the DB user credentials in the string are valid.
- If password has special characters (like
@,#,%), URL-encode it.
- Start the app:
node app.jsOptional (development):
npx nodemon app.js- Open in browser:
http://localhost:3000
package.jsoncurrently does not definestartordevscripts.- If
npm run devfails, runnode app.jsdirectly. - RSVP values are strictly validated as uppercase
YES,NO, orMAYBE.