How chetan0402/tidytrack works
Project type and purpose
• This is a monolithic, full-stack web application built with FastAPI that also exposes a REST/JSON API consumed by an Android client (app-release.apk).
• It provides user-facing HTML pages (via Jinja2 templates in templates/) for web users (report generation, dashboards, public pages) and programmatic endpoints for the Android app (BSNL OTP authentication, data submission, version checks).
Key directories/files and their roles
• fastapi_app.py: entry point for the FastAPI application.
• database.py: database connection / session management (MySQL).
• models.py: ORM / database table definitions.
• schema.py: Pydantic request/response schemas.
• constants/: domain constants (report types, location data, tags).
• settings/config.py: application configuration (DB credentials, OTP limits, template IDs).
• templates/: Jinja2 templates + static assets (CSS, JS, images, mail php).
• LEARNING.md: possibly docs/training material.
• app-release.apk: compiled Android client that hits the API.
• utils.py: shared utility functions.
• requirements.txt: Python dependencies.
Architectural pattern
• MVC-style:
• Models ↔ models.py
• Views ↔ templates/ + static assets
• Controllers ↔ fastapi_app.py route handlers
• Pydantic for request validation and response modeling (schema.py).
• Central configuration (settings/config.py) injected into the app.
• External integration with BSNL OTP service via HTTP calls using credentials/config.
• Single relational database (MySQL) backend.
Main components and interactions
A. Clients
1. Web browser
• Requests HTML pages (GET /, /generate_report, dashboards, error pages).
• Submits forms (POST /generate_report).
2. Android app
• Calls REST endpoints for OTP generation/verification.
• Checks version (currentVersion vs latestAppLocalPath).
• Submits report data via JSON.
B. API / Web server (FastAPI)
• Routes defined in fastapi_app.py.
• Uses Pydantic schemas (schema.py) to parse/validate.
• Business logic uses utils.py and constants/.
• Renders templates using Jinja2.
• Reads settings from settings/config.py.
C. Database (MySQL)
• Stores user submissions, OTP objects, report logs, ban counters.
• Accessed via database.py session and models.py definitions.
D. External Service
• BSNL OTP SMS service for sending/validating OTPs.
• Configured via auth, templateID, Entity_ID.
E. Static assets
• CSS/JS/images in templates/assets served by FastAPI’s static file mount.
• Web Browser
• Android Client
• FastAPI Server
– Route Handlers
– Pydantic Schemas
– Business Logic (utils, constants)
– Template Engine
– Static File Server
• MySQL Database
• BSNL OTP Service
• Web Browser → FastAPI: HTTP GET/POST for HTML
• FastAPI → Templates: inject data → HTML → Browser
• Android → FastAPI: REST API calls (JSON)
• FastAPI → MySQL: SQL queries via ORM
• FastAPI → BSNL OTP Service: HTTP POST for SMS
c. Technologies:
• FastAPI (Python)
• Jinja2 templates, static assets (CSS/JS)
• Pydantic for schema validation
• SQLAlchemy or direct MySQL driver
• External SMS HTTP API
d. Call out config:
• settings/config.py drives DB connection, OTP policies, versioning