Saving is off. The course database is down: labs work for practice, but nothing is saved.The course database is down.

LAB03

UI Systems, Project Architecture & Navigation

Start the app you will grow all semester, give it a NativeWind design language and a feature architecture, wire typed stack, tab and drawer navigation, and separate development, staging and production — through 15 interactive exercises.

Intermediate 3 h 45 minproduct-briefnativewinddesign-tokensaccessibilityfeature-architecturepath-aliasesreact-navigationtypescriptenvironmentseas

Your progress

0 / 15 exercises

6 parts · 3 h 45 min

Before you start

Who’s doing Lab 03?

This lab is open any time. Enter your name and student ID to start. Your work is saved.

By the end you will

  • Choose one approved app idea and write its product brief and screen map
  • Turn a screen design into reusable, accessible React Native components
  • Style consistent interfaces with NativeWind: hierarchy, rhythm, surfaces, feedback and state
  • Organize an Expo app by feature and use @/ path aliases
  • Build typed stack, tab and drawer navigation with route parameters
  • Separate development, staging and production without exposing secrets

You need

  • Lab 02 completed: components, props, state, NativeWind and navigation basics
  • Your team's approved project idea (or use Campus Companion, the worked example)
  • A laptop with Chrome, Edge or Firefox for the interactive exercises
  • Your team's GitHub repository and Expo Go or the Android emulator

Important

From this lab on, your team grows one application all semester. Every lab adds one taught technique to the same repository and Git history. Build one vertical slice at a time — don’t generate the whole app today.

Part 1: Start the semester app

35 min

One problem, one user, kept all semester

We use Campus Companion as the worked example: students discover events, save them, find their way around campus and get useful reminders. Your team may use its own instructor-approved idea — the techniques are the same.

Stable problem

One user problem you can keep for 12 weeks. Features grow; the problem doesn’t change.

Vertical slices

Each sprint finishes one thin feature end to end — screen, data, states — instead of half of everything.

Measurable

A sign you can check with real users, e.g. “6 of 10 testers save an event within 2 minutes”.

EX 01Read a product briefLoading the exercise…

Write your team’s brief

Fill it in for your idea — the card and the Markdown update as you type. Copy the Markdown into docs/product-brief.md in your repository.

Semester app

Campus Companion

    📱 🔌

    🎯

    docs/product-brief.md
    Empty fields use the Campus Companion example. What you type stays in this browser only; copy the Markdown into your repository.

    Draw the first screen map

    For each screen, write its purpose, its main action, the data it needs, and its loading, empty and error states. Today you build the shell, not every final feature.

    Home / discovery
    Item details
    Empty state, designed
    SprintAdd to the same applicationEvidence
    Lab 03Product brief, design language, folders, navigation, environmentsWorking shell + architecture commit
    UI & state labsReal screens, forms, lists and interaction statesA usable feature flow
    Data & API labsPersistent data and the external APILoading, success, empty and error paths
    Device & testing labsThe device feature and automated testsDemonstrated feature + test report
    Final labsAccessibility, performance and release qualityA staging build and defended decisions
    EX 02Visualize the semester app ideaLoading the exercise…

    Part 2: A UI system with NativeWind

    55 min

    How NativeWind works

    NativeWind lets React Native components use Tailwind-style utilities through className. They become native styles — not browser CSS. Read the classes left to right:

    <View className="flex-1bg-slate-950px-6pt-12">
    1. flex-1flex: 1
    2. bg-slate-950backgroundColor: '#020617'
    3. px-6paddingHorizontal: 24
    4. pt-12paddingTop: 48
    Terminal — add NativeWind to your project
    npx expo install nativewind react-native-reanimated react-native-safe-area-context
    then follow the NativeWind guide for your installed version (tailwind.config.js, global.css, babel/metro)
    npx expo start --clear

    Tip

    Before styling the whole app, prove the setup works: put className="bg-emerald-300" on one View. If it turns green, continue.

    Design with a system, not decoration

    Hierarchy

    text-3xl font-bold vs text-sm text-slate-400: what is read first.

    Rhythm

    gap-4, p-6: one spacing scale everywhere.

    Surface

    rounded-2xl border bg-slate-900: group related content.

    Feedback & state

    active:opacity-70, disabled:opacity-40: show what is happening.

    Platform

    ios:pt-12 android:pt-8: adapt on purpose.

    EX 03Classes with a purposeLoading the exercise…

    Tokens, primitives and feature components

    Split every screen into layout, reusable UI primitives (components/ui) and data-aware feature components (features/<name>/components). Keep colours, spacing and radius in one place:

    export const colors = {
      background: '#0B1020', surface: '#151C31', text: '#F8FAFC',
      muted: '#94A3B8', primary: '#7CFFB2', danger: '#FB7185',
    } as const;
    export const spacing = { xs: 4, sm: 8, md: 16, lg: 24, xl: 32 } as const;
    export const radius = { sm: 8, md: 14, pill: 999 } as const;

    A primitive owns its look, feedback, state and accessibility; the feature only decides what happens on press. Prefer one variant prop over many booleans, and keep business data out of ui/.

    ● LIVE DEMOA small UI system: tokens, a primitive and a screenLoading the editor and preview…
    EX 04Accessible save cardLoading the exercise…
    EX 05Fix the AppButton primitiveLoading the exercise…

    CheckpointUI system ready

    You have theme tokens, a shared AppButton with typed props, pressed feedback, a disabled state and accessibility semantics — and screens built from them.

    Part 3: Feature architecture & aliases

    35 min

    Organize by feature, not by file type

    Keep each feature’s screens, components, hooks, API calls and types together. Extract shared code only when several features need it.

    Example. The TA asks: “add a ‘128 going’ counter to events.” Which folders do you open?

    ❌ by file type — 4 folders
    • screens/
    • EventListScreen.tsx
    • LoginScreen.tsx
    • ProfileScreen.tsx
    • components/
    • EventCard.tsx
    • Avatar.tsx
    • hooks/
    • useEvents.ts
    • api/
    • events.ts
    • auth.ts
    ✅ by feature — 1 folder
    • features/
    • events/everything for events
    • screens/EventListScreen.tsx
    • components/EventCard.tsx
    • hooks/useEvents.ts
    • api.ts
    • auth/
    • profile/

    Same files, but by feature everything for one change is in one folder — and you can’t break login by accident.

    src
    • app/
    • navigation/the shell: navigators, linking
    • components/
    • ui/AppButton, Card, Input — no business data
    • features/
    • auth/screens/, components/, api.ts, types.ts
    • events/screens/, components/, hooks/, api.ts
    • profile/screens/, components/, api.ts, types.ts
    • services/httpClient.ts, storage.ts
    • theme/tokens.ts

    One-way imports

    Features may import shared code. Shared code never imports a feature — that prevents cycles.

    Clear ownership

    A teammate looking for “the events code” opens one folder.

    No dumping grounds

    A giant components/, screens/ and utils/ hides who owns what as the app grows.

    EX 06Where does each file live?Loading the exercise…
    EX 07Which imports are allowed?Loading the exercise…

    Relative paths vs the @/ alias

    An import path tells Metro where the file is. There are two ways to write it — like giving someone directions vs giving them an address:

    Directions (relative): “From my room, go out, down one floor, the kitchen is on the left.” Works only if you start in my room.

    Address (alias): “12 Nile Street, flat 4.” Works from anywhere.

    Here are both ways to the same file. Folders are drawn as boxes inside boxes: .. steps out of a box, @/ jumps to src/, and each name steps into a box. Press Play all, then switch to @/:

    📁 src
    📁 components
    📁 ui📄 AppButton.tsx
    📁 features
    📁 profile
    📁 screens📄 ProfileScreen.tsx you are here

    ../../../components/ui/AppButton@/components/ui/AppButton
    Starts fromthe file you are insrc/, always
    Steps3 out + 3 in = 61 jump + 3 in = 4
    Move ProfileScreen one folder deeper❌ breaks — needs ../../../../✅ still works
    Best fora neighbour in the same feature: ../apishared code across the app

    Relative: ./ and ../

    Directions from the file you are in. ./ = this folder, ../ = one folder up. Short for neighbours, but ../../../ is hard to read and breaks when the file moves.

    Alias: @/

    An address from src/, the same from every file: @/components/ui/AppButton. Moving the importing file changes nothing.

    The rule

    Inside one feature → ./ or ../. Across boundaries (shared UI, theme, services) → @/.

    Pick what ProfileScreen.tsx imports and watch the path walk the folders. Then move the file:

    ./ this folder../ one folder up@/ start at src/
    1. src
    2. components
    3. ui
    4. AppButton.tsx
    5. features
    6. events
    7. components
    8. EventCard.tsx
    9. profile
    10. api.ts
    11. screens
    12. ProfileScreen.tsx
    13. edit
    14. ProfileScreen.tsx
    15. theme
    16. tokens.ts

    Relative path from

      Alias path (same from anywhere)

      A relative path is directions from where the file is. @/ is an address from src/: it never changes when the file moves.

      Now try both kinds in a real project. Open each file tab, then follow the Try suggestions and read the errors:

      ● LIVE DEMOBoth kinds of import in one real screenLoading the editor and preview…

      @/ is not built in — you define it once in tsconfig.json. "@/*": ["src/*"] means: replace @/ with src/. Expo’s bundler reads the same setting, so TypeScript and the running app agree.

      {
        "extends": "expo/tsconfig.base",
        "compilerOptions": {
          "strict": true,
          "baseUrl": ".",
          "paths": { "@/*": ["src/*"] }
        }
      }
      Terminal
      npx expo start --clear
      restart Metro after changing tsconfig paths
      Bundler cache cleared
      EX 08Replace fragile paths with @/Loading the exercise…

      Part 4: Typed navigation

      55 min

      You already use all three

      Stack — the Settings app

      Settings → Wi-Fi → your network. Each tap goes deeper; Back returns one step.

      Tabs — WhatsApp’s bottom bar

      Chats · Updates · Calls: a few equal places, one tap apart, each keeps its scroll position.

      Drawer — Gmail’s ☰ menu

      Sent, Drafts, Spam, Settings: many, occasional places hidden until you need them.

      Stack, tabs or drawer?

      Choose by how the user moves. Switch between the three patterns and tap inside the phone:

      Events

      Last call

      —

      History

        Tap inside the phone. Watch what the Back button would do: that is the question every navigation choice answers.
        EX 09Stack, tabs or drawer?Loading the exercise…

        Note

        Expo Router (Lab 02) is built on React Navigation. This lab uses the React Navigation API directly so you see every piece. In an Expo Router project, don’t add a NavigationContainer — the same ideas become layouts: <Stack />, <Tabs /> and <Drawer /> in app/…/_layout.tsx, and route params come from useLocalSearchParams().

        Terminal — install the navigators
        npm install @react-navigation/native @react-navigation/native-stack @react-navigation/bottom-tabs @react-navigation/drawer
        npx expo install react-native-screens react-native-safe-area-context react-native-gesture-handler react-native-reanimated
        restart Expo after native dependency changes

        How the pieces fit

        NavigationContainer

        Holds the navigation state of the whole app. One, at the root.

        Navigator

        Stack, Tab or Drawer. Draws the header or tab bar and remembers the history.

        Screen

        A name to navigate to + the component to draw. It receives navigation and route as props.

        Your first navigator

        The smallest working example: two screens and one parameter. Read the 4 numbered comments, run it, then follow the Try suggestions:

        ● LIVE DEMOYour first navigator: two screens, one parameterLoading the editor and preview…

        Now step through what happened when you tapped the event:

        <NavigationContainer>  <Stack.Navigator>    <Stack.Screen name="Home" component={HomeScreen} />    <Stack.Screen name="Details" component={DetailsScreen} />  </Stack.Navigator></NavigationContainer> function HomeScreen({ navigation, route }) {  … onPress={() => navigation.navigate('Details', { itemId: 'e42' })}}function DetailsScreen({ route }) {  return <Text>Event {route.params.itemId}</Text>;}
        ‹ BackHome
        Coding nightCampus Fair
        { itemId: 'e42' }

        History

          Props of the screen on top

          1 / 7NavigationContainer

          Holds the navigation state for the whole app. Exactly one, at the root.

          Params: how does a screen know which item?

          Think of a shopping app. It sells hundreds of products, but there is only one Product screen. When you tap the headphones, how does that screen know to show headphones and not shoes?

          The list sends a small ticket with the product’s id. The Product screen reads the ticket and finds the product. Tap a product:

          Shop
          1. 1
            Send — the list screen says which product was tappednavigation.navigate('Product', { productId: '…' })
          2. 2
            Carry — only a small ticket travels, not the whole product{ productId: '…' }
          3. 3
            Read — the Product screen reads the ticket and finds the productroute.params.productId → PRODUCTS.find(…)

          👆 Tap a product in the phone.

          Like the number on a shop’s order ticket: the cashier doesn’t carry the shoe to the stockroom — just its number. The Product screen uses the number to find the right item. One screen, any product.

          Send

          navigation.navigate('Product', { productId: 'p2' }) — the screen name, then a params object.

          Read

          route.params.productId is 'p2' inside the Product screen.

          Why only the id?

          It is small, the screen always shows the latest price and stock, and it also works when the app opens from a link or a notification.

          Now in real code. Add a product, send an id that doesn’t exist, and print what the screen received:

          ● LIVE DEMOA shop: one Product screen for every productLoading the editor and preview…

          Campus Companion works exactly the same way: itemId is the event’s id — navigate('Details', { itemId: 'e42' }) sends it, and Details reads route.params.itemId to find the event.

          Type every route once

          The param list is a contract for every screen:

          Home: undefined

          This screen takes no params.

          Details: { itemId: string }

          Params are required, and itemId must be a string.

          source?: 'search' | 'featured'

          The ? makes it optional; only these two values are allowed.

          NativeStackScreenProps<List, 'Details'>

          Types the props of one screen, so route.params.itemId is known to be a string.

          Pick a call and see what TypeScript says — while you type, before the app runs:

          type RootStackParamList = {
            Home: undefined;                                   // no params
            Details: { itemId: string; source?: 'search' | 'featured' };  // required + optional
            Main: NavigatorScreenParams<MainTabParamList>;     // a nested navigator
          };
          type MainTabParamList = { Feed: undefined; Profile: { userId: string } };

          In your editor (before running)

          Without types, on the phone

          The param list is written once. After that, every navigate() in the project is checked against it — mistakes turn red while you type, instead of crashing in front of a user.

          Never hide a red line with as any: fix the param list or the call.

          import { NavigationContainer } from '@react-navigation/native';
          import { createNativeStackNavigator, type NativeStackScreenProps } from '@react-navigation/native-stack';
          
          export type RootStackParamList = {
            Home: undefined;
            Details: { itemId: string; source?: 'search' | 'featured' };
          };
          
          const Stack = createNativeStackNavigator<RootStackParamList>();
          export type DetailsProps = NativeStackScreenProps<RootStackParamList, 'Details'>;
          
          // navigation.navigate('Details', { itemId: item.id, source: 'search' });
          EX 10A typed stack with a route parameterLoading the exercise…
          EX 11What does each navigation call do?Loading the exercise…

          Tabs for the main areas

          A tab navigator draws one button per Tab.Screen. screenOptions can be a function of the route, so one line gives every tab its own icon. The navigator passes color (green when active) and size:

          <Tab.Navigator screenOptions={({ route }) => ({
            tabBarIcon: ({ color, size }) => <Ionicons name={ICONS[route.name]} color={color} size={size} />,
          })}>
          EX 12Bottom tabs with iconsLoading the exercise…

          Nesting: tabs inside a stack

          A common root is Stack(Auth, MainTabs, Details): the tabs live inside one stack screen. A navigate() call is offered to the screen’s own navigator first, then bubbles up to its parents. Pick a call and watch who handles it:

          NavigationContainer
          Stack.Navigator
          Main · Tab.Navigator
          FeedProfile
          Settings
            A call goes to the screen’s own navigator first, then up to its parents. To reach a screen inside another navigator, name the outer one: navigate('Main', { screen: 'Profile' }).

            Type the nested navigator with NavigatorScreenParams, and nest as little as possible — every navigator adds history and options.

            import type { NavigatorScreenParams } from '@react-navigation/native';
            
            export type MainTabParamList = { Feed: undefined; Profile: { userId: string } };
            export type RootStackParamList = {
              Main: NavigatorScreenParams<MainTabParamList>;
              Details: { itemId: string };
            };
            
            // navigation.navigate('Main', { screen: 'Profile', params: { userId: '42' } });
            ● LIVE DEMOCampus Companion shell: tabs + a stackLoading the editor and preview…
            EX 13Jump into a nested tabLoading the exercise…

            CheckpointNavigation shell

            One NavigationContainer, typed routes and params, and every navigator has a reason you can defend: tabs for equal areas, a stack for drill-down, a drawer only for occasional places.

            Part 5: Dev, staging & production

            35 min

            One codebase, three builds

            Pick an environment and watch what changes:

            Project (Dev)Project (Staging)Project

            3 bundle ids → 3 apps on one phone

            APP_VARIANT
            staging
            App name
            Project (Staging) STAGING
            Bundle id / package
            com.team.project.staging
            EXPO_PUBLIC_API_URL
            https://staging-api.example.com
            eas build --profile
            staging
            Who uses it
            Your TA and testers

            Ships inside the app (anyone can read it)

            EXPO_PUBLIC_APP_ENVEXPO_PUBLIC_API_URL

            Never in the app: server only

            DATABASE_URLSTRIPE_SECRET_KEYSERVICE_ROLE_KEY
            Same code, different identity and public settings. Separating environments never makes client code a safe place for a secret.
            EX 14Public or secret?Loading the exercise…

            Public values with EXPO_PUBLIC_

            Expo inlines every EXPO_PUBLIC_ variable into the app. Use them only for public values such as the API address and the environment name.

            # development
            EXPO_PUBLIC_APP_ENV=development
            EXPO_PUBLIC_API_URL=http://192.168.1.10:3000
            
            # staging
            EXPO_PUBLIC_APP_ENV=staging
            EXPO_PUBLIC_API_URL=https://staging-api.example.com
            
            # production
            EXPO_PUBLIC_APP_ENV=production
            EXPO_PUBLIC_API_URL=https://api.example.com

            Caution

            Never put database passwords, service-role keys or private API secrets in a mobile app — EXPO_PUBLIC_ means public. Commit .env.example; ignore the real .env* files. Keep secrets on a server.

            Give each build its own identity

            An app variant sets the display name, the bundle identifier / package and the API environment, so all three builds can sit side by side on one phone.

            import type { ExpoConfig } from 'expo/config';
            
            const variant = process.env.APP_VARIANT ?? 'development';
            const production = variant === 'production';
            const staging = variant === 'staging';
            
            export default <ExpoConfig>{
              name: production ? 'Project' : staging ? 'Project (Staging)' : 'Project (Dev)',
              slug: 'project',
              ios: { bundleIdentifier: production ? 'com.team.project' : `com.team.project.${variant}` },
              android: { package: production ? 'com.team.project' : `com.team.project.${variant}` },
            };
            {
              "build": {
                "development": { "developmentClient": true, "distribution": "internal", "env": { "APP_VARIANT": "development" } },
                "staging": { "distribution": "internal", "env": { "APP_VARIANT": "staging" } },
                "production": { "autoIncrement": true, "env": { "APP_VARIANT": "production" } }
              }
            }
            EX 15Make the environment visibleLoading the exercise…

            Part 6: Sprint 01 deliverable

            10 min

            Apply the lab to your semester app — not a throwaway example. Start in the lab; finish before next week’s lab.

            TASK 6.1

            Build the project foundation on your branch

            5 min

            Your branch must contain:

            • docs/product-brief.md and the screen map
            • The NativeWind design language and two polished screens
            • Feature-based src/ folders and @/ aliases
            • A typed navigation shell with at least one real route parameter
            • Development, staging and production examples with no secrets (.env.example, app.config.ts, eas.json)
            • A README section called Sprint 01 — Architecture decisions: why these navigators, this folder structure and these tokens
            you are here
            Commit and push
            git switch -c feature/app-architecture
            git add docs src app.config.ts eas.json .env.example tsconfig.json README.md
            git commit -m "Sprint 01: brief, UI system, architecture, navigation, environments"
            git push -u origin feature/app-architecture
            TASK 6.2

            Architecture and product review

            5 min

            Before you open the pull request, review it as a team:

            • Is the user problem specific and stable enough for the semester?
            • Can a teammate find one feature in under 10 seconds?
            • Does NativeWind give clear hierarchy and consistent spacing?
            • Do @/ aliases resolve in both TypeScript and Metro?
            • Are all routes and params typed, with no as any?
            • Can the three variants coexist on one phone — and is there no secret in the app?
            • Are loading, empty, error and disabled states designed?

            Merge through a pull request, then paste the repository link for your TA:

            CheckpointSprint 01 complete

            Your semester app has a brief, a design language, a feature architecture, a typed navigation shell and three safe environments — the foundation every later lab builds on. 🚀

            Stuck?

            "Couldn't find a navigation context" or "Couldn't find a navigation container"
            Cause

            A navigator or useNavigation() is used outside <NavigationContainer>.

            Fix

            Wrap the root navigator in exactly one <NavigationContainer>. With Expo Router, do not add one — it is already there.

            "The action NAVIGATE with payload … was not handled by any navigator"
            Cause

            The screen name is misspelled, or it lives in a nested navigator.

            Fix

            Check the name of the Screen. For a nested screen use navigate('Parent', { screen: 'Child' }).

            @/… imports fail with "Unable to resolve module"
            Cause

            Metro still uses the old configuration.

            Fix

            Check "paths": { "@/*": ["src/*"] } in tsconfig.json, then restart with a clean cache.

            Run
            npx expo start --clear
            NativeWind classes do nothing
            Cause

            The NativeWind setup is incomplete for your installed version.

            Fix

            Follow the official installation guide for your version step by step, then test className="bg-emerald-300" on one View.

            process.env.EXPO_PUBLIC_… is undefined
            Cause

            The variable lacks the EXPO_PUBLIC_ prefix, or Metro started before the .env file changed.

            Fix

            Use the prefix and restart Expo.

            Run
            npx expo start --clear

            Still stuck? Search the troubleshooting center or ask your TA.

            Submission

            • All 15 interactive exercises show Solved
            • Your team repository with docs/product-brief.md, the feature-based src/ structure, @/ aliases and a typed navigation shell
            • .env.example, app.config.ts and eas.json with three variants and no secrets
            • A README section called Sprint 01 — Architecture decisions, merged into main through a pull request
            Optional

            Extra challenge

            Add a dark mode: define a dark set of tokens, switch with useColorScheme(), and use NativeWind dark: classes on two screens.

            Resources

            End of lab · attendance

            Check in for Lab 03

            Checking whether check-in is open…