How thesangamx/student-marks-predictor works
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: main.py FastAPI API · MainActivity.kt Android UI · final_exam_predictor_model.joblib Serialized predictor · ApiClient.kt Retrofit client
Components 17
Offline training
Builds the serialized model artifact.
- Student dataset
data/students_data.csv - Training notebook · Explores data and trains the model.
notebook/Student_Marks_Prediction.ipynb - Serialized predictor · 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 · Owns status and POST /predict contract.
backend/main.py - Request validation · Accepts raw values for 18 student attributes.
backend/main.py - Inference adapter · Converts accepted JSON into a DataFrame and returns predicted marks.
backend/main.py - Serving dependencies
backend/requirements.txt - Uvicorn
- EC2 systemd deployment · Hosts Uvicorn/FastAPI in production.
Clients
Independent browser and Android consumers.
- Streamlit web client · Collects raw inputs and calls the API over HTTP.
backend/streamlit_app.py
Android app
Native app networking and distribution boundary.
- Android UI · Collects inputs and renders prediction state.
android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/MainActivity.kt - Android API models
android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/StudentData.kt - Prediction response
android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/PredictionResponse.kt - Retrofit client
android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/ApiClient.kt - API endpoint interface · Declares asynchronous FastAPI calls.
android-app/app/src/main/java/com/sangamgupta/studentmarkspredictor/ApiService.kt - Android network policy · Permits Internet access and current cleartext HTTP.
android-app/app/src/main/AndroidManifest.xml - Play release bundle
android-app/app/release/app-release.aab
Connections 18
- 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