System Documentation
Version: 2.0.0 | Last Updated: January 2026 | Status: Production
Table of Contents
1. System Overview
JGPNR is a comprehensive ticketing and e-commerce platform designed for managing game arena sessions, product sales, and customer relationships. The system provides:
- Game Session Ticketing: Purchase and manage tickets for scheduled gaming sessions
- E-Commerce: Product catalog with shopping cart and checkout
- Customer Management: Track customer data, orders, and engagement
- Admin Dashboard: Full administrative control with analytics and reporting
- Automated Notifications: Email and WhatsApp reminders for sessions and expirations
Technology Stack
| Component | Technology |
|---|---|
| Backend API | Node.js + Express + TypeScript |
| Database | PostgreSQL with Prisma ORM |
| Cache & Queues | Redis + BullMQ |
| Admin Panel | React + TypeScript + TailwindCSS |
| Customer Frontend | React + JavaScript (Vite) |
| Nodemailer with HTML templates | |
| Authentication | JWT with refresh tokens |
| File Storage | Local filesystem (uploads/) |
Architecture Overview
Deployment Architecture
- • SSL/TLS termination (Let's Encrypt)
- • Static file serving
- • Load balancing
- • Gzip compression
- • Cluster mode (4 instances)
- • Auto-restart on crash
- • Zero-downtime reload
- • Log management
- • Express 5 API
- • TypeScript compiled
- • ES2022 features
- • Socket.IO server
| Domain | Upstream | Type |
|---|---|---|
| jgpnr.com | /var/www/jgpnr/my-app/dist | Static |
| api.jgpnr.com | localhost:5000 | Proxy |
| admin.jgpnr.com | localhost:4173 | Proxy |
| securedocs.jgpnr.com | /var/www/jgpnr/docs | Static |
Background Jobs Architecture
2. Core Concepts
Tickets
Tickets are the primary purchasable units for game sessions. Each ticket:
- Has a unique
ticketCode(e.g., TKT-XXXXXX) - Is linked to an Order and a Customer
- Has a
validUntildate determining when it expires - Supports scanning for entry validation (configurable max scans)
Ticket Categories
| Category | Description | Use Case |
|---|---|---|
| SINGLE | One-time use ticket | Individual game session |
| GROUP | Discounted group tickets | Group bookings (4+ people) |
| SUBSCRIPTION | Time-based pass | Monthly/Quarterly/Yearly access |
Ticket Lifecycle
Ticket Expiry Mechanisms
Important: Tickets can expire through 3 different
mechanisms. The expiry job runs daily at midnight (cron: 0 0 * * *).
| Mechanism | Field | Applies To | Logic |
|---|---|---|---|
| Date Expiry | validUntil |
All tickets | Expires when current date > validUntil |
| Subscription Expiry | subscriptionExpiresAt |
Subscription tickets | Expires when current date > subscriptionExpiresAt |
| Scan Window Expiry | firstScanAt + scanWindow |
Multi-scan tickets | Expires when current date > (firstScanAt + scanWindow days) |
Reminder Schedule Processing
Analytics Note: Expired tickets are automatically excluded from active ticket counts and PlayStation session graphs. Only ACTIVE and PENDING tickets appear in forward-looking analytics.
Orders
Orders encapsulate purchases containing Tickets (for game sessions), Products (from the shop), or both.
Game Sessions
Game sessions occur on specific days with defined schedules:
- Tuesday Sessions: 17:00 (5PM Lagos time)
- Friday Sessions: 17:00 (5PM Lagos time)
Timezone: All session times use Africa/Lagos timezone. Subscription tickets calculate next session automatically for Tuesday (day 2) and Friday (day 5).
3. User Roles & Permissions
Authentication Flow
Role Definitions
| Action | SUPER_ADMIN | ADMIN | STAFF |
|---|---|---|---|
| Create Users | ✅ | ❌ | ❌ |
| Manage Orders | ✅ | ✅ | ❌ |
| Scan Tickets | ✅ | ✅ | ✅ |
4. Ticket Lifecycle
Ticket Statuses
| Status | Description |
|---|---|
| PENDING | Payment not yet confirmed |
| ACTIVE | Valid and ready for use |
| SCANNED | Has been used (max scans reached) |
| EXPIRED | Past validity date |
5. Order & Product Lifecycle
Order Statuses
| Status | Description |
|---|---|
| PENDING | Awaiting payment |
| PROCESSING | Paid, preparing fulfillment |
| COMPLETED | Fully fulfilled |
6. Shipment Logic
Note: Shipments apply to product orders only. Ticket orders do not generate shipments.
Shipment Statuses
| Status | Description | Actions Available |
|---|---|---|
| PROCESSING | Payment confirmed, preparing order | Add tracking, Mark shipped |
| SHIPPED | Order dispatched with tracking | Mark delivered |
| DELIVERED | Customer received order | Mark completed |
7. Inventory Management
The inventory system tracks product stock levels and provides automated low-stock alerts.
Key Features
- Real-time Stock Tracking: Stock decrements automatically on order creation
- Low Stock Alerts: Configurable threshold per product (default: 5 units)
- Product Sizes: Size-specific inventory with individual pricing
- Stock Adjustment: Manual adjustments with audit logging
Product Data Model
| Field | Type | Purpose |
|---|---|---|
| stock | Integer | Current quantity available |
| lowStockThreshold | Integer (default: 5) | Triggers low stock notification |
| trackInventory | Boolean | Enable/disable stock tracking |
| sizes | JSON Array | Size variants with individual pricing |
8. Payment System
9. Notification & Reminder Logic
Automated emails sent via Nodemailer and BullMQ. Background jobs process scheduled reminders.
Email Types
| Type | Trigger | Attachments |
|---|---|---|
| Order Confirmation | Order successfully created | None |
| Payment Receipt | Payment confirmed (webhook/manual) | PDF Receipt, Ticket QR Codes |
| Session Reminder | 24h and 2h before session | None |
| Expiry Reminder | 7 days, 3 days, 1 day before expiry | None |
| Shipping Update | Order shipped or delivered | None |
| Marketing Campaign | Admin-triggered campaigns | Custom (optional) |
Reminder Schedule Processing
10. Audit Logs & System Health
All significant actions are logged in the AuditLog table for compliance and debugging.
Logged Actions
| Category | Actions Logged |
|---|---|
| Authentication | Login, Logout, Password Change, Failed Attempts |
| Orders | Created, Payment Confirmed, Cancelled, Refunded |
| Tickets | Scanned, Extended, Cancelled, Settings Changed |
| Users | Created, Role Changed, Disabled, Deleted |
| Settings | System Settings Updated, Email Config Changed |
System Health Monitoring
- Database: Connection pool status, query latency
- Redis: Memory usage, queue depths (BullMQ)
- Email Queue: Pending, completed, and failed job counts
- Disk: Upload directory usage for attachments and QR codes
Access Restricted
System health endpoints require SUPER_ADMIN role. Access via:
GET /api/v1/health/detailed
11. Known Limitations
- Single Server: Not designed for horizontal scaling.
- Local File Storage: Uploads stored locally (not cloud storage).
- Single Database: No read replicas configured.
- Session Days: Tickets restricted to Tuesdays and Fridays only.
12. Glossary
| Term | Definition |
|---|---|
| Ticket | A scannable entry pass for a game session, with unique QR code |
| Order | A purchase transaction containing tickets and/or products |
| Subscription | A time-based ticket allowing unlimited sessions within validity period |
| Session | A scheduled game period on Tuesdays (18:00-20:30) or Fridays (18:00-21:30) |
| Scan | Validation of a ticket at entry, decrementing remaining uses |
| Customer | End-user who purchases tickets/products (separate from admin users) |
13. Request Lifecycle Architecture
Every API request passes through a defined middleware chain before reaching business logic.
14. Product Directory Structure
Complete directory layout for all system applications.
Backend API (/var/www/jgpnr/backend/src)
| Directory | Purpose | Key Files |
|---|---|---|
| modules/ | Feature modules (27 total) | orders/, tickets/, email/, payment/, analytics/ |
| jobs/ | Background jobs (10 files) | reminder.jobs.ts, ticketExpiry.job.ts, scheduler.jobs.ts |
| middleware/ | Express middleware (12 files) | auth.ts, validate.ts, rateLimit.ts |
| config/ | Configuration (9 files) | database.ts, queue.ts, email.ts |
| utils/ | Utilities (21 files) | ticketLifecycle.utils.ts, pdfGenerator.ts |
Frontend App (/var/www/jgpnr/my-app/src)
| Directory | Purpose | Key Files |
|---|---|---|
| pages/ | Route pages (12 files) | HomePage.jsx, BookingPage.jsx, ShopPage.jsx |
| components/ | Reusable UI (17 files) | PaymentModal.jsx, Header.jsx, SEO.jsx |
| api/ | API client (2 files) | axios.js, endpoints.js |
Admin Panel (/var/www/jgpnr/admin/src)
| Directory | Purpose | Key Files |
|---|---|---|
| pages/ | Admin views (55 files) | Dashboard/, Orders/, Tickets/, Settings/ |
| components/ | Shared components (64 files) | Tables, Forms, Modals, Charts |
| layout/ | Page layouts (4 files) | AppSidebar.tsx, AppLayout.tsx |
| context/ | React contexts (7 files) | AuthContext, NotificationContext, SocketContext |
| hooks/ | Custom hooks (8 files) | useAuth, useSocket, useNotifications |