How tashdik-29/shopninja-server works
1. Repository shape
- This is a small Node.js backend service, not a multi-package or microservice system.
- The top level contains only index.js, package.json, package-lock.json, vercel.json, and the README, which suggests a single deployable API entrypoint with minimal internal file structure exposed in this snapshot.
2. Core runtime
- The application runs on Node.js with Express.js as the HTTP server layer.
- index.js is the main bootstrap file and is likely responsible for creating the server, registering middleware, and wiring API routes.
3. Primary domain
- The domain is a delivery management system called ShopNinja.
- The system centers on parcel booking, approval, assignment, tracking, and delivery-status updates.
4. User roles and boundaries
- There are three functional actors:
- User: books parcels and tracks delivery progress.
- Admin: approves bookings, views all parcels, and assigns parcels to delivery personnel.
- Deliveryman: receives assigned parcels and updates delivery status.
- These roles define the main authorization boundaries in the architecture.
5. API security and identity
- The backend uses JWT to secure API access and enforce role-based behavior.
- The README also states Firebase is used for authentication, so authentication appears split between Firebase sign-in/sign-up and JWT-based authorization for protected API operations.
- In architecture terms, Firebase is the identity provider, while JWT is the session/access-control mechanism for the backend.
6. Data layer
- MongoDB is the persistent datastore.
- It likely stores user profiles, parcel bookings, approval state, assignment state, and delivery history.
- The data model is probably centered on parcel lifecycle records rather than isolated feature-specific services.
7. Parcel lifecycle flow
- The main business flow is:
- User creates a parcel booking.
- Booking enters a pending state.
- Admin reviews and approves it.
- Admin assigns it to a deliveryman.
- Deliveryman updates delivery progress and final delivery status.
- User can view status updates and history.
- This is the central data flow for the whole system.
8. Operational dashboards
- The README describes separate dashboards for admin, user, and deliveryman, which implies role-specific API endpoints and views on the client side.
- The backend serves these dashboards by exposing different parcel queries and mutations depending on role and authorization level.
9. Deployment / hosting
- vercel.json indicates the service is configured for Vercel deployment.
- That suggests the backend may be deployed as a serverless/edge-friendly Node application or a Vercel-hosted API, rather than a traditional long-running VM service.
10. External integrations
- The README mentions a Stripe Secret Key in environment setup, implying payment-related capabilities or future payment integration, even though payment flow is not described in detail.
- The key external services affecting architecture are therefore:
- MongoDB for persistence
- Firebase for authentication
- JWT for API authorization
- Stripe for payment-related integration
11. Architectural summary
- Overall, the repo appears to implement a single-service monolithic API with a simple server entrypoint, external auth, MongoDB persistence, and role-based parcel workflows.
- The important diagram boundaries are: client dashboards on one side, the Express API in the middle, and MongoDB/Firebase/Stripe as external dependencies on the other side.
Main entry points: index.js index.js · vercel.json Vercel
Components 14
API Service
Single Node.js backend entrypoint and request handling layer
- index.js · Main server bootstrap and wiring file
index.js - Express API · HTTP application layer and route registration
- JWT Guard · Protects API access and enforces session-based authorization
- Role Routes · Separates user, admin, and deliveryman operations
Parcel Domain
Role-based delivery workflow and business operations
- User API · Booking and tracking actions for parcel owners
- Admin API · Reviews bookings, assigns parcels, and oversees all parcels
- Delivery API · Updates delivery progress and completion status
- Parcel Flow · Core booking-to-delivery lifecycle state machine
- Tracking Data · Parcel status history and user-visible progress views
External Systems
Identity, persistence, payment, and hosting dependencies
- MongoDB · Stores users, parcels, assignments, and delivery records
- Firebase · Authentication source for sign-in and sign-up
- Stripe · Payment-related external service referenced by environment setup
- Vercel · Serverless hosting and deployment configuration target
vercel.json
Other components
- Dashboards · User, admin, and deliveryman dashboard clients that consume the API
Connections 18
- index.js → Express API: boots · Creates and configures the HTTP app
- index.js → JWT Guard: registers · Adds authorization layer to protected routes
- index.js → Role Routes: mounts · Attaches API route groups
- Express API → Vercel: deploys on · Runs as a Vercel-hosted Node service
- Dashboards → Role Routes: calls · Dashboard clients invoke the role-specific API
- Role Routes → User API: exposes · User-facing booking and tracking endpoints
- Role Routes → Admin API: exposes · Admin approval and assignment endpoints
- Role Routes → Delivery API: exposes · Delivery status update endpoints
- JWT Guard → Firebase: verifies identity · Authentication begins with Firebase-backed identity
- JWT Guard → Role Routes: authorizes · Checks JWT claims and role access
- User API → Parcel Flow: creates · User booking initiates parcel lifecycle
- Admin API → Parcel Flow: approves/assigns · Admin advances parcels through workflow
- Delivery API → Parcel Flow: updates · Deliveryman changes parcel delivery state
- Parcel Flow → Tracking Data: records · Lifecycle changes feed tracking history
- User API → MongoDB: reads/writes · Persists bookings and retrieves status
- Admin API → MongoDB: reads/writes · Stores approvals, assignments, and parcel views
- Delivery API → MongoDB: reads/writes · Stores delivery progress and completion updates
- Role Routes → Stripe: integrates · Potential payment integration point