How andregbracco/calculator works
Main Components
• JavaScript/React Native Layer:
• Entry Point: The index.js file bootstraps the app and hands it off to Metro, the JS bundler.
• Application Logic & UI: The src folder contains the core presentation layer that includes:
▪ Presentation components (e.g., CalculatorButton, CalculatorScreen).
▪ Hooks and custom logic (e.g., useCalculator in src/presentation/hooks).
▪ Configuration files (e.g., app-theme in src/config).
• Testing: __tests__ folder contains unit tests (e.g., App.test.tsx).
• Native Code & Platform-Specific Layers:
• Android: The android directory contains the native Android entry point, gradle build scripts, and native modules (e.g., MainActivity.kt and MainApplication.kt). This layer interacts with the React Native bridge for communication with the JavaScript layer.
• iOS: The ios directory holds the Xcode project, native configuration (e.g., AppDelegate, Info.plist) and other resources specific to iOS.
• Build & Configuration Tools:
• Metro bundler (referenced in README steps) is the tool that compiles and bundles the JavaScript code.
• ESLint, Prettier, TypeScript configuration, and others ensure code quality and type-safety.
• Dependency files such as package.json, Gemfile, and gradle files indicate the technologies and build processes.
Relationships and Interactions
• The JavaScript/React Native layer acts as the primary application logic exposing UI components that are rendered on both Android and iOS.
• The React Native bridge facilitates communication between the JavaScript runtime and the native modules present in the android and ios layers.
• Metro server (bundler) is an essential early-running process that compiles/bundles the JavaScript code and pushes it to the native runtime.
• The build scripts (Android and iOS specific) compile the native code and include configurations that integrate the React Native bundle.
• Testing components are used to validate functionality of the UI components and hooks independently.
Architectural Patterns and Design Principles
• Separation of Concerns: JavaScript code in the src folder handles UI logic and business logic distinctly, while native code handles platform-specific tasks.
• Componentization: The UI is split into reusable elements (components), keeping the user interface modular.
• MVC/MVVM-like pattern: Although React Native allows flexibility, the separation between presentation (screens, components) and logic (hooks, configuration) is apparent.
• Native Bridge Pattern: The standard React Native architecture uses a bridge for communication between the JavaScript and native sides, which is fundamental in this project.
Technologies/Frameworks
• React Native (JavaScript/TypeScript)
• Metro Bundler
• Native Android (Kotlin) & iOS (Objective-C/Swift and Xcode)
• Testing frameworks (Jest as configured)
• Various build tools (Gradle for Android, Xcode for iOS)