How arman-mishra562/internvault-backend works
Project Type and Purpose
• This is a standalone backend service (Node.js + Express) providing RESTful endpoints for Authentication, Application Management, Payment Processing, and Dynamic Pricing.
• It uses Prisma ORM to interact with a PostgreSQL database and integrates with SMTP (email), Stripe, PayPal, Google OAuth, and an IP geolocation API.
File Structure
• Entry point: src/app.ts
• Layered folders under src/:
• config/ (configuration of third-party clients: Prisma, Stripe, PayPal, Google, Mailer)
• middlewares/ (authentication, request validation)
• routes/ route definitions mapping URL paths to controllers
• controllers/ business-logic handlers for each feature domain
• schemas/ Zod validation schemas
• utils/ shared helper functions (token generation, email templates, geolocation)
• Prisma folder with schema and migrations for User, Application, Payment, PricingPlan models.
Pull Additional Insights from README
• JWT-based auth with email verification and Google OAuth
• Application lifecycle (statuses, payment tie-in)
• Atomic payments via Stripe/PayPal with webhooks
• Geo-based, currency-aware dynamic pricing
• Env variables define external endpoints, secrets, and DB connection.
Main Components and Their Interactions
A. Client (Web/Mobile Frontend)
• Sends HTTP requests (/api/auth, /api/applications, /api/pricing, etc.).
B. API Gateway (Express App)
• app.ts initializes Express, loads global middlewares (CORS, JSON parser).
• Mounts route groups under /api and /webhook.
C. Middleware Layer
• Authentication (JWT validation, auth.middleware)
• Request validation (Zod schemas via validateRequest)
D. Controller Layer
• auth.controller (register, login, verify email, password reset)
• application.controller (submit, list, status updates)
• payment.controller (initiate Stripe/PayPal payments)
• pricing.controller (CRUD pricing plans, carousel)
E. Service / Utils Layer
• Prisma client (DB access via config/prisma.ts)
• Email (Nodemailer via config/mailer.ts + utils/emailTemplates)
• Payment SDKs (Stripe, PayPal via config/stripe.ts & config/paypal.ts)
• Token generators and geolocation helpers in utils/
F. Database
• PostgreSQL (User, Application, Payment, PricingPlan)
G. External Services
• SMTP server (Gmail)
• Stripe & Google Pay via Stripe SDK
• PayPal REST API
• Google OAuth API
• IP geolocation API (ip-api.com)
• Webhook endpoints for asynchronous payment events
Architectural Patterns & Design Principles
• Layered Architecture (Routing → Middleware → Controllers → Data Access)
• Single-Responsibility Modules (each folder handles a distinct concern)
• Event-driven integration for payment webhooks
• Validation as a cross-cutting concern (Zod schemas + middleware)
• Configuration isolation (config/ folder for externals)
• ORM via Prisma (repository pattern)
• Clear component names (e.g., “auth.controller”, “Prisma Client”)
• Core backend layers
• Database
• External integrations
• Client boundary
• Optional: Deployment boundary (Docker container hosting the Express service, connected to a managed Postgres instance).