Skip to main content

Data Flow

How data flows through the ThePlugg platform.

Authentication Flow

User → App: Enter phone number
App → Backend: POST /api/auth/send-otp
Backend → BulkSMS: Send SMS
BulkSMS → User: OTP code
User → App: Enter OTP code
App → Backend: POST /api/auth/verify-otp
Backend → Database: Create/Update user
Backend → App: User data + token
App: Store user session

Job Creation Flow

Service Seeker → App: Create job request
App → Backend: POST /api/service-seeker/jobs
Backend → Database: Create job record
Backend → OneSignal: Notify nearby providers
Backend → App: Job created confirmation
Provider Apps: Receive push notification
Provider → App: View and accept job
App → Backend: POST /api/provider/accept-job
Backend → Database: Update job with provider
Backend → OneSignal: Notify service seeker
Service Seeker App: Receive notification

Messaging Flow

User A → App: Send message
App → Backend: POST /api/chat/messages
Backend → Database: Save message
Backend → OneSignal: Push notification to User B
Backend → App: Message confirmation
User B App: Receive notification
User B → App: View conversation
App → Backend: GET /api/chat/conversations/:id/messages
Backend → Database: Fetch messages
Backend → App: Return messages
App: Display messages

Location Updates

App: Get GPS location
App → Backend: POST /api/location/update
Backend → Database: Save location
Backend → App: Success response

Admin Operations Flow

Admin → Dashboard: Perform action (e.g., verify provider)
Dashboard → Backend: PUT /api/admin/providers/:id/verify (with API key)
Backend: Validate API key
Backend → Database: Update provider
Backend → Dashboard: Success response
Dashboard: Show loading indicator
Dashboard: Refresh provider list
Dashboard: Display updated state

Rate Limiting Flow

App → Backend: Request OTP
Backend → Database: Check SMS rate limit
Database → Backend: Rate limit status
If allowed:
Backend → Generate OTP
Backend → BulkSMS: Send SMS
Backend → Database: Record SMS send
Backend → App: Success + nextAllowedAt
Else:
Backend → App: 429 error + nextAllowedAt
App: Show countdown timer

Data Synchronization

The platform uses:

  • Polling: Regular API calls to fetch updates
  • Push Notifications: Real-time notifications via OneSignal
  • Manual Refresh: User-triggered data refresh

Future improvements could include:

  • WebSocket connections for real-time updates
  • GraphQL subscriptions
  • Server-sent events (SSE)