How aswin-cs/safaiwatch-backend works
This is a backend for a community cleanup and rewards platform. Users authenticate, report or mark cleanup spots, and the service tracks assignment and completion; profiles, feeds, and rewards provide supporting features. The graph separates API routing, domain controllers, persistence, and integrations. The excerpts show selected controller behavior and app routing; several subsystems are represented from the source index and tree, so uncertain internal links are omitted.
Main entry points: spots.controller.js Cleanup spots · profile.controller.js Profile management · authorize.middleware.js Authorization · app.js Express app
Components 26
API and access
- Express app
src/app.js - Auth routes
src/routes/auth.routes.js - Profile routes
src/routes/profile.routes.js - Spot routes
src/routes/spots.routes.js - Feed routes
src/routes/feeds.routes.js - Reward routes
src/routes/rewards.routes.js - Authorization
src/middlewares/authorize.middleware.js
Product workflows
- Authentication
src/controllers/auth.controller.js - Profile management
src/controllers/profile.controller.js - Cleanup spots
src/controllers/spots.controller.js - Community feeds
src/controllers/feeds.controller.js - Rewards and rankings
src/controllers/rewards.controller.js
Domain data
- User records
models/user.model.js - User activity
models/userStatus.model.js - Spot records
models/markedSpots.model.js - Reward records
models/userRewards.model.js - Feed records
models/feeds.model.js - OTP records
models/sample.modal.js - One-time codes
models/one-time.model.js
Integrations
- Cloudinary media
utils/Cloudinaryimage.utils.js - Photo verification
utils/aiPhotoVerification.utils.js - Reward calculations
utils/rewards.utils.js - Socket.IO events
config/socketIoConfig.js - Response formatting
utils/responseHandler.js - Error handling
utils/errorHandler.js
Other components
- API clients
Connections 37
- API clients → Express app: send requests
src/app.js - Express app → Auth routes: mounts
src/app.js - Express app → Profile routes: mounts
src/app.js - Express app → Spot routes: mounts
src/app.js - Express app → Feed routes: mounts
src/app.js - Express app → Reward routes: mounts
src/app.js - Auth routes → Authentication: routes to
src/routes/auth.routes.js - Profile routes → Profile management: routes to
src/routes/profile.routes.js - Spot routes → Cleanup spots: routes to
src/routes/spots.routes.js - Feed routes → Community feeds: routes to
src/routes/feeds.routes.js - Reward routes → Rewards and rankings: routes to
src/routes/rewards.routes.js - Auth routes → Authorization: applies access
src/routes/auth.routes.js - Profile routes → Authorization: applies access
src/routes/profile.routes.js - Spot routes → Authorization: applies access
src/routes/spots.routes.js - Feed routes → Authorization: applies access
src/routes/feeds.routes.js - Reward routes → Authorization: applies access
src/routes/rewards.routes.js - Authentication → User records: reads and writes
src/controllers/auth.controller.js - Authentication → OTP records: reads and writes
src/controllers/auth.controller.js - Authorization → User records: loads user
src/middlewares/authorize.middleware.js - Authorization → OTP records: loads OTP
src/middlewares/authorize.middleware.js - Profile management → User records: reads profile
src/controllers/profile.controller.js - Profile management → User activity: reads activity
src/controllers/profile.controller.js - Profile management → Spot records: reads spots
src/controllers/profile.controller.js - Profile management → Reward records: reads rewards
src/controllers/profile.controller.js - Profile management → Feed records: reads posts
src/controllers/profile.controller.js - Profile management → Cloudinary media: uploads media
src/controllers/profile.controller.js - Cleanup spots → Spot records: manages spots
src/controllers/spots.controller.js - Cleanup spots → Cloudinary media: uploads media
src/controllers/spots.controller.js - Cleanup spots → Photo verification: verifies photos
src/controllers/spots.controller.js - Cleanup spots → Socket.IO events: emits events
src/controllers/spots.controller.js - Cleanup spots → Reward calculations: calculates rewards
src/controllers/spots.controller.js - Cleanup spots → One-time codes: uses codes
src/controllers/spots.controller.js - Community feeds → Feed records: manages posts
src/controllers/feeds.controller.js - Rewards and rankings → Reward records: manages rewards
src/controllers/rewards.controller.js - Rewards and rankings → Reward calculations: calculates rewards
src/controllers/rewards.controller.js - Cleanup spots → Response formatting: formats responses
src/controllers/spots.controller.js - Cleanup spots → Error handling: creates errors
src/controllers/spots.controller.js