Skip to content

Create a safe One Concept Staging app and environment #255

Open

Description

@Muawiya-contact

Goal

Create one safe Staging environment beside the existing Production environment. The staging app must install and run on the same phone as the production One Concept app without replacing it, sharing its account data, or receiving production updates.

Timing and current platform (2026-10-24)

Plan this work for the week of 2026-10-26, after the production Railway-to-Supabase migration is complete and verified. Keep this issue open; do not build or deploy the separate staging APK as part of the current cutover or PR #458.

The repository already identifies a separate Supabase staging project (zhrulokgngjceqgjkcmw) and production project (egdszjoesxlccauahmsx). Verify the staging project's live schema, API, Auth, workers, and access before reusing it; do not create a duplicate project by default. Supabase Edge Functions and Cron are the target for both environments. Earlier Railway staging requirements in this issue and its comments are superseded by this plan.

The existing Expo preview channel alone is not a staging environment. The last reviewed preview mobile values pointed at production Supabase. Before distributing the staging APK, configure and validate the preview EAS environment against staging-only Supabase URL, publishable key, API URL, Auth redirects, and test accounts. Leave production EAS variables unchanged.

This is a two-environment design:

Environment Branch Users Purpose
Staging develop Team test accounts only Test merged work and test PR branches locally from a PC
Production main Real users Live application

A developer PC running Expo or FastAPI is only a temporary local test server. It is not a third deployed environment.

Problem in simple words

Today, the preview and production builds use the same Android package identity: com.codingmoves.oneconcept. Android treats two APKs with that identity as the same app. Installing a preview build can therefore replace the production app on a phone.

That makes PR testing risky. A tester should be able to open the real production app and the staging app side by side. The staging app also needs its own database, authentication users, backend URL, and update stream so test activity cannot touch real user data.

A production app must never be pointed at a PC's local server. It should continue to use only the production update channel and production services.

Required design

1. A separate One Concept Staging mobile app

Create a build variant with clear visual identity:

  • Display name: One Concept Staging.
  • Android package: com.codingmoves.oneconcept.staging.
  • A distinct iOS bundle identifier and URL/deep-link scheme for future iOS support.
  • A visibly different staging icon, label, or startup marker so a tester cannot mistake it for the production app.
  • Production remains One Concept with com.codingmoves.oneconcept.
  • Both APKs must install on one Android phone at the same time. Installing, updating, or deleting the staging app must not modify the production app.
  • Publish a separate staging APK build link. Use the existing mobile source and EAS project; the distinct package identity, preview channel, and staging configuration create the separate installed app.

2. Separate cloud data and services

Create isolated staging resources:

  • Verify and reuse the existing Supabase Staging project (zhrulokgngjceqgjkcmw), separate from production (egdszjoesxlccauahmsx); create a replacement only if the existing project fails the isolation/readiness checks.
  • Deploy staging API and workers as Supabase Edge Functions from the reviewed develop revision, with staging-only Cron jobs and safe gates. Production API/workers remain on their protected Supabase deployment path from main.
  • Staging database credentials, Supabase URL, Supabase publishable key, Edge API URL, Auth redirect URLs, and test-email settings must be separate from production values.
  • Create test accounts only in staging. No production user data, database backups, service-role keys, Gemini keys, or SMTP credentials are copied into the app or committed to Git.
  • Keep generation disabled in staging by default. Enable it only for a deliberate test with capped/non-production credentials.
  • Configure staging Edge API health checks and Cron worker schedules safely. Reminder emails and notifications must not reach real users from staging.
  • Register the staging Android package in Firebase/FCM with a matching google-services.json and EAS credentials before testing push reminders; do not reuse production push configuration by changing only the app label.

3. Separate update channels and configuration

Keep one EAS project but isolate update delivery by channel and environment:

  • Production builds use the production channel and production EAS variables.
  • Staging builds use the preview channel and staging EAS variables.
  • A staging development-client build may use the staging package identity and the preview channel. It must be able to open a Metro bundle from a PC for a feature-branch test, then receive ordinary preview OTA updates when develop advances.
  • Production phones must never receive preview updates. Staging phones must never receive production updates.
  • Native changes require a new staging APK before staging testing, and a separate production build later. JavaScript-only changes can use OTA updates within the compatible runtime.
  • Maintain the existing release rule: a release PR still needs a version bump and matching one-time What's New card. Do not publish a production OTA from a feature branch or from develop.

4. Local PR testing on a physical phone

Document a repeatable local flow:

  1. Install One Concept Staging once on the Android phone.
  2. Check out the feature branch on the PC.
  3. Start FastAPI on 0.0.0.0:8000 using safe local/staging test configuration.
  4. Set the feature branch's uncommitted local configuration to use the PC's LAN IP, such as http://192.168.x.x:8000; never use localhost on the phone.
  5. Start Expo with npx expo start --dev-client --lan.
  6. Connect the staging app to Metro and test the exact PR flow.
  7. Run mobile typecheck/tests and backend tests before opening or updating the PR.
  8. Stop Metro and the local backend when testing is finished. The production app remains unaffected throughout.

The phone and PC must be on the same Wi-Fi network. Document firewall guidance for port 8000 and how to find the PC LAN IP. Local environment files must remain gitignored.

5. Shared staging validation after merge

After a PR merges into develop:

  • Deploy the Supabase Edge API and workers to the verified staging project.
  • Run the existing preview OTA workflow against the preview channel.
  • Test the merged behavior in One Concept Staging against staging Supabase only.
  • Keep production untouched until a reviewed develop to main release PR is merged and the manual production Release workflow is run.

Do not publish an OTA for every open feature branch. A feature branch is tested locally through Metro; the shared staging app receives the integrated update after its PR merges into develop.

Implementation tasks

  • Add a documented app-variant configuration for production and staging package names, display names, schemes, and visual marker.
  • Add safe EAS build profiles for staging APK and staging development client; preserve the production profile.
  • Configure EAS preview variables exclusively with staging public configuration and keep production variables unchanged.
  • Verify the existing Supabase staging project's isolation, schema, API, Auth, redirect URLs/templates, test accounts, and safe worker defaults; create a replacement only if needed.
  • Deploy staging Supabase Edge API and workers from develop; configure safe Cron schedules and generation switch.
  • Register the staging package in Firebase/FCM and configure package-specific Android push credentials before notification tests.
  • Add an explicit configuration validation that rejects production values in a staging build and rejects staging values in a production build.
  • Update GitHub Actions so develop publishes only preview/staging updates after checks pass; main retains the guarded production release workflow.
  • Add a local-phone test guide with exact commands, LAN troubleshooting, test-account rules, and rollback/reinstall instructions.
  • Add automated checks for app variant identity, channel/environment pairing, and public configuration validation.
  • Verify Android side-by-side installation: production stays signed in to production while staging signs in only to staging.
  • Verify a staging OTA cannot reach production and a production OTA cannot reach staging.
  • Verify sign-out, offline queue, password reset links, notifications, and account switching use the correct environment.

Acceptance criteria

  • A tester can keep production One Concept installed while installing One Concept Staging.
  • The two apps show different names and package identities and can be opened independently.
  • Staging uses only staging Supabase API/Auth/data/workers, staging users, and preview updates.
  • Production uses only production Supabase API/Auth/data/workers, production users, and production updates.
  • A feature PR can be tested from a PC on a physical phone over LAN without modifying the production app or publishing an update.
  • A merge to develop updates staging only after required checks pass.
  • A production release remains the existing guarded develop to main process, including deployment verification, the manual Release workflow, and the matching What's New card.
  • Setup and rollback are documented well enough for the owner to repeat without exposing secrets.

Out of scope

  • Play Store submission and paid features.
  • Moving production to a different provider.
  • Restoring or copying production backups into staging.

Activity

  1. Muawiya-contact commented on Sep 27, 2026

    @Muawiya-contact
    MemberAuthor

    Additional requirement: seeded staging sandbox

    The staging Supabase database must be a small, safe sandbox for realistic testing. It must not be restored from a production backup or contain production users, learning history, email addresses, or secrets.

    Seed a compact, repeatable test dataset after schema migrations:

    • A small card library across the existing subjects, including enough lessons to test assignment replacement, completed subjects, saved/liked cards, and search/history views.
    • Named test accounts with non-real addresses or clearly marked test inboxes. Give each account a documented purpose rather than using anonymous shared credentials.
    • Test profiles covering a new learner, an active learner, and an advanced learner.
    • Controlled values for streaks, points/stars, completed lessons, saved concepts, daily-review state, achievements, and notification preferences.
    • Purpose-built scenarios such as an empty state, a full/complete subject, a failed/retryable sync, queued offline progress, and a prior What's New dismissal.

    Provide a reset/seed command that is safe for staging only. It must reject production configuration, be idempotent, and make it obvious that it deletes/recreates staging test data only. Document how to refresh the sandbox before a test session and how to create temporary extra data without changing the seed baseline.

    Acceptance additions:

    • Staging starts with enough cards and test accounts to exercise every primary mobile screen without generating live content.
    • Testers can select documented dummy accounts for streak, achievement, star, offline, empty-state, and completed-subject checks.
    • The seed/reset process cannot run against production.
    • No production data is copied into staging.
  2. Muawiya-contact commented on Sep 27, 2026

    @Muawiya-contact
    MemberAuthor

    Engineering review: required additions before implementation

    The scope is strong. Add the following requirements so the setup remains safe as more contributors and features arrive.

    Migration and seed order

    • Apply every new migration to staging before deploying code that depends on it. Production migrations remain ordered, immutable, and manually verified under the existing production rule.
    • Run the staging seed only after migrations complete successfully. The seed must be versioned with the schema and fail clearly when the expected schema revision is missing.
    • Test both a blank staging database and a populated seeded database. A feature must not work only because the seed hides a migration or empty-state problem.
    • Destructive migration rehearsal, seed reset, and fixture refresh may run only against the staging project. The command must require an explicit staging marker in addition to rejecting production URLs/project IDs.

    Deployment traceability and smoke checks

    • Every staging API/worker deployment must expose the deployed Git SHA through a safe health/status endpoint or deployment metadata. The staging mobile build/update must record its Git SHA, EAS update ID, channel, runtime version, and backend revision in the PR/check output.
    • After a develop deployment, run a non-destructive smoke check against staging: API health/database reachability, authenticated test-account request, and worker configuration/status. Do not claim staging is ready merely because the deployment platform reports green.
    • Serialize staging deployments and preview OTA publications so two quick merges cannot leave the app pointing to a different backend revision than the tested code.

    Native platform identity and credentials

    • Register the staging Android package separately in Firebase/Google services if push notifications are enabled. Its google-services.json, FCM credentials, OAuth redirect settings, deep-link scheme, and future iOS bundle ID must belong only to staging.
    • Keep staging signing/build credentials and artifact links distinct from production release credentials. A staging build must never be submitted to Play Store production tracks.
    • Maintain independent app-version/build-number records for the staging package. Native changes require a compatible new staging build before the staging OTA is published.

    Secrets, access, and untrusted contributions

    • Store staging and production secrets in separate GitHub/EAS/Railway/Supabase environments. Do not place any secret in repository variables, mobile public configuration, logs, screenshots, test fixtures, or pull-request comments.
    • Protect production deployment/release secrets behind the production GitHub environment. Pull requests from forks and untrusted branches must run lint/tests only; they must never receive deployment credentials, publish an OTA, access staging data, or trigger Railway jobs.
    • Give contributors the smallest access needed. Record the owner of staging resources and a simple rotation/revocation procedure for compromised staging credentials.

    Local-network testing safety

    • Local backend instructions must use a staging-only configuration and test accounts. They must never accept production database URLs or production service credentials.
    • Add narrow CORS/LAN guidance for web testing. Do not solve local connectivity by permitting every origin in production.
    • Document that a physical device needs the PC and phone on the same trusted network; do not expose a local development server publicly to make testing work.

    Rollback and test operations

    • Record the previous staging backend revision and preview update ID before each staging release. Document how to roll back the staging backend and republish/revert a preview update without affecting production.
    • Add a small staging operations checklist: reset fixture data, check worker schedules, verify test email/notification routing, inspect health/revision, and record the tested PR/commit.
    • Define fixture ownership and cleanup: test accounts/data are deliberately disposable, no personal information is stored, and stale temporary accounts are removed on a documented schedule.

    Contribution workflow

    • Require each feature/fix PR to reference its dedicated GitHub issue, describe the tested staging/local flow, list migrations/configuration changes, and state whether it is OTA-compatible or needs a new native staging build.
    • Make the normal sequence explicit: feature branch → local phone/PC test → reviewed PR → merge to develop → staging deploy/preview validation → release PR from develop to main → guarded production release.
    • Add required CI checks for mobile typecheck/tests, backend tests, migration/seed validation, app-variant identity, public configuration pairing, and a staging smoke check after deploy. Enable branch-protection rules once these checks are established.

    Acceptance additions

    • A deployed staging revision and its matching preview update can be identified from a commit SHA without inspecting secrets.
    • Staging migration, seed, reset, and rollback paths are tested and cannot target production.
    • Untrusted PRs cannot obtain staging/production credentials or trigger deployments.
    • Staging push/auth/deep-link configuration uses its own application identity and cannot send to production users.
    • Two develop merges cannot race and produce a mismatched staging backend/mobile test result.
    • Every contribution PR links an issue and records its local/staging validation and native-versus-OTA impact.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions