A secure digital wallet API built with Node.js, Express, and PostgreSQL. Wallety enables users to manage their wallets, transfer funds, and handle payment requests.
- User authentication with JWT
- Wallet management with transaction history
- Fund deposits and transfers between users
- Payment request system (create, accept, reject)
- Comprehensive API documentation with Swagger
- PostgreSQL database with Prisma ORM
- Docker support for easy deployment
- Runtime: Node.js with TypeScript
- Framework: Express.js
- Database: PostgreSQL
- ORM: Prisma
- Authentication: JWT with bcryptjs
- Validation: Zod
- Documentation: Swagger (swagger-jsdoc + swagger-ui-express)
- Containerization: Docker & Docker Compose
- Node.js (v16 or higher)
- PostgreSQL (v15)
- Docker and Docker Compose (optional)
- Clone the repository:
git clone <repository-url>
cd Wallety- Install dependencies:
npm install- Set up environment variables:
Create a
.envfile in the root directory:
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/fintech_wallet_db"
JWT_SECRET=your_jwt_secret_here
PORT=3000
NODE_ENV=development- Start PostgreSQL using Docker:
docker-compose up -d- Run database migrations:
npx prisma migrate deploy- Start the development server:
npm run devThe API will be available at http://localhost:3000
Once the server is running, access the Swagger documentation at:
http://localhost:3000/api-docs
POST /api/auth/register- Register a new userPOST /api/auth/login- Login and receive JWT token
POST /api/wallet/deposit- Deposit funds to your walletPOST /api/wallet/transfer- Transfer funds to another userGET /api/wallet/history- Get paginated transaction history
POST /api/request/request- Create a payment requestGET /api/request/incoming- Get all incoming payment requestsPATCH /api/request/:id/reject- Reject a payment requestPATCH /api/request/:id/pay- Accept and pay a payment request
All endpoints except authentication require a Bearer token in the Authorization header.
npm run dev # Start development server with nodemon
npm run build # Compile TypeScript to JavaScript
npm start # Run production server
npm run lint # Run ESLint
npm run lint:fix # Fix ESLint issues
npm run format # Format code with PrettierThe application uses four main models:
- User: Stores user credentials and profile
- Wallet: Manages user balance and currency
- Transaction: Records all deposits and transfers
- Request: Handles payment requests between users
Build and run with Docker:
# Build the image
docker build -t wallety-api .
# Run the container
docker run -p 3000:3000 --env-file .env wallety-apiOr use Docker Compose for the full stack:
docker-compose upsrc/
├── @types/ # TypeScript type definitions
├── config/ # Configuration files (Swagger, etc.)
├── lib/ # Database client initialization
├── middleware/ # Auth, validation, error handling
├── modules/ # Feature modules (auth, wallet, payment-request)
│ ├── auth/
│ ├── wallet/
│ └── payment-request/
├── utils/ # Helper functions
├── app.ts # Express app setup
└── server.ts # Server entry point
- Passwords are hashed using bcrypt
- JWT tokens for authentication
- Helmet.js for HTTP headers security
- Input validation with Zod schemas
- Prepared statements via Prisma (SQL injection prevention)
ISC