How priyangshu139/photontroppers works
Project type and purpose
• This is a backend microservice written in Python using FastAPI (app/main.py + uvicorn).
• It provides REST endpoints to ingest data, train ML models, serve predictions, run shell commands, control a Raspberry Pi, and send Telegram notifications.
• It persists data in a database (app/database.py) and stores serialized scikit-learn models (.pkl) in app/models.
File structure
• Top‐level: README, .env, requirements.txt, test.py
• app/main.py – FastAPI app entrypoint; mounts routers
• app/routers/*.py – grouped endpoints by function:
• data_routes (data ingestion)
• train_routes (trigger training)
• predict_routes (model inference)
• getdata_routes (fetch stored data)
• shell_routes (execute shell commands)
• picron_routes (Raspberry Pi control)
• telegram_routes + telegram_notify_routes (Telegram bot integration)
• app/models/*.pkl – pre‐trained/scaler ML artifacts
• app/utils/trainer.py – encapsulates training workflow
• app/database.py – ORM/DB connection code
README insights
• Launches with uvicorn app.main:app --reload
• Exposes Swagger UI at /docs
• No frontend component—purely a service layer
• Labels: use controller/service names matching file names (e.g., PredictRouter)
• Blue rectangles: API/Routers
• Orange rectangles: Services (trainer, model loader)
Putting it all together
• Layer 1 (Top): Clients (HTTP, CLI, Telegram User, Raspberry Pi)
• Layer 2: FastAPI container with grouped Routers
• Layer 3: Service layer modules (Data, Train, Predict, Shell, PiControl, TelegramNotify)
• Layer 4 (Bottom): Persistence (Database + Model files) + External services