How amritha0503/mini-project works
1) Overall shape
CyberGuard is a Flutter-first Android app with a small amount of native Android glue. There is no bespoke backend service in this repo; Firebase is the cloud boundary for auth, storage, and push messaging. Most behavior, scoring, and presentation logic lives in lib/, while Android-specific lifecycle and background execution are handled under android/app/src/main/kotlin.
2) App bootstrap and composition
lib/main.dart is the Flutter entry point. firebase_options.dart and lib/core/app_config.dart provide environment/Firebase wiring, and the app theme lives in lib/theme/app_theme.dart. The README indicates Riverpod is used for state/dependency management, so the UI is likely composed from injected services rather than direct singleton access.
3) Monitoring subsystem
The core product is passive risk monitoring. The service layer is split by signal type: background_monitor_service.dart, continuous_monitoring_service.dart, network_monitor_service.dart, cross_app_url_monitor.dart, app_safety_service.dart, and email_spam_service.dart. These services detect privacy-safe behavioral events such as unsafe links, suspicious downloads, unknown app installs, weak passwords, and network/security changes.
4) Android lifecycle and background execution boundary
Android native code is used to keep monitoring alive across app restarts and device boots. BootReceiver.kt suggests restart-on-boot behavior, BackgroundMonitorService.kt provides a native service hook, and MainActivity.kt hosts the Flutter runtime. WorkManager is the documented scheduler, running periodic checks roughly every 15 minutes. This is the key boundary between Flutter UI and OS-managed background work.
5) Domain model and event pipeline
The data model layer captures the app’s main domain objects: behavior_event.dart, user_risk_profile.dart, app_usage_session.dart, and spam_email.dart. Monitoring services create events with timestamp, severity, and metadata; those events become the source of truth for risk, trends, and logs.
6) Risk computation
lib/utils/risk_scoring_engine.dart is the central business rule engine. It turns accumulated behavior events into a 0–100 cyber risk score with diminishing returns for repeated events, and then maps that score into LOW / MODERATE / HIGH bands. This engine is called both on new events and during periodic background refreshes.
7) Storage and sync
lib/services/firestore_service.dart is the persistence layer. Firestore appears to store the event history, user risk profile, and trend data that power the dashboard and logs. firestore.rules is an important security boundary for what the client can read/write. The README also mentions cache-first access and offline persistence, so local responsiveness is expected even when connectivity is limited.
8) Alerts and notification delivery
lib/services/notification_service.dart handles on-device notifications, while Firebase Cloud Messaging provides remote alerts. Alerts are triggered by conditions like high risk, suspicious Wi‑Fi, malicious URLs, or background changes. This creates a dual-path notification model: local device alerts for immediate feedback and FCM for remote push events.
9) Presentation layer
The UI is organized by screen in lib/screens/: dashboard, home, login, consent, alerts, behavior log, profile, app safety, app usage, real-time monitor, email spam, and help. The dashboard is the primary composite view, backed by reusable widgets such as risk_score_gauge.dart, trend_chart.dart, recommendation_card.dart, stat_card.dart, risk_block_overlay.dart, and wifi_info_card.dart.
10) User flow and gating
The app flow appears to be: authentication, consent, then monitoring/dashboard. login_screen.dart and consent_screen.dart are explicit gates before the monitoring experience. That matters architecturally because it separates identity and permission setup from ongoing passive analysis.
11) Android and Firebase infrastructure
android/app/google-services.json, firebase_auth, cloud_firestore, and firebase_messaging indicate the Firebase stack is essential to the app’s runtime architecture. Android permissions and network_security_config.xml support network/Wi‑Fi inspection and notifications. The app also uses a foreground/background service model and periodic scheduler rather than a continuously polling loop, which is important for battery behavior.
12) Build, flavors, and delivery
The repo supports dev/prod flavors and a Flutter CI workflow under .github/workflows/flutter_ci.yml. The README notes production disables demo/test attack paths, which means the architecture includes feature gating between presentation/demo behavior and real release behavior.
13) What an architecture diagram should emphasize
The most important boundaries are:
• Flutter UI vs Android OS services
• Monitoring signals vs scoring engine
• Client app vs Firebase persistence/notifications
• Auth/consent gate vs post-consent monitoring
• Local notification path vs remote FCM path
If diagrammed, the central loop is: monitored signal → event model → Firestore/local cache → risk scoring engine → dashboard/recommendations → notifications/alerts.
Main entry points: firestore_service.dart Firestore service · continuous_monitoring_service.dart Continuous monitor · main.dart App entry · dashboard_screen.dart Dashboard
Components 34
Flutter app
Dart-side application, domain logic, UI, and service orchestration.
- App entry · Bootstraps the app and wires top-level composition.
lib/main.dart - App config · Environment and Firebase wiring.
lib/core/app_config.dart - Firebase options · Generated Firebase platform settings.
lib/firebase_options.dart - App theme · Global styling and visual tokens.
lib/theme/app_theme.dart
Android glue
Native lifecycle and background execution boundary.
- Boot receiver · Restarts monitoring after device boot.
android/app/src/main/kotlin/com/cyberriskanalyzer/BootReceiver.kt - Native service · Android background service hook for long-running monitoring.
android/app/src/main/kotlin/com/cyberriskanalyzer/BackgroundMonitorService.kt - Main activity · Hosts the Flutter runtime on Android.
android/app/src/main/kotlin/com/cyberriskanalyzer/MainActivity.kt
Firebase boundary
Cloud persistence, auth, and push messaging integration.
- Firestore rules · Client read/write boundary for persisted app data.
firestore.rules
Presentation
Screens and reusable dashboard widgets.
- Dashboard · Primary overview of risk, trends, and recommendations.
lib/screens/dashboard_screen.dart - Home · Top-level landing and navigation shell.
lib/screens/home_screen.dart - Login · Authentication gate before monitoring starts.
lib/screens/login_screen.dart - Consent · Permission and privacy gate for monitoring.
lib/screens/consent_screen.dart - Alerts · User-facing alert and notification log.
lib/screens/alerts_screen.dart - Behavior log · Historical event timeline and audit view.
lib/screens/behavior_log_screen.dart - Profile · User settings and account state.
lib/screens/profile_screen.dart - App safety · Visibility into app and device safety checks.
lib/screens/app_safety_screen.dart - Usage · App usage and session insights.
lib/screens/app_usage_screen.dart - Live monitor · Real-time monitoring status and signal view.
lib/screens/real_time_monitor_screen.dart - Email spam · Spam analysis and email risk view.
lib/screens/email_spam_screen.dart - Help · User guidance and support content.
lib/screens/help_screen.dart - Dashboard widgets · Reusable dashboard components for scores, trends, cards, and overlays.
lib/widgets/risk_score_gauge.dart
Domain core
Event, risk, and monitoring services.
- Firestore service · Client-side storage and sync for events, trends, and risk state.
lib/services/firestore_service.dart - Notifications · Local on-device alert delivery.
lib/services/notification_service.dart - Background monitor · Coordinates periodic background checks and refreshes.
lib/services/background_monitor_service.dart - Continuous monitor · Runs ongoing passive monitoring workflows.
lib/services/continuous_monitoring_service.dart - Network monitor · Detects suspicious Wi-Fi and network changes.
lib/services/network_monitor_service.dart - URL monitor · Tracks unsafe links across apps and browsing surfaces.
lib/services/cross_app_url_monitor.dart - App safety · Checks app-install and device-safety conditions.
lib/services/app_safety_service.dart - Spam monitor · Analyzes suspicious email and spam signals.
lib/services/email_spam_service.dart - Risk engine · Converts accumulated events into risk score and bands.
lib/utils/risk_scoring_engine.dart - Behavior event · Canonical monitored event with severity and metadata.
lib/models/behavior_event.dart - Risk profile · User-level risk state and derived trends.
lib/models/user_risk_profile.dart - Usage session · App usage timeline and session record.
lib/models/app_usage_session.dart - Spam email · Structured email/spam payload used by detection flows.
lib/models/spam_email.dart
Connections 38
- App entry → App config: uses · Initializes environment and runtime wiring.
- App entry → Firebase options: uses · Loads generated Firebase settings.
- App entry → App theme: applies · Sets the application theme.
- App entry → Home: opens · Starts the user-facing shell.
- App entry → Dashboard: routes · Navigates into the monitoring experience.
- Login → Consent: gates · Authentication precedes consent.
- Consent → Home: unlocks · Monitoring UI becomes available after consent.
- Home → Dashboard: navigates · Primary entry into the app overview.
- Home → Alerts: navigates · Surfaces alert history.
- Home → Profile: navigates · Opens user settings and identity state.
- Dashboard → Dashboard widgets: composes · Uses gauges, charts, cards, and overlays.
- Dashboard → Risk profile: reads · Displays derived user risk state.
- Behavior log → Behavior event: shows · Presents raw monitored events.
- Background monitor → Continuous monitor: orchestrates · Coordinates ongoing passive checks.
- Continuous monitor → Network monitor: includes · Monitors Wi-Fi and network changes.
- Continuous monitor → URL monitor: includes · Detects unsafe link behavior.
- Continuous monitor → App safety: includes · Checks app and device safety conditions.
- Continuous monitor → Spam monitor: includes · Analyzes spam and suspicious email.
- Continuous monitor → Behavior event: emits · Produces canonical risk events.
- Background monitor → Behavior event: refreshes · Feeds periodic checks into event creation.
- Behavior event → Risk engine: scores · Events are the input to risk calculation.
- Risk engine → Risk profile: updates · Derives score and band into profile state.
- Risk engine → Dashboard: drives · Feeds risk, trends, and recommendations.
- Risk engine → Notifications: triggers · High-risk changes can trigger local alerts.
- Firestore service → Behavior event: stores · Persists event history and logs.
- Firestore service → Risk profile: stores · Persists score and trend state.
- Firestore service → Usage session: stores · Persists usage/session records.
- Firestore service → Spam email: stores · Persists email analysis artifacts.
- Firestore service → Firestore rules: constrained by · Read/write access is restricted by rules.
- Notifications → Alerts: feeds · Populates user-visible alert views.
- Boot receiver → Native service: starts · Restarts background execution after boot.
- Native service → Background monitor: bridges · Native Android hook into Flutter monitoring.
- Main activity → App entry: hosts · Android entrypoint for Flutter runtime.
- Firestore service → Dashboard: serves · Supplies data for dashboard views.
- Firestore service → Behavior log: serves · Supplies historical event data.
- Firestore service → App safety: serves · Supplies safety status data.
- Firestore service → Email spam: serves · Supplies spam analysis data.
- Firestore service → Live monitor: serves · Supplies live monitoring state.