Skip to content

System Architecture

MyWarranties is a complete warranty management ecosystem consisting of three main applications that work together to provide a seamless experience for customers and suppliers.

Overview

The MyWarranties ecosystem includes:

  1. Mobile App (iOS & Android) - Customer-facing mobile application
  2. ERP Web Application - Management and administration interface
  3. Backend API - Centralized API server powering both applications

Architecture Diagram

┌─────────────────────────────────────────────────────────┐
│                      Clients                             │
├────────────────┬─────────────────┬──────────────────────┤
│  Mobile App    │   ERP Web App   │   Future Clients     │
│  (iOS/Android) │   (React SPA)   │                      │
└────────┬───────┴────────┬────────┴──────────────────────┘
         │                │
         │  HTTPS/JWT     │  HTTPS/JWT
         │                │
┌────────▼────────────────▼───────────────────────────────┐
│          Backend API (Symfony 8 / PHP 8.3)             │
│  ┌───────────┐  ┌───────────┐  ┌──────────┐           │
│  │   Auth    │  │  Products │  │  Claims  │           │
│  │   JWT     │  │  Warranty │  │  Messages│           │
│  └───────────┘  └───────────┘  └──────────┘           │
│                                                         │
│  ┌───────────┐  ┌───────────┐  ┌──────────┐           │
│  │   Email   │  │Real-time  │  │   Push   │           │
│  │  Resend   │  │  Mercure  │  │ Firebase │           │
│  └───────────┘  └───────────┘  └──────────┘           │
└───────┬─────────────────────────────────────────────────┘

    ┌───┼──────┬──────────────┬─────────────┬───────────┐
    │   │      │              │             │           │
┌───▼┐ ┌▼────┐ ┌▼────────┐ ┌─▼──────┐  ┌──▼──────┐ ┌─▼────┐
│MySQL│ │Resend│ │ Mercure │ │Firebase│  │ Claude  │ │ CDN  │
│  DB │ │Email │ │Realtime │ │  Push  │  │   AI    │ │Assets│
└─────┘ └──────┘ └─────────┘ └────────┘  └─────────┘ └──────┘

Applications

1. Mobile App (mywarranties)

Technology Stack:

  • React Native (via Capacitor)
  • TypeScript
  • Mantine UI
  • Vite build system

Features:

  • Native iOS and Android apps
  • Real-time chat via Mercure (Server-Sent Events)
  • Native push notifications (APNs for iOS, FCM for Android)
  • Receipt scanning and OCR
  • Warranty tracking
  • Claim management
  • Product management

Deployment:

  • iOS: App Store
  • Android: Google Play Store
  • Kubernetes deployment for web version

Repository: /IdeaProjects/mywarranties

2. ERP Web Application (mywarranties-ERP)

Technology Stack:

  • React 18
  • TypeScript
  • Mantine UI 8.3
  • Zustand (state management)
  • TanStack Query (server state)
  • Axios (HTTP client)
  • React Router v6

Features:

  • Web-based management interface
  • Product and warranty management
  • Claims processing
  • User management
  • Reporting and analytics
  • Bulk operations

Deployment:

  • Kubernetes cluster
  • Nginx reverse proxy
  • CDN for static assets

Repository: /IdeaProjects/mywarranties-ERP

Production URL: https://erp.my-warranties.nl

3. Backend API (mywarranties-backend)

Technology Stack:

  • Symfony 8.0
  • PHP 8.3+
  • PostgreSQL 16
  • Docker + Kubernetes

Core Services:

  • RESTful API
  • JWT Authentication
  • Email (Resend)
  • Real-time updates (Mercure)
  • Push notifications (Firebase)
  • AI OCR (Claude AI)

Deployment:

  • Kubernetes cluster on DigitalOcean
  • Docker containers
  • ArgoCD GitOps deployment
  • Automatic CI/CD via pre-commit hooks

Repository: /IdeaProjects/mywarranties-backend

Production URL: https://api.my-warranties.nl

Communication Flow

Authentication

  1. User logs in via mobile app or ERP web app
  2. Client sends credentials to /api/login
  3. Backend validates and returns JWT token
  4. Client stores token and includes in all subsequent requests

Real-time Updates (Mercure)

  1. User A sends a message in a claim
  2. Backend publishes update to Mercure hub
  3. Mercure broadcasts to all subscribers (User B, suppliers)
  4. Clients receive update via Server-Sent Events
  5. UI updates automatically without polling

Push Notifications

  1. Backend detects event requiring notification
  2. Sends notification payload to Firebase Cloud Messaging
  3. FCM routes to APNs (iOS) or directly delivers (Android)
  4. Device receives push notification
  5. User taps notification, app opens to relevant screen

Email Integration

  1. System sends email via Resend SMTP
  2. Recipient can reply to embedded claim email
  3. Resend receives reply, forwards to webhook
  4. Backend processes webhook, creates claim message
  5. Message appears in real-time via Mercure

Infrastructure

Kubernetes Cluster

All three applications run on a Kubernetes cluster with:

API Backend:

  • Deployment: mywarranties-api
  • Service: ClusterIP
  • Ingress: api.my-warranties.nl
  • Replicas: 2 (auto-scaling enabled)

ERP Web App:

  • Deployment: mywarranties-erp
  • Service: ClusterIP
  • Ingress: erp.my-warranties.nl
  • Replicas: 2
  • Nginx for static files

Mobile App Web Version:

  • Deployment: mywarranties-app
  • Service: ClusterIP
  • Ingress: app.my-warranties.nl
  • Replicas: 2

Supporting Services:

  • PostgreSQL database (persistent volume)
  • Mercure hub for real-time updates
  • Redis for caching
  • Nginx Ingress Controller
  • cert-manager for TLS certificates

Container Registry

All Docker images are stored in:

  • Registry: registry.digitalocean.com/delaparra-services-private-registry
  • Images:
    • mywarranties-api:latest
    • mywarranties-api-docs:latest
    • mywarranties-erp:latest
    • mywarranties-app:latest

GitOps Workflow

Deployments are automated using ArgoCD:

  1. Developer commits code
  2. Pre-commit hook builds Docker image
  3. Image pushed to registry
  4. Kubernetes manifests updated with new tag
  5. Changes pushed to Git
  6. ArgoCD detects change
  7. ArgoCD syncs cluster state
  8. Deployment rolled out with zero downtime

Security

Authentication & Authorization

  • JWT tokens with 1-hour expiry
  • Role-based access control (RBAC)
  • Password hashing with bcrypt
  • Secure cookie storage for web clients

Network Security

  • All traffic over HTTPS/TLS
  • TLS certificates from Let's Encrypt
  • CORS configuration for allowed origins
  • Rate limiting on API endpoints

Data Security

  • Encrypted database connections
  • Environment variables for secrets
  • Kubernetes secrets for sensitive data
  • No credentials in source code

API Security

  • Input validation on all endpoints
  • SQL injection prevention (Doctrine ORM)
  • CSRF protection
  • Webhook signature verification (HMAC-SHA256)

Scalability

Horizontal Scaling

  • All applications are stateless
  • Can scale to multiple replicas
  • Load balanced via Kubernetes service
  • Session data in Redis (shared)

Database Scaling

  • PostgreSQL replication (master-replica)
  • Connection pooling
  • Read replicas for reporting queries
  • Automated backups

Caching Strategy

  • Redis for session storage
  • Application-level caching
  • CDN for static assets
  • Browser caching headers

Monitoring & Logging

Application Monitoring

  • Kubernetes health checks
  • Liveness and readiness probes
  • Resource usage metrics
  • Error tracking and alerting

Logging

  • Centralized logging
  • Application logs to stdout
  • Kubernetes log aggregation
  • Log retention policies

Metrics

  • API response times
  • Error rates
  • Database query performance
  • Real-time connection count

Development Workflow

Local Development

  1. Backend: symfony server:start or Docker Compose
  2. ERP Web: npm run dev (Vite dev server)
  3. Mobile App: npm run dev for web, Xcode/Android Studio for native

Testing

  • Backend: PHPUnit with 40+ tests
  • ERP Web: Vitest for unit tests
  • Mobile App: Jest + React Native Testing Library

CI/CD Pipeline

  1. Commit triggers pre-commit hook
  2. Tests run automatically
  3. Docker images built
  4. Images pushed to registry
  5. Kubernetes manifests updated
  6. ArgoCD deploys to cluster

URLs & Endpoints

ServiceURLPurpose
API Backendhttps://api.my-warranties.nlREST API endpoints
API Documentationhttps://docs.api.my-warranties.nlAPI docs (VitePress)
ERP Web Apphttps://erp.my-warranties.nlManagement interface
Mobile Web Apphttps://app.my-warranties.nlPWA version
Mercure Hubhttps://mercure.api.my-warranties.nlReal-time updates

Database Schema

Core Tables

  • users - User accounts with roles
  • products - Products with warranty information
  • warranty_claims - Customer warranty claims
  • claim_messages - Messages in claim threads
  • receipts - Receipt images and OCR data
  • verification_codes - Auth verification codes
  • product_images - Product photos

Relationships

  • User → Products (one-to-many)
  • Product → WarrantyClaim (one-to-many)
  • WarrantyClaim → ClaimMessages (one-to-many)
  • User → ClaimMessages (one-to-many)

Next Steps

MyWarranties - Warranty Management System