react/react-native
End-to-end: Metro prepends react-native/setup-env to every bundle; setUpDefaultReactNativeEnvironment installs globals then requires AppRegistry; the native side calls AppRegistry.runApplication which resolves the registered runnable and renders through RendererProxy into ReactFabric; Fabric commits to the C++ shadow tree (ReactCommon/react/renderer) and mounts to platform views. Native capabilities are reached through TurboModuleRegistry (__turboModuleProxy with BatchedBridge fallback); native-to-JS calls go through BatchedBridge callFunctionReturnFlushedQueue and DeviceEventEmitter. Native interfaces are declared as JS specs that codegen turns into C++/ObjC++/Java at build time. Feature flags are authored once and generated into JS/Java/C++ accessors.
- Metro serializer getModulesRunBeforeMainModule injects 'react-native/setup-env' before the app entry on every bundle; InitializeCore.js is kept as a deprecated alias that simply requires ../../src/setup-env so it stays in the module graph.
- setUpDefaultReactNativeEnvironment runs a fixed require order — setUpGlobals, setUpDOM, setUpPerformance, polyfillPromise, setUpTimers, [DEV] setUpReactDevTools, setUpErrorHandling, setUpRegeneratorRuntime, setUpXHR, setUpAlert, setUpNavigator, setUpBatchedBridge, setUpSegmentFetcher, [DEV] checkNativeVersion/setUpDeveloperTools/LogBox.install — then requires AppRegistry and conditionally installs the three observers. A module-level `initialized` flag makes it idempotent.
- App launch data flow: JS calls AppRegistry.registerComponent(appKey, provider) which stores a runnable in the `runnables` map; native invokes runApplication(appKey, appParameters) over the bridge; the runnable calls renderApplication which wraps RootComponent in AppContainer (plus optional React.unstable_Activity wrapper) and calls Renderer.renderElement with createRootTag(rootTag).
- RendererProxy re-exports RendererImplementation, which resolves to Libraries/Renderer/implementations/ReactFabric-{dev,prod,profiling}.js; the proxy indirection exists so bundles can swap the Fabric renderer variant (profiling vs production) at runtime.
- TurboModule resolution: TurboModuleRegistry.get/getEnforcing first calls global.__turboModuleProxy(name); on miss it falls back to NativeModules[name] (the BatchedBridge-generated module object); getEnforcing throws an invariant naming the module when neither yields a result.
- Legacy-bridge module calls: NativeModules.genModule builds each method via genMethod (typed 'async'|'promise'|'sync' from the ModuleConfig tuple [name, constants, methods, promiseMethodIDs, syncMethodIDs]) which enqueues onto BatchedBridge/MessageQueue.enqueueNativeCall; RCT/RK prefixes must already be stripped natively (invariant).
- Native -> JS direction: registerCallableModule exposes JS modules to native through BatchedBridge (AppRegistry itself is registered this way at module load, alongside global.RN$AppRegistry); RCTDeviceEventEmitter/NativeAppEventEmitter deliver native events into JS.
- Codegen flow: `Native*.js` and `*NativeComponent.js` spec files -> @react-native/codegen parsers (flow/typescript) -> CodegenSchema -> RNCodegen.generate -> LIBRARY_GENERATORS buckets (componentsIOS, componentsAndroid, modulesIOS, modulesAndroid, modulesCxx, descriptors, events, props, states, shadow-nodes, tests) -> writeMapToFiles or checkFilesForChanges (verify mode when test:true).
- Codegen is invoked three ways: `react-native codegen` CLI -> scripts/codegen/generate-artifacts-executor.execute(path, platform, outputPath, source); Android Gradle via GenerateCodegenSchemaTask + GenerateCodegenArtifactsTask in the react-native-gradle-plugin; iOS via scripts/generate-codegen-artifacts.js inside the pod build phases.packages/community-cli-plugin/src/commands/codegen.js#L44-60packages/react-native/scripts/codegen/generate-artifacts-executor/index.jspackages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTask.ktpackages/react-native/scripts/generate-codegen-artifacts.js
- Feature flags: ReactNativeFeatureFlags.config.js is the single source of truth (common/jsOnly scopes, defaultValue, metadata.purpose, expectedReleaseValue, ossReleaseStage); `yarn featureflags` regenerates the JS (src/private/featureflags/ReactNativeFeatureFlags.js), Java and C++ accessors, which gate behavior like the observers at env setup.
- Type pipeline: Flow-typed JS sources -> `yarn build-types` (scripts/js-api using flow-api-translator) -> per-module .d.ts in types_generated/ (generated at build time, referenced by the exports 'types' condition) plus the committed whole-API snapshot ReactNativeApi.d.ts; `yarn test-generated-typescript` type-checks the result against __typetests__.
- UI commit path: ReactFabric renderElement -> C++ shadow tree under ReactCommon/react/renderer (uimanager/scheduler/mounting/runtimescheduler) -> platform mount: Android FabricUIManager (com.facebook.react.fabric) and iOS RCTComponentViewFactory/RCTMountingManager; the JS FabricUIManager.js module is the JS-side handle. (inferred)