How neerjhar/app_builders-backend works
1. This repository is a backend-only Node.js service built around a single Express application entry point in backend/server.js. It exposes HTTP APIs for turf discovery and, according to the README, booking/payment support.
2. The core runtime boundary is:
- HTTP clients or a frontend app
- Express API server
- MongoDB via Mongoose
- Razorpay for payment orchestration
3. The main domain model lives in backend/models/Truf.js (note the filename typo). This is the Mongoose schema for turf records and is the persistence boundary between route handlers and the turffdata collection in MongoDB.
4. Turf discovery is implemented in backend/routes/turfRoutes.js. This route layer is responsible for:
- listing all turfs
- searching by query text
- nearby turf discovery using geospatial coordinates
5. The nearby-search path is an important architectural feature. Turf documents include a GeoJSON location field with [longitude, latitude], and the model creates a 2dsphere index so MongoDB can answer proximity queries efficiently.
6. backend/data/turfs.json is sample/fixture data, not the live source of truth. It likely supports seeding or local testing, while MongoDB remains the authoritative store for API reads.
7. The README describes booking/payment endpoints under /api/booking for Razorpay order creation and signature verification. Those routes are not present in the provided file tree, so for an architecture diagram they should be shown as either an omitted module or an adjacent payment subsystem, not as part of the visible core snapshot.
8. Environment and configuration are file-based through backend/.env and dotenv. The service expects at least:
- MONGO_URI for MongoDB connection
- PORT for the Express listener
- Razorpay API credentials for payment flows
9. MongoDB is used locally, with the README calling out the admin database and turffdata collection. This means the backend is stateful and depends on a running local database instance for all real turf data operations.
10. The principal request flow for turf discovery is:
client request → Express route handler → Mongoose query → MongoDB → JSON response. Search and nearby discovery are both read-heavy flows, with nearby search relying on geospatial index support.
11. The payment flow described in the README is separate from turf discovery:
client initiates booking → backend creates Razorpay order → browser completes payment → backend verifies signature. Razorpay is the external service boundary here.
12. Operationally, the repo is lightweight: there is no separate frontend, job worker, or microservice decomposition visible in the file tree. The architecture is a single-process API server with one database and one external payment provider.
Main entry points: server.js Express Server · turfRoutes.js Turf Routes · Truf.js Truf Model · .env Env Config
Components 11
Client/API
HTTP entrypoint and request handling boundary
- HTTP Client · Frontend app or API consumer issuing requests to the backend
- Express Server · Single Node.js entry point that mounts the HTTP API
backend/server.js - Turf Routes · Handles listing, search, and nearby turf discovery endpoints
backend/routes/turfRoutes.js - Booking API · README-described booking and payment endpoints; not present in the visible file tree
Domain/Data
Turf discovery logic and persistence model
- Truf Model · Mongoose schema for turf records, including GeoJSON location and geospatial indexing
backend/models/Truf.js - Mongoose · Query and schema layer between route handlers and MongoDB
Storage
MongoDB-backed data sources
- MongoDB · Stateful backing store for live turf data
- turffdata · MongoDB collection storing turf documents referenced by the model
- Sample Data · Local fixture or seed data for testing and bootstrapping
backend/data/turfs.json
External Services
Outside dependencies used by the backend
- Razorpay · External payment orchestration and signature verification service
Config
Environment and runtime configuration
- Env Config · Runtime configuration loaded from environment variables such as MongoDB, port, and Razorpay credentials
backend/.env
Connections 14
- HTTP Client → Express Server: HTTP requests · Clients send API calls to the Node/Express service
- Express Server → Turf Routes: mounts · Server delegates turf discovery endpoints to the route layer
- Express Server → Booking API: exposes · Server is expected to expose booking/payment endpoints described in the README
- Express Server → Env Config: reads config · Listener and database/payment settings come from environment variables
- Turf Routes → Mongoose: queries via · Route handlers use Mongoose to read turf records
- Booking API → Razorpay: creates/verifies · Booking flow orchestrates Razorpay order creation and signature verification
- Mongoose → Truf Model: uses schema · Mongoose operates through the turf schema definition
- Truf Model → MongoDB: persists to · The schema maps turf records into MongoDB
- MongoDB → turffdata: stores · Live turf documents reside in the turffdata collection
- Turf Routes → turffdata: reads turf data · Discovery endpoints ultimately resolve against the MongoDB collection
- Sample Data → MongoDB: seed source · Fixture data can bootstrap or test the live database
- Truf Model → Sample Data: matches shape · Fixture records reflect the modelled turf document structure
- Env Config → MongoDB: MONGO_URI · Database connection is configured from environment variables
- Env Config → Razorpay: API creds · Payment credentials are supplied through environment configuration