0% found this document useful (0 votes)
8 views8 pages

SystemDesign Document

This is for My Interview Research

Uploaded by

Vikash Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ZIP, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views8 pages

SystemDesign Document

This is for My Interview Research

Uploaded by

Vikash Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ZIP, PDF, TXT or read online on Scribd
You are on page 1/ 8

Designing an Online Ticket Booking Application involves breaking the

system into manageable components, addressing both functional and non-


functional requirements. Here's a high-level system design approach:

🎯 1. Requirements Gathering

✅ Functional Requirements

User registration and authentication

Search for events/movies/trains/flights

Select and book available seats

Payment integration

Booking confirmation with email/SMS

Booking cancellation and refund

Admin interface to manage events/seats/schedules

⚙️Non-Functional Requirements

Scalability

High availability

Security (especially for payment and personal data)

Performance (fast response time for seat selection and booking)

Consistency (prevent double-booking)

🧱 2. System Architecture

A layered architecture or microservices design works well.

🔹 Frontend

Web app (React, Angular)

Mobile app (iOS/Android)

🔹 Backend (APIs / Services)


User Service

Event/Schedule Service

Seat Management Service

Booking Service

Payment Service

Notification Service

Admin Service

🔹 Databases

Relational DB (PostgreSQL/MySQL) for structured data

NoSQL (Redis/MongoDB) for caching and logs

Message queue (Kafka/RabbitMQ) for async processing (e.g., notifications)

3. Key Components and Design Details

🔸 User Management

Registration, login (JWT-based auth), roles (user/admin)

OAuth for social login

🔸 Event/Schedule Service

Store data like movies/events/trains with showtimes and location

Supports filtering and searching

🔸 Seat Management

Stores seat layout

Shows real-time availability

Implements locking mechanism during booking to avoid race conditions

🔸 Booking Workflow
1. User selects event & time

2. System locks selected seats (temporary hold for 5 mins)

3. User proceeds with payment

4. On payment success:

Seats marked as booked

Confirmation generated

Notification sent

5. On failure or timeout, seats are released

🔸 Payment Integration

Use third-party gateway (e.g., Stripe, Razorpay, PayPal)

Secure card storage (PCI compliance)

🔸 Notification Service

Sends email/SMS on successful booking/cancellation

Uses messaging queue for async processing

💡 4. Tech Stack Suggestion

🧠 5. Cons
derations

Concurrency: Optimistic or pessimistic locking to prevent double-booking

Caching: Use Redis for frequent queries like showtimes or seat availability

Analytics: For popular events, demand forecasting

Auditing: Keep track of all transactions

Designing an Online Payment System like PhonePe, Google Pay, or Paytm


involves high levels of security, fault tolerance, and scalability. These
platforms handle millions of transactions daily, integrate with banks,
support UPI (Unified Payments Interface), wallets, credit/debit cards, and
provide bill payments, recharges, and P2P transfers.

Here's a comprehensive breakdown of the PhonePe-like Payment System


Design:

🧱 1. High-Level Components

🔹 User Layer
Mobile app or web interface

User registration & KYC (Know Your Customer)

Payment options UI: UPI, wallet, card, bank account

🔹 Application Layer (Microservices)

User Service: Registration, authentication, KYC

Wallet Service: In-app balance, top-up, deductions

Payment Gateway: Routes transactions to UPI, banks, cards

Transaction Service: P2P, P2M (peer-to-merchant), bill payments

UPI Service: Integration with NPCI

Banking Integration Service: API bridge to banks

Notification Service: SMS/email/push notifications


Analytics & Risk Engine: Fraud detection, pattern analysis

Ledger Service: Immutable transactional log

🔹 Database Layer

SQL (PostgreSQL/MySQL): Structured transactional data

NoSQL (MongoDB/Redis): Fast reads, caching, session info

Blockchain-style ledger (append-only, tamper-proof)

🔐 2. Security Architecture


🔁 3. UPI Flow (

PCI Integration)
UPI (in India) involves NPCI as the switch. PhonePe acts as a Payment Service
Provider (PSP).

Typical UPI Flow:

1. User initiates a transfer (via VPA like name@upi)

2. App sends transaction to NPCI via UPI API

3. NPCI validates and routes it to the remitter’s bank

4. Bank processes debit, sends response to NPCI

5. NPCI credits to the beneficiary's bank

6. Response is sent back to PhonePe


All these steps must happen in real-time, securely, and with transactional
integrity.

💰 4. Wallet System Design

Key Features:
Load money from bank or card

Pay using wallet balance

Refunds and reversals

Compliance with RBI regulations

Design:

Balance table (user_id, available_balance, hold_balance)

Every transaction creates entries in:

Ledger Table (immutable history)

Wallet Transaction Table (current status, type)

🔄 5. Transaction Flow (Generic)

Initiation
1. User starts payment

2. Validate credentials, MPIN

Lock funds (soft lock)

Processing

3. Send request to payment processor (UPI/Card Gateway)

Wait for response (success/failure)

Completion

4. Update wallet/bank balance

Persist transaction status


Send confirmation to user

5. Failure/Timeout Handling

6. Rollback or retry

7. Reconciliation jobs for orphaned transactions

🧰 6. Tech Stack (Suggested)


📊 7. Scalability &

eliability

Partitioned Services (e.g., UPI vs Wallet vs Cards)


Database Sharding for high load

Failover Mechanisms for 3rd party APIs (multiple gateways)

Rate-limited APIs for fairness

Scheduled Reconciliation jobs to ensure ledger integrity

🔍 8. Monitoring & Auditing


Real-time monitoring of failures, fraud

Alerting on anomalies (transaction spikes, duplicate patterns)

Auditable transaction logs

Admin dashboard with filters


🧠 Example ERD (Simplified)

Entities:
User: id, phone, KYC_status, auth_token

Wallet: user_id, balance, hold_balance

BankAccount: user_id, bank_ifsc, account_number, UPI_handle

Transaction: id, sender, receiver, amount, type, status, timestamp

Ledger: transaction_id, debit_account, credit_account, amount, timestamp

You might also like