A full-stack wallet platform built using Next.js, Express, and MongoDB, designed to mimic Paytm-style wallet operations — user authentication, balance management, and secure wallet-to-wallet transfers.
This project demonstrates a production-grade monorepo architecture using Turborepo and PNPM workspaces, combining:
- A Next.js frontend for user interaction.
- An Express.js API for backend logic and data handling.
- Shared Mongoose models and configuration packages for scalability and reusability.
apps/
api/ → Express + TypeScript REST API
web/ → Next.js frontend (App Router)
packages/
db/ → Shared Mongoose models & MongoDB connection
ui/ → Shared React UI components
tailwind-config/ → Centralized TailwindCSS setup
eslint-config/ → Common ESLint configuration
typescript-config/ → Shared TS references
| Layer | Technologies |
|---|---|
| Frontend | Next.js 15 (App Router), React 19, TailwindCSS 4 |
| Backend | Express.js, TypeScript, JWT, bcrypt |
| Database | MongoDB, Mongoose, MongoDB Sessions (Transactions) |
| Tooling | Turborepo, PNPM Workspaces, ESLint, Prettier, TypeScript Project References |
-
🔐 User Authentication: Secure signup/signin using hashed passwords (
bcrypt) and JWT-based session management. -
💳 Wallet Management: Automatic wallet creation on signup; protected balance retrieval endpoint.
-
🔄 Atomic Transactions: Peer-to-peer wallet transfers implemented with MongoDB sessions ensuring atomic debit/credit operations.
-
🧩 Monorepo Modularity: Shared Mongoose models and configuration across multiple apps via PNPM workspaces.
-
🛠️ Developer Experience: Unified build, lint, and type-check scripts across all packages using Turborepo pipelines.
Base URL: http://localhost:4173
| Method | Endpoint | Description |
|---|---|---|
POST |
/signup |
Register new user and auto-create wallet |
POST |
/signin |
Authenticate user and return JWT |
GET |
/wallet |
Fetch wallet balance (JWT required) |
POST |
/transactions |
Perform atomic wallet-to-wallet transfer |
User Model
{
userName: string,
email: string,
password: string, // hashed with bcrypt
connections?: ObjectId[]
}Wallet Model
{
userId: ObjectId,
balance: number
}Transaction Model
{
fromUser: ObjectId,
toUser: ObjectId,
debit?: number,
credit?: number
}- User signs up with
username,email, andpassword. - Password is hashed with bcrypt before storing in MongoDB.
- On successful signin, a JWT token is issued.
- Token is validated in middleware before accessing protected routes like
/walletor/transactions.
POST /transactionsis called with{ from, to, amount }.- MongoDB session-based transaction begins.
- Balance is debited from sender’s wallet and credited to receiver’s wallet atomically.
- Any failure triggers rollback, ensuring data integrity.
- Node.js ≥ 18
- PNPM
- MongoDB (local or Atlas)
# Install dependencies
pnpm install
# Start API
pnpm --filter api dev
# Start Web
pnpm --filter web devDefault Ports:
- API →
4173 - Web →
4005
Create a .env file inside apps/api:
MONGODB_URI=mongodb://localhost:27017/paytm-wallet
JWT_SECRET=your_jwt_secret
PORT=4173
You can also use a cloud MongoDB URI (Atlas).
Root Scripts
pnpm dev # run all apps in parallel (turbo run dev)
pnpm build # build all packages
pnpm lint # lint all apps
pnpm check-types # type-check all projectsIndividual Apps
pnpm --filter api dev
pnpm --filter web devSignup
curl -X POST http://localhost:4173/signup \
-H "Content-Type: application/json" \
-d '{"username":"alice","email":"[email protected]","password":"pass"}'Signin
curl -X POST http://localhost:4173/signin \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","password":"pass"}'
# → { "token": "<JWT>" }Get Wallet Balance
curl http://localhost:4173/wallet \
-H "Authorization: <JWT>"Transfer Funds
curl -X POST http://localhost:4173/transactions \
-H "Content-Type: application/json" \
-d '{"from":"alice","to":"bob","amount":200}'- Add transaction history and audit logs
- Integrate input validation with Zod/Valibot
- Enhance frontend wallet dashboard and transfer UI
- Add Docker setup for containerized deployment
- Implement rate limiting and CORS
- Hands-on with Turborepo monorepo structure and shared configurations.
- Implemented atomic DB operations with MongoDB transactions.
- Gained deep understanding of secure authentication and route protection using JWT.
- Achieved code scalability through modular shared packages.