# rachitnaruzu/resultnotifier architecture

> Architecture diagram of the GitHub repository rachitnaruzu/resultnotifier, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rachitnaruzu/resultnotifier
- Repository: https://github.com/rachitnaruzu/resultnotifier

## Overview

##### Project type and purpose
- This is a full-stack “ResultNotifier” system consisting of:
- An Android mobile client (Gradle/Android Studio)
- A Python backend (WSGI app behind nginx/uwsgi)
- A PostgreSQL database
- Scheduled jobs (cron) for scraping and updating data
- Push notifications via FCM/GCM
- Purpose: scrape/ingest university results, notices, schedules; store and surface them through a mobile UI; push real-time notifications to users.

##### File structure
- Top-level “app” directory: Android client
- src/main/java/com/resultnotifier/main/…
– ui (Activities, Fragments, Adapters)
– service (HTTP client wrappers)
– notification (FCM services)
– downloader, loader (data fetching abstractions)
– db (SQLite/DB manager)
– util, config, state classes
- build.gradle, AndroidManifest.xml, res/ (layouts, drawables, animators, values)
- Top-level “backend” directory: Python service
- config.py (settings)
- databaseutil.py (DB helpers)
- extractbeta.py (web-scrape fetcher)
- main.py, wsgi.py (WSGI entrypoints)
- notification.py, registration.py (push logic)
- seed.py, update_recent_viewed.py (initial data & trending updates)
- nginx/uwsgi config files, requirements.txt
- images/ for README screenshots

##### README insights
- Backend uses PostgreSQL, uWSGI & nginx, cron jobs scheduled via crontab
- Mobile uses GCM_API_KEY, SECRET_KEY matching backend for auth
- Workflow: seed DB → scrape new data → push via notification.py → update trending → mobile fetches via REST

##### Main components & interactions
a. Android Mobile App
- UI Layer (Activities/Fragments) ←→ Data Loader layer
- Service layer (CustomRequest, MyHTTPHandler) calls REST API
- Local storage (SQLite via DatabaseManager, SharedPreferences)
- FCM services (FCMMessagingService, token handling) receive push
b. Backend Web Service
- nginx → uWSGI → WSGI Python app (main.py/wsgi.py)
- REST endpoints (registration, fetch data) implemented in registration.py, main.py
- Business logic in notification.py, update_recent_viewed.py
- Database access via databaseutil.py to PostgreSQL
- extractbeta.py fetches raw data from external sources
c. External Services
- PostgreSQL database
- Google FCM/GCM push endpoint
d. Scheduled Jobs (cron)
- notification.py (hourly push)
- update_recent_viewed.py (every 5 minutes)
- extractbeta.py invoked from seed or cron to fetch new data

##### Architectural patterns & design principles
- Android client uses an MVC/MVP-style layering: UI ↔ Loaders ↔ Network Service ↔ Persistence
- Backend is a layered web application: HTTP routing → business logic → data access
- Asynchronous decoupling: scheduled jobs update DB and trigger notifications out-of-band from user requests
- Configuration-driven: config.py and CommonUtility.java both hold shared SECRET_KEY, domain, API keys
- Infra layering: nginx reverse proxy → uWSGI application server → Python WSGI

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile App Layer
    subgraph "Mobile App" 
        direction TB
        UI["Android UI Layer"]:::mobile
        subgraph "Service & Loader Layer"
            direction TB
            Downloader["Downloader"]:::mobile
            ServiceClient["Service Client"]:::mobile
            DataLoaders["Data Loaders"]:::mobile
        end
        subgraph "Local Storage"
            direction TB
            SQLite["SQLite (DatabaseManager)"]:::persistence
            Prefs["SharedPreferences"]:::persistence
        end
        subgraph "FCM Services"
            direction TB
            FCMMessaging["FCM Messaging Service"]:::mobile
            TokenReceiver["FCMTokenReceiverService"]:::mobile
            TokenUpdater["FCMTokenUpdaterService"]:::mobile
        end
        subgraph "Config & Utils"
            direction TB
            Config["Config"]:::mobile
            CommonUtil["CommonUtility"]:::mobile
        end
    end

    %% Backend Infrastructure
    subgraph "Backend Infrastructure"
        direction TB
        NGINX["nginx (reverse proxy)"]:::backend
        UWSGI["uWSGI Application Server"]:::backend
        subgraph "WSGI Application"
            direction TB
            WSGIEntry["WSGI Entrypoints"]:::backend
            Registration["Registration Endpoint"]:::backend
            NotificationLogic["Push Notification Logic"]:::backend
            Scraper["Web Scraper"]:::backend
            DBHelpers["Database Helpers"]:::backend
        end
        subgraph "Scheduler (cron)"
            direction TB
            Seed["Seed Job"]:::backend
            Trending["Trending Update Job"]:::backend
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Postgres["PostgreSQL Database"]:::persistence
    end

    %% External Services
    subgraph "External Services"
        direction TB
        ExtData["External Data Sources"]:::external
        FCMEndpoint["FCM/GCM Push Endpoint"]:::external
    end

    %% Connections
    UI -->|uses| Downloader
    Downloader -->|loads| UI
    ServiceClient -->|calls API| NGINX
    DataLoaders --> SQLite
    DataLoaders --> Prefs
    FCMMessaging -->|updates UI| UI
    FCMEndpoint -.->|push| FCMMessaging
    NGINX -->|HTTP:80/443| UWSGI
    UWSGI -->|WSGI call| WSGIEntry
    WSGIEntry -->|handles| Registration
    WSGIEntry -->|handles| NotificationLogic
    WSGIEntry -->|handles| Scraper
    Registration -->|reads/writes| Postgres
    NotificationLogic -->|reads/writes| Postgres
    NotificationLogic -->|push| FCMEndpoint
    Scraper -->|FETCH| ExtData
    Scraper -->|writes| Postgres
    DBHelpers -->|access| Postgres
    Seed -.->|cron| WSGIEntry
    Seed -->|initializes| Postgres
    Trending -.->|cron| WSGIEntry
    Trending -->|updates| Postgres

    %% Click Events
    click UI "https://github.com/rachitnaruzu/resultnotifier/tree/master/app/src/main/java/com/resultnotifier/main/ui"
    click Downloader "https://github.com/rachitnaruzu/resultnotifier/tree/master/app/src/main/java/com/resultnotifier/main/downloader"
    click ServiceClient "https://github.com/rachitnaruzu/resultnotifier/tree/master/app/src/main/java/com/resultnotifier/main/service"
    click DataLoaders "https://github.com/rachitnaruzu/resultnotifier/tree/master/app/src/main/java/com/resultnotifier/main/loader"
    click SQLite "https://github.com/rachitnaruzu/resultnotifier/blob/master/app/src/main/java/com/resultnotifier/main/db/DatabaseManager.java"
    click Prefs "https://github.com/rachitnaruzu/resultnotifier/blob/master/app/src/main/java/com/resultnotifier/main/SharedPreferencesKeys.java"
    click FCMMessaging "https://github.com/rachitnaruzu/resultnotifier/blob/master/app/src/main/java/com/resultnotifier/main/notification/FCMMessagingService.java"
    click TokenReceiver "https://github.com/rachitnaruzu/resultnotifier/blob/master/app/src/main/java/com/resultnotifier/main/notification/FCMTokenReceiverService.java"
    click TokenUpdater "https://github.com/rachitnaruzu/resultnotifier/blob/master/app/src/main/java/com/resultnotifier/main/notification/FCMTokenUpdaterService.java"
    click Config "https://github.com/rachitnaruzu/resultnotifier/blob/master/app/src/main/java/com/resultnotifier/main/Config.java"
    click CommonUtil "https://github.com/rachitnaruzu/resultnotifier/blob/master/app/src/main/java/com/resultnotifier/main/CommonUtility.java"
    click NGINX "https://github.com/rachitnaruzu/resultnotifier/blob/master/backend/resultnotifier_nginx.conf"
    click UWSGI "https://github.com/rachitnaruzu/resultnotifier/blob/master/backend/resultnotifier_uwsgi.ini"
    click UWSGI "https://github.com/rachitnaruzu/resultnotifier/blob/master/backend/resultnotifier_uwsgi.conf"
    click UWSGI "https://github.com/rachitnaruzu/resultnotifier/tree/master/backend/uwsgi_params"
    click WSGIEntry "https://github.com/rachitnaruzu/resultnotifier/blob/master/backend/main.py"
    click WSGIEntry "https://github.com/rachitnaruzu/resultnotifier/blob/master/backend/wsgi.py"
    click Registration "https://github.com/rachitnaruzu/resultnotifier/blob/master/backend/registration.py"
    click NotificationLogic "https://github.com/rachitnaruzu/resultnotifier/blob/master/backend/notification.py"
    click Scraper "https://github.com/rachitnaruzu/resultnotifier/blob/master/backend/extractbeta.py"
    click DBHelpers "https://github.com/rachitnaruzu/resultnotifier/blob/master/backend/databaseutil.py"
    click Seed "https://github.com/rachitnaruzu/resultnotifier/blob/master/backend/seed.py"
    click Trending "https://github.com/rachitnaruzu/resultnotifier/blob/master/backend/update_recent_viewed.py"
    click Postgres "https://github.com/rachitnaruzu/resultnotifier/blob/master/backend/config.py"
    click ExtData "https://github.com/rachitnaruzu/resultnotifier/blob/master/backend/requirements.txt"

    %% Styles
    classDef mobile fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef persistence fill:#FFA500,stroke:#333,stroke-width:1px;
    classDef external fill:#FFFF00,stroke:#333,stroke-width:1px;
```
