A complete backend API solution built with Express.js, PostgreSQL, and Prisma ORM.
- 🔐 Authentication - JWT-based authentication
- 💳 Payment Processing - Order and payment management
- 📱 QR Code Management - Create and manage QR codes
- 🎫 Support System - Ticket-based support system
- 🗄️ Database - PostgreSQL with Prisma ORM
- ✅ Validation - Zod schema validation
- 🔒 Security - Password hashing, CORS, rate limiting
- Framework: Express.js
- Database: PostgreSQL
- ORM: Prisma
- Authentication: JWT
- Validation: Zod
- Language: JavaScript
npm installCopy the environment file and configure your variables:
cp env.example .envUpdate the .env file with your configuration:
# Database
DATABASE_URL="postgresql://username:password@localhost:5432/plusfive_db"
# JWT
JWT_SECRET="your-jwt-secret-here"
# Server
PORT=3000
NODE_ENV="development"Generate Prisma client:
npm run db:generateRun database migrations:
npm run db:migrateSeed the database with sample data:
npm run db:seednpm run devThe API will be available at http://localhost:3000
- Project root me
vercel.jsonaurapi/index.jsalready configured hain. Vercel par naya Project banayein aur is repository ko connect karein. - Vercel Project Settings → Environment Variables me set karein:
DATABASE_URL(Vercel Postgres/Prisma integration se milne wala URL)JWT_SECRET- Optional:
.env.exampleme diye hue anya vars
- Database migrate/deploy:
- Production:
npx prisma migrate deploy - Ya non‑prod:
npx prisma db push
- Production:
- Deploy karein. Build ke dauran
prisma generatepostinstallse auto chalega.
POST /api/auth/register
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123",
"firstName": "John",
"lastName": "Doe",
"phoneNumber": "+1234567890",
"businessName": "My Business",
"businessType": "Technology",
"address": "123 Business St",
"whatsappNumber": "+1234567890",
"directChatMessage": "Hello! How can I help you?"
}
POST /api/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123"
}
GET /api/users/profile
Authorization: Bearer <token>
PUT /api/users/profile
Authorization: Bearer <token>
Content-Type: application/json
{
"firstName": "John",
"lastName": "Doe",
"phoneNumber": "+1234567890"
}
GET /api/orders?page=1&limit=10&status=completed
Authorization: Bearer <token>
POST /api/orders
Authorization: Bearer <token>
Content-Type: application/json
{
"amount": 99.99,
"currency": "USD",
"description": "Premium Plan",
"metadata": {}
}
GET /api/orders/{id}
Authorization: Bearer <token>
PUT /api/orders/{id}
Authorization: Bearer <token>
Content-Type: application/json
{
"status": "completed",
"description": "Updated description"
}
DELETE /api/orders/{id}
Authorization: Bearer <token>
GET /api/payments?page=1&limit=10&status=completed
Authorization: Bearer <token>
POST /api/payments
Authorization: Bearer <token>
Content-Type: application/json
{
"orderId": "order_id",
"amount": 99.99,
"currency": "USD",
"paymentMethod": "stripe",
"transactionId": "txn_123456"
}
GET /api/qr?page=1&limit=10&isActive=true
Authorization: Bearer <token>
POST /api/qr
Authorization: Bearer <token>
Content-Type: application/json
{
"name": "Business Card QR",
"url": "https://example.com/business-card",
"qrData": "https://example.com/business-card"
}
GET /api/qr/{id}
Authorization: Bearer <token>
PUT /api/qr/{id}
Authorization: Bearer <token>
Content-Type: application/json
{
"name": "Updated QR Name",
"isActive": false
}
DELETE /api/qr/{id}
Authorization: Bearer <token>
GET /api/support?page=1&limit=10&status=open&priority=high
Authorization: Bearer <token>
POST /api/support
Authorization: Bearer <token>
Content-Type: application/json
{
"subject": "Payment Issue",
"description": "I am having trouble with my payment.",
"priority": "high",
"category": "billing"
}
GET /api/support/{id}
Authorization: Bearer <token>
PUT /api/support/{id}
Authorization: Bearer <token>
Content-Type: application/json
{
"status": "in_progress",
"priority": "high"
}
DELETE /api/support/{id}
Authorization: Bearer <token>
- Basic user information
- Business details
- Authentication data
- Order management
- Payment tracking
- Status management
- Payment processing
- Transaction tracking
- Multiple payment methods
- QR code generation
- URL management
- Usage tracking
- Ticket management
- Priority levels
- Status tracking
# Development
npm run dev
# Production
npm start
# Database commands
npm run db:generate # Generate Prisma client
npm run db:migrate # Run migrations
npm run db:push # Push schema to database
npm run db:studio # Open Prisma Studio
npm run db:seed # Seed database| Variable | Description | Required |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Yes |
JWT_SECRET |
JWT signing secret | Yes |
PORT |
Server port | No (default: 3000) |
NODE_ENV |
Environment | No (default: development) |
The database seed creates a test user with the following credentials:
- Email: test@example.com
- Password: password123
- Password hashing with bcrypt
- JWT token authentication
- Input validation with Zod
- CORS configuration
- Rate limiting
- Helmet security headers
├── server.js # Main Express server
├── package.json # Dependencies and scripts
├── prisma/
│ ├── schema.prisma # Database schema
│ └── seed.js # Database seeding
├── lib/
│ ├── prisma.js # Prisma client
│ ├── utils.js # Utility functions
│ └── validations.js # Zod validation schemas
├── middleware/
│ ├── auth.js # JWT authentication
│ └── validation.js # Request validation
├── routes/
│ ├── auth.js # Authentication routes
│ ├── users.js # User routes
│ ├── orders.js # Order routes
│ ├── payments.js # Payment routes
│ ├── qr.js # QR code routes
│ └── support.js # Support ticket routes
└── README.md # Documentation
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License