How darshan98solanki/paytm works
Project type and purpose
• This is a full-stack, single-page web application (“PayTM Clone”) that lets registered users sign up, receive demo money, search for other users, and transfer funds.
• Frontend: React.js (Vite + Tailwind).
• Backend: Node.js + Express.js, using JWT for auth and bcrypt for password hashing.
• Database: MongoDB.
• Hosted/deployed via Vercel (serverless).
a. Client / Browser (React SPA)
b. CDN / Edge (for serving static assets) – Vercel
c. API Layer – Express.js serverless functions (routes: /user, /account, /transaction)
d. Authentication Service – JWT issue/validation, bcrypt hashing
e. Database – MongoDB collections: Users, Transactions
f. External Payment Gateway (PayTM) – merchant API calls using merchant key & ID
g. DevOps / Deployment – Dockerfile (optional container), Vercel configuration
Relationships & data flow
• User opens the app in browser → requests index.html + JS/CSS from CDN/Edge.
• SPA boots and calls “/api/auth/signup” or “/api/auth/login” on the Express API → backend verifies credentials, uses bcrypt → issues JWT.
• Browser stores JWT (localStorage) → all subsequent API calls include JWT in Authorization header.
• For “Send Money”, SPA calls “/api/account/transfer” → backend middleware verifies JWT → backend writes Transaction record & updates User balances in MongoDB.
• Optionally backend calls external PayTM merchant API to simulate/validate payment.
• Responses flow back to SPA, which updates UI (Dashboard, Transactions, User Profile).
Architectural patterns & principles
• Separation of concerns:
• Frontend (UI layer) vs. Backend (API layer) vs. Database
• Backend uses MVC-style (routes/controllers, services, models in db.js/types.js)
• Stateless serverless functions on Vercel
• Secure by design: bcrypt for hashing, JWT for session, HTTPS assumed
• Modular code: routes under backend/routes, components under frontend/src/components