How polito/students-app works
Project Type and Purpose
• This is a React Native mobile application (“PoliTO Students App”) targeting iOS and Android platforms.
• It provides students of Politecnico di Torino with features such as agenda, courses, bookings, maps, notifications, messaging and more by calling Polito’s public/internal APIs.
High-Level Architecture Overview
• The system is purely a mobile client (no in-repo backend) that bundles JavaScript/TypeScript code via Metro and interacts at runtime with:
• Native modules (iOS/Android code for push notifications, file system, keychain, etc.)
• External services (Polito RESTful APIs, Firebase, Sentry, asset servers)
• Local storage (AsyncStorage, file system caches)
Main Components
A. Presentation Layer (React Native JS)
• src – Application entry point (App.tsx), navigation containers, screens, feature modules.
• lib/ui – Shared UI component library (buttons, cards, calendar, bottom sheets, etc.).
• Feature subfolders (src/features/*) – Agenda, Courses, Bookings, Places, Services, etc., each with its own components, hooks, contexts, queries and navigation.
B. State & Business Logic
• Context Providers (ApiProvider, PreferencesProvider, DownloadsProvider, etc.)
• Hooks & React-Query-style queries (in src/core/hooks & src/core/queries)
• Migrations & caching services (MigrationService, CourseFilesCacheProvider)
C. Data Layer
• API layer (src/config/api.tsx, ApiContext): HTTP client configuration, base URLs, auth token injection.
• Local persistence: AsyncStorage or file-system for downloaded course files. Keychain for secrets.
D. Native Bridge Layer
• iOS (Objective-C/Swift) & Android (Kotlin/Java) projects under ios/ and android/ – push notifications (Firebase), asset linking, custom native modules.
• React Native bridge (react-native.config.js) connecting JS → Native.
E. External Services
• Polito backend APIs (authentication, data endpoints)
• Firebase (push notifications, remote config if used)
• Sentry (error reporting)
Interactions & Data Flows
• On app start: JS bundle loads, App.tsx initializes providers → ApiProvider fetches config → NavigationContainer mounts.
• User action in UI → Screen component dispatches query hook → ApiContext issues HTTP request → Polito API responds → Data cached in context or local storage → UI re-renders.
• Background downloads (course files) use native file-system module via bridge.
• Push notifications received by native code → forwarded to JS via bridge → Notification hooks update UI.
• Errors caught in JS or native → sent to Sentry.
Architectural Patterns & Principles
• Feature-based modularization: each feature folder encapsulates its UI, data-fetching, state, and navigation.
• Unidirectional data flow: components → hooks/contexts → API/storage → back to components.
• Separation of concerns: lib/ui for generic UI, src/core for cross-cutting logic, src/features for domain functionality.
• Provider pattern: React Contexts wrap the app to supply dependencies.
Technologies & Frameworks to Annotate
• React Native + TypeScript
• Metro bundler
• React Navigation
• React Context & Hooks
• Babel, ESLint, Prettier, Husky (pre-commit)
• Fastlane (iOS/Android CI)
• Gradle (Android), CocoaPods (iOS)
• Firebase SDK, Sentry SDK
Final Advice
• React Native bridge – that is the heart of integration between JS and native subsystems.
• Core architectural elements: Presentation → Business Logic → Data → Native Bridge → External Services.
• Do not overload with every single file; group by folder and functionality. This balance yields clarity and accuracy.