Thuta Learning
ProjectsMobile Developmentintermediate

Project: Mobile Auth and Notification Architecture

What you'll walk away with

  • Explain the core ideas behind Project: Mobile Auth and Notification Architecture
  • Read the diagram/checklist and trace how the mobile architecture or decision connects
  • Explain how this applies to a real mobile app project

Build the mental model

This project fuses the two identity- and messaging-focused lessons from this course: mobile authentication architecture and push notification architecture. Individually, each lesson explained one loop: how a user proves who they are and keeps a session alive, and how a backend reaches a specific installed app instance without polling. Building a real app requires connecting those two loops, because a push notification is worthless if the backend cannot say which user's device to send it to, and that link only exists once authentication and device registration talk to each other.

  • Mobile authentication architecture — login, session tokens, secure storage, and every subsequent authenticated call
  • Push notification architecture — device-token registration and how a backend reaches one specific installed app

The fictional app for this project is a learning platform with user accounts and lesson-reminder notifications, deliberately close to the real site this course lives on. A learner logs in with an email and password, or through an OAuth provider such as Google as an alternative path with no separate password to manage.

Both paths funnel into the same session token from mobile authentication architecture. That token goes into secure storage on the device, never plain preferences, and every subsequent API call, including the push-notification lesson's device-token registration call, carries it as proof of identity.

The design detail that ties the whole project together is the backend's data model: it does not store device tokens on their own, it stores a device token linked to a user id, populated only after that same authenticated call succeeds.

When an event worth notifying about happens, a new lesson unlocking in this scenario, the backend looks up that user's stored device token and sends the push through Apple's or Google's notification service, never contacting the device directly.

Short-circuit before the lookup

An unauthenticated request, or a user with no registered device token, must short-circuit before reaching the device-token lookup step — which is exactly what the accompanying code demonstrates for both failure cases.

text
MOBILE AUTH + PUSH NOTIFICATION ARCHITECTURE
--------------------------------------------
[Login: password]  or  [Login: OAuth (Google)]
              |
              v
     [Backend issues session token]
              |
              v
   [Token stored in secure storage on device]
              |
              v
  [Authenticated API calls]  +  [Device token registration]
              |
              v
   [Backend: user record now linked to device token]
              |
              v
        [Event: new lesson unlocked]
              |
              v
     [Push service: Apple APNs / Google FCM]
              |
              v
           [Learner's device]

Connect it to a real scenario

Login: password or OAuth

The learner opens the app and either enters a password or completes an OAuth redirect with Google. Either path ends at the same place: the backend issues a session token.

Token to secure storage

The app immediately writes that session token to secure storage rather than to plain app preferences, so it survives app restarts without being readable by other apps or a simple file-system scan.

Device token registration (authenticated)

The app asks the OS for a device token, then sends it to the backend on an authenticated endpoint using the same authorization header as every other API call. The backend rejects the call outright if the session token is missing or invalid.

Backend links device token to user

Once registration succeeds, the backend's user record carries both the account data and the current device token side by side — a device token saved without a verified user id would be a device the backend can message but never actually identify.

Event triggers a push lookup

When a lesson-unlock event fires, the backend does not touch the device directly. It looks up the user's stored device token and hands the notification off to Apple's or Google's push service, which performs the actual delivery.

Trace the failure path

Deliberately trace an unauthenticated session, and a user who has never completed device registration, and confirm both stop before the lookup step and never reach the push service at all.

Try the working example

javascript
function simulateAuthAndNotificationFlow(user, event) {
  const steps = [];

  if (!user.isAuthenticated) {
    steps.push("Auth check: FAILED - no valid session token");
    steps.push("Aborting before device-token lookup");
    return { user: user.name, event, steps, notificationSent: false };
  }
  steps.push("Auth check: PASSED - session token valid");

  if (!user.deviceToken) {
    steps.push("Device token lookup: NONE REGISTERED");
    steps.push("Aborting before push dispatch");
    return { user: user.name, event, steps, notificationSent: false };
  }
  steps.push(`Device token lookup: FOUND (${user.deviceToken})`);

  steps.push(`Event received: "${event}"`);
  steps.push(`Push dispatch: sending to ${user.platform} push service`);
  steps.push(`Notification delivered to device ${user.deviceToken}`);

  return { user: user.name, event, steps, notificationSent: true };
}

const scenarios = [
  {
    user: {
      name: "Aye (authenticated, registered device)",
      isAuthenticated: true,
      deviceToken: "device-abc123",
      platform: "Android (FCM)"
    },
    event: "New lesson unlocked: How Mobile Apps Work"
  },
  {
    user: {
      name: "Unknown visitor (no session)",
      isAuthenticated: false,
      deviceToken: null,
      platform: null
    },
    event: "New lesson unlocked: How Mobile Apps Work"
  }
];

scenarios.forEach(({ user, event }) => {
  const result = simulateAuthAndNotificationFlow(user, event);
  console.log(`${result.user}`);
  result.steps.forEach((s) => console.log(`  - ${s}`));
  console.log(`  Notification sent: ${result.notificationSent}\n`);
});
You should see
Running the two scenarios prints: the authenticated user with a registered device passes the auth check, finds device token "device-abc123", and logs a successful push dispatch and delivery, ending with notificationSent: true. The unauthenticated visitor fails the auth check immediately, logs an abort message, and ends with notificationSent: false — the device-token lookup never runs.

5-minute try-it

Extend simulateAuthAndNotificationFlow with a third scenario: an authenticated user whose session is valid but who has never registered a device token. Trace through the function by hand first, predict which log lines it prints and whether notificationSent is true or false, then run it and check your prediction.

One important caution

Registering a device token before confirming the session is authenticated, leaving a device the backend can message but never identify.

Designing the auth flow and the notification flow as two unrelated diagrams instead of one sequence that shares the same session token.

Firebase Cloud Messaging — Architectural OverviewHow Mobile Apps Work

Easy traps

  • Registering a device token before confirming the session is authenticated, leaving a device the backend can message but never identify.
  • Designing the auth flow and the notification flow as two unrelated diagrams instead of one sequence that shares the same session token.
  • This course does not re-teach the Android Development, Flutter, iOS Development, or React Native tutorials -- continue to those for hands-on framework depth. This course teaches the framework-neutral mobile architecture, decision-making, and build/deployment/security concepts that sit above all four.

Exercise

Extend simulateAuthAndNotificationFlow with a third scenario: an authenticated user whose session is valid but who has never registered a device token. Trace through the function by hand first, predict which log lines it prints and whether notificationSent is true or false, then run it and check your prediction.

You'll know it worked when: Running the two scenarios prints: the authenticated user with a registered device passes the auth check, finds device token "device-abc123", and logs a successful push dispatch and delivery, ending with notificationSent: true. The unauthenticated visitor fails the auth check immediately, logs an abort message, and ends with notificationSent: false — the device-token lookup never runs.

Project: Mobile Auth and Notification Architecture | Thuta Learning