# thesangamx/student-marks-predictor architecture

> Architecture diagram of the GitHub repository thesangamx/student-marks-predictor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thesangamx/student-marks-predictor
- Repository: https://github.com/thesangamx/student-marks-predictor

## Overview

#### Purpose and Entry Points
Student Marks Predictor serves one serialized scikit-learn pipeline as a REST prediction service, with browser and Android clients. Runtime entry points are FastAPI in `backend/main.py`, Streamlit in `backend/streamlit_app.py`, and the Android launcher/UI in `android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/MainActivity.kt`.

#### Training-to-Artifact Boundary
The offline ML workflow starts from `data/students_data.csv` and is documented/implemented for exploration and training in `notebook/Student_Marks_Prediction.ipynb`. It produces the deployable artifact `backend/model/final_exam_predictor_model.joblib`. Training is not part of request handling; serving consumes the already-built artifact.

#### Prediction Pipeline
The artifact is a complete scikit-learn pipeline: numerical scaling, categorical one-hot encoding, and linear regression. This is the central compatibility boundary: clients submit raw values for all 18 student attributes, while preprocessing schema and inference stay encapsulated in `backend/model/final_exam_predictor_model.joblib`, rather than being duplicated by clients.

#### API Serving Layer
`backend/main.py` owns the FastAPI contract: a status route and `POST /predict`. It validates incoming JSON through Pydantic, converts accepted feature values into a Pandas DataFrame, invokes the loaded Joblib pipeline, and returns predicted final marks as JSON. Dependencies and serving/runtime libraries are declared in `backend/requirements.txt`; Uvicorn hosts the ASGI application and FastAPI supplies OpenAPI/Swagger documentation.

#### Web Client Flow
`backend/streamlit_app.py` is a separate Streamlit process and HTTP client, not an embedded inference UI. It collects browser form inputs, sends them to the FastAPI `/predict` endpoint, then renders the returned prediction. The web app and API can be deployed independently, but must preserve the same raw request schema.

#### Android Client Flow
The native Android app collects and renders prediction state in `android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/MainActivity.kt`. Its request and response boundary is represented by `android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/StudentData.kt` and `android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/PredictionResponse.kt`. Retrofit configuration/client construction in `android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/ApiClient.kt` and endpoint declaration in `android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/ApiService.kt` issue asynchronous HTTP calls to FastAPI; no model runs on device.

#### Deployment and External Boundaries
The intended production topology is FastAPI/Uvicorn on Ubuntu in AWS EC2, managed as a systemd service, consumed by Streamlit and Android over HTTP. The Android manifest at `android-app/app/src/main/AndroidManifest.xml` carries the network boundary (Internet access and current cleartext HTTP support). Android is packaged through Gradle under `android-app/`, with a release bundle present at `android-app/app/release/app-release.aab` for Google Play distribution. The principal operational risk is the current HTTP/cleartext API transport; HTTPS, authentication, and observability are future hardening concerns.

Main entry points: [`backend/main.py`](https://github.com/thesangamx/student-marks-predictor/blob/main/backend/main.py) (FastAPI API), [`android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/MainActivity.kt`](https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/MainActivity.kt) (Android UI), [`backend/model/final_exam_predictor_model.joblib`](https://github.com/thesangamx/student-marks-predictor/blob/main/backend/model/final_exam_predictor_model.joblib) (Serialized predictor), [`android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/ApiClient.kt`](https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/ApiClient.kt) (Retrofit client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Offline training"]
  node_dataset[("Student dataset<br/>CSV data<br/>[students_data.csv]")]
  node_training_notebook["Training notebook<br/>ML workflow"]
  node_model_artifact[("Serialized predictor<br/>Joblib pipeline")]
end

subgraph group_serving["Prediction service"]
  node_fastapi_app["FastAPI API<br/>ASGI application<br/>[main.py]"]
  node_request_validation["Request validation<br/>Pydantic schema<br/>[main.py]"]
  node_inference_adapter["Inference adapter<br/>Pandas + pipeline call<br/>[main.py]"]
  node_runtime_deps["Serving dependencies<br/>Python requirements<br/>[requirements.txt]"]
  node_uvicorn{{"Uvicorn<br/>ASGI host"}}
  node_ec2_service{{"EC2 systemd deployment<br/>Ubuntu service"}}
end

subgraph group_clients["Clients"]
  node_streamlit_app["Streamlit web client<br/>Browser UI<br/>[streamlit_app.py]"]
end

subgraph group_android["Android app"]
  node_main_activity["Android UI<br/>Activity<br/>[MainActivity.kt]"]
  node_android_models["Android API models<br/>Request/response DTOs<br/>[StudentData.kt]"]
  node_prediction_response["Prediction response<br/>Response DTO"]
  node_retrofit_client["Retrofit client<br/>HTTP client<br/>[ApiClient.kt]"]
  node_api_service["API endpoint interface<br/>Retrofit service<br/>[ApiService.kt]"]
  node_android_manifest["Android network policy<br/>Manifest"]
  node_release_bundle["Play release bundle<br/>Android App Bundle<br/>[app-release.aab]"]
end

node_dataset -->|"training data"| node_training_notebook
node_training_notebook -->|"produces"| node_model_artifact
node_model_artifact -->|"loaded at serving"| node_fastapi_app
node_fastapi_app -->|"validates request"| node_request_validation
node_request_validation -->|"accepted features"| node_inference_adapter
node_inference_adapter -->|"predicts with"| node_model_artifact
node_runtime_deps -.->|"declares runtime"| node_fastapi_app
node_uvicorn -->|"hosts"| node_fastapi_app
node_ec2_service -->|"runs"| node_uvicorn
node_streamlit_app -->|"HTTP POST /predict"| node_fastapi_app
node_main_activity -->|"uses request data"| node_android_models
node_main_activity -->|"renders result"| node_prediction_response
node_android_models -->|"serialized request"| node_retrofit_client
node_retrofit_client -->|"creates"| node_api_service
node_api_service -->|"async HTTP /predict"| node_fastapi_app
node_prediction_response -->|"prediction state"| node_main_activity
node_android_manifest -.->|"permits network / cleartext HTTP"| node_retrofit_client
node_release_bundle -->|"packages"| node_main_activity

click node_dataset "https://github.com/thesangamx/student-marks-predictor/blob/main/data/students_data.csv"
click node_training_notebook "https://github.com/thesangamx/student-marks-predictor/blob/main/notebook/Student_Marks_Prediction.ipynb"
click node_model_artifact "https://github.com/thesangamx/student-marks-predictor/blob/main/backend/model/final_exam_predictor_model.joblib"
click node_fastapi_app "https://github.com/thesangamx/student-marks-predictor/blob/main/backend/main.py"
click node_request_validation "https://github.com/thesangamx/student-marks-predictor/blob/main/backend/main.py"
click node_inference_adapter "https://github.com/thesangamx/student-marks-predictor/blob/main/backend/main.py"
click node_runtime_deps "https://github.com/thesangamx/student-marks-predictor/blob/main/backend/requirements.txt"
click node_streamlit_app "https://github.com/thesangamx/student-marks-predictor/blob/main/backend/streamlit_app.py"
click node_main_activity "https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/MainActivity.kt"
click node_android_models "https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/StudentData.kt"
click node_prediction_response "https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/PredictionResponse.kt"
click node_retrofit_client "https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/ApiClient.kt"
click node_api_service "https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/ApiService.kt"
click node_android_manifest "https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/src/main/AndroidManifest.xml"
click node_release_bundle "https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/release/app-release.aab"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dataset,node_training_notebook,node_model_artifact toneBlue
class node_fastapi_app,node_request_validation,node_inference_adapter,node_runtime_deps,node_uvicorn,node_ec2_service toneAmber
class node_streamlit_app toneMint
class node_main_activity,node_android_models,node_prediction_response,node_retrofit_client,node_api_service,node_android_manifest,node_release_bundle toneRose
```

## Components

### Offline training

Builds the serialized model artifact.

- [Student dataset](https://github.com/thesangamx/student-marks-predictor/blob/main/data/students_data.csv): CSV data · `data/students_data.csv`
- [Training notebook](https://github.com/thesangamx/student-marks-predictor/blob/main/notebook/Student_Marks_Prediction.ipynb): ML workflow · Explores data and trains the model. · `notebook/Student_Marks_Prediction.ipynb`
- [Serialized predictor](https://github.com/thesangamx/student-marks-predictor/blob/main/backend/model/final_exam_predictor_model.joblib): Joblib pipeline · Scaling, encoding, and linear-regression inference are encapsulated here. · `backend/model/final_exam_predictor_model.joblib`

### Prediction service

FastAPI serves the prebuilt pipeline.

- [FastAPI API](https://github.com/thesangamx/student-marks-predictor/blob/main/backend/main.py): ASGI application · Owns status and POST /predict contract. · `backend/main.py`
- [Request validation](https://github.com/thesangamx/student-marks-predictor/blob/main/backend/main.py): Pydantic schema · Accepts raw values for 18 student attributes. · `backend/main.py`
- [Inference adapter](https://github.com/thesangamx/student-marks-predictor/blob/main/backend/main.py): Pandas + pipeline call · Converts accepted JSON into a DataFrame and returns predicted marks. · `backend/main.py`
- [Serving dependencies](https://github.com/thesangamx/student-marks-predictor/blob/main/backend/requirements.txt): Python requirements · `backend/requirements.txt`
- **Uvicorn**: ASGI host
- **EC2 systemd deployment**: Ubuntu service · Hosts Uvicorn/FastAPI in production.

### Clients

Independent browser and Android consumers.

- [Streamlit web client](https://github.com/thesangamx/student-marks-predictor/blob/main/backend/streamlit_app.py): Browser UI · Collects raw inputs and calls the API over HTTP. · `backend/streamlit_app.py`

### Android app

Native app networking and distribution boundary.

- [Android UI](https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/MainActivity.kt): Activity · Collects inputs and renders prediction state. · `android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/MainActivity.kt`
- [Android API models](https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/StudentData.kt): Request/response DTOs · `android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/StudentData.kt`
- [Prediction response](https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/PredictionResponse.kt): Response DTO · `android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/PredictionResponse.kt`
- [Retrofit client](https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/ApiClient.kt): HTTP client · `android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/ApiClient.kt`
- [API endpoint interface](https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/ApiService.kt): Retrofit service · Declares asynchronous FastAPI calls. · `android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/ApiService.kt`
- [Android network policy](https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/src/main/AndroidManifest.xml): Manifest · Permits Internet access and current cleartext HTTP. · `android-app/app/src/main/AndroidManifest.xml`
- [Play release bundle](https://github.com/thesangamx/student-marks-predictor/blob/main/android-app/app/release/app-release.aab): Android App Bundle · `android-app/app/release/app-release.aab`

## Connections

- Student dataset → Training notebook: training data
- Training notebook → Serialized predictor: produces
- Serialized predictor → FastAPI API: loaded at serving
- FastAPI API → Request validation: validates request
- Request validation → Inference adapter: accepted features
- Inference adapter → Serialized predictor: predicts with
- Serving dependencies → FastAPI API: declares runtime
- Uvicorn → FastAPI API: hosts
- EC2 systemd deployment → Uvicorn: runs
- Streamlit web client → FastAPI API: HTTP POST /predict
- Android UI → Android API models: uses request data
- Android UI → Prediction response: renders result
- Android API models → Retrofit client: serialized request
- Retrofit client → API endpoint interface: creates
- API endpoint interface → FastAPI API: async HTTP /predict
- Prediction response → Android UI: prediction state
- Android network policy → Retrofit client: permits network / cleartext HTTP
- Play release bundle → Android UI: packages
