How alexxito23/2fa-vpn-app works
Project type and purpose
• This is a React Native mobile application targeting both Android and iOS.
• Purpose: Provides a UI with Home, Profile and Settings screens, and includes custom hooks (e.g., VPN integration, “sendServer” calls) to interact with external services.
File structure
• Top-level language and config:
• App.tsx, index.js – entry points
• babel.config.js, tsconfig.json, eslint & prettier configs, metro.config.js, package.json – build and linting
• “app” directory (JavaScript/TypeScript business logic):
• hooks/ – custom React hooks for VPN and server communication
• screens/ – UI components (HomeScreen, ProfileScreen, SettingsScreen)
• Native wrappers:
• android/ – full Android Studio project, Java/Kotlin MainActivity, JNI libs, certificates
• ios/ – Xcode project, AppDelegate, Info.plist, asset catalogs
• Tests: __tests__ for unit/UI tests using Jest
• Assets & styling: assets/ (images, fonts), tailwind.config.js & global.css (nativewind)
README for additional insights
• Bootstrapped with React Native CLI
• Uses Metro as the JS bundler
• Standard development flow: Metro → build → emulator/simulator
a. Main components
1. JavaScript Layer
– React Native app code (App.tsx, screens, hooks, components)
2. Metro Bundler
– Transforms JSX/TS → JS bundle
3. Native Runtime
– iOS: Objective-C/Swift bridge (AppDelegate, RN bridge)
– Android: Java/Kotlin bridge (MainActivity, MainApplication)
4. Native Modules & Libraries
– vpnService.tsx (bridged native VPN code)
– jniLibs (C/C++ libraries)
5. External Services
– REST or WebSocket backend (“sendServer”)
– VPN service endpoints
6. Device OS
– Android OS
– iOS SDK
b. Relationships & interactions
• UI screens invoke hooks → hooks call JS APIs → Metro‐bundled code calls RN bridge → native module → OS or external service
• Data flow: User action → React component → Hook logic → Network layer → External API → back to JS state → UI render
c. Architectural patterns & design principles
• MVVM-style separation: Screens (View) + Hooks (ViewModel) + Services (Model/Network)
• Bridge pattern: React Native JS ↔ Native code
• Modular folder structure (isolated concerns)
d. Relevant technologies/frameworks
• React Native (JS runtime, bridge)
• Metro Bundler
• TypeScript, Babel
• Native toolchains: Android Gradle, Xcode/Pods
• NativeWind (Tailwind-style styling)
• Jest for testing
Detail
• Break the JS layer into sub-components (screens, hooks, services)
• Test runner (Jest) as a side component interacting with JS code
• Asset flow (assets → bundler → native resources)