Skip to content

PR/PO Management App System Design

1. Business Requirements

Functional Requirements

  • User registration and authentication (employees, managers, finance, admins)
  • Create, edit, approve, and track Purchase Requests (PR) and Purchase Orders (PO)
  • Workflow management for PR/PO approvals (multi-level)
  • Attachments for supporting documents (quotes, invoices)
  • Real-time status updates and notifications (urgent alerts for pending/overdue approvals)
  • Search and filter PR/POs (by status, department, vendor, date, etc.)
  • Role-based access control (requester, approver, finance, admin)
  • Audit logging for all actions
  • Mobile-ready responsive UI and API
  • Analytics and reporting (spending trends, approval times)

Non-Functional Requirements

  • 99.9% availability (max ~8.76 hours downtime/year)
  • Scalability to support large organizations and high transaction volume
  • Secure data storage and access control
  • Fast response times (<300ms for most requests)
  • Audit logging and monitoring
  • Backup and disaster recovery
  • GDPR/data privacy compliance
  • Mobile responsiveness

Out of Scope

  • Integration with external ERP/accounting systems (unless specified)
  • Payment processing
  • Vendor onboarding/management (unless specified)

2. Estimation & Back-of-the-Envelope Calculations

  • Users: 10,000 (employees, managers, finance, admins)
  • PR/POs per year: 500,000 (~1,400/day)
  • Peak concurrent users: ~1,000
  • Data size:
    • PR/PO records: 500,000 × 2 KB ≈ 1 GB
    • Attachments: 500,000 × 500 KB ≈ 250 GB (object storage)
    • User data: 10,000 × 2 KB ≈ 20 MB
    • Audit logs: 10M × 0.2 KB ≈ 2 GB
    • Total DB size: ~3 GB (excluding logs, backups, attachments)
  • Availability:
    • 99.9% = 8.76 hours/year downtime max
    • Use managed DB, multi-AZ deployment, health checks, auto-scaling

3. High Level Design (Mermaid Diagrams)

Component Diagram

mermaid
flowchart LR
  User[User (Web/Mobile)]
  LB[Load Balancer]
  App[Application Server]
  DB[(Database)]
  Cache[Cache (Redis)]
  Storage[Object Storage (Attachments)]
  Alert[Alert/Notification Service]
  Analytics[Analytics Engine]

  User --> LB --> App
  App --> DB
  App --> Cache
  App --> Storage
  App --> Alert
  App --> Analytics
  Analytics --> DB

Data Flow Diagram

mermaid
sequenceDiagram
  participant U as User
  participant A as App Server
  participant D as Database
  participant C as Cache
  participant S as Storage
  participant L as Alert Service

  U->>A: Submit PR/PO
  A->>C: Check User/Workflow State
  C-->>A: Hit/Miss
  A->>D: Create/Update PR/PO Record
  D-->>A: Success/Fail
  A->>S: Upload Attachment (if any)
  S-->>A: Success/Fail
  A->>L: Send Urgent Alert (if pending/overdue)
  A-->>U: Response

Key Design Decisions

  • Database: Relational DB (e.g., PostgreSQL) for transactional data, strong consistency
  • Cache: Redis for fast lookups (sessions, workflow state)
  • Object Storage: For attachments (e.g., AWS S3, Azure Blob)
  • Alerting/Notifications: Email/SMS/push via third-party service (e.g., Twilio, Firebase)
  • Analytics: Batch or streaming (e.g., Kafka + Spark, or managed cloud analytics)
  • Deployment: Cloud-based, multi-AZ, managed services for high availability
  • API: REST/GraphQL for mobile and web clients

4. Conceptual Design

Entities

  • User: id, name, email, password_hash, role, department, registration_date, status
  • PurchaseRequest (PR): id, user_id, department, description, amount, status, created_at, updated_at
  • PurchaseOrder (PO): id, pr_id, vendor, amount, status, created_at, updated_at
  • Attachment: id, pr_id, po_id, url, type, uploaded_by, uploaded_at
  • Approval: id, pr_id, po_id, approver_id, status, approved_at, level
  • Alert: id, user_id, pr_id, po_id, type (urgent/pending/overdue), message, created_at, status
  • AuditLog: id, user_id, action, entity, entity_id, timestamp

Key Flows

  • PR/PO Submission:
    1. User submits PR/PO
    2. App checks workflow state (cache, then DB)
    3. Stores PR/PO, uploads attachments
    4. Triggers urgent alert if pending/overdue
  • Approval Workflow:
    1. Approver reviews PR/PO
    2. Updates approval status, triggers next step or alert
  • Alerts:
    • System triggers urgent alerts for pending/overdue approvals
  • Analytics:
    • Periodic jobs aggregate PR/PO, approval, and spend data

Security

  • Role-based access control (RBAC)
  • Input validation, rate limiting
  • Encrypted connections (HTTPS)
  • Regular backups and audit logs

5. Bottlenecks and Refinement

Potential Bottlenecks

  • Workflow state contention:
    • Use cache for workflow state, DB connection pooling
  • Attachment storage/delivery:
    • Use scalable object storage and CDN
  • Alert delivery:
    • Use async queues for urgent notifications
  • Database contention:
    • Use read replicas, caching, and DB connection pooling
  • Single region failure:
    • Deploy across multiple availability zones/regions

Refinement

  • Monitor system metrics and auto-scale app servers
  • Regularly test failover and backup restores
  • Optimize queries and indexes for frequent operations
  • Consider sharding if user/PR/PO volume grows significantly

This design provides a scalable, highly available, and mobile-ready PR/PO management system with robust urgent alerts, analytics, and operational best practices.