{"id":31011921,"url":"https://github.com/bdeekshith066/restaurant-uptime-tracker","last_synced_at":"2026-04-18T07:33:22.942Z","repository":{"id":313467883,"uuid":"1044261933","full_name":"bdeekshith066/restaurant-uptime-tracker","owner":"bdeekshith066","description":"A FastAPI-based backend that tracks store uptime/downtime from pings and generates time-zone aware reports for the last hour, day, and week.","archived":false,"fork":false,"pushed_at":"2025-09-06T07:48:40.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-13T15:05:15.236Z","etag":null,"topics":["fastapi","python","sqlalchemy","sqlite"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bdeekshith066.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-25T12:24:22.000Z","updated_at":"2025-09-06T07:51:31.000Z","dependencies_parsed_at":"2025-09-06T09:24:45.679Z","dependency_job_id":"bb75bdae-bb81-48b9-b229-18f09db69995","html_url":"https://github.com/bdeekshith066/restaurant-uptime-tracker","commit_stats":null,"previous_names":["bdeekshith066/deekshith_b_30-08-2025"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bdeekshith066/restaurant-uptime-tracker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdeekshith066%2Frestaurant-uptime-tracker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdeekshith066%2Frestaurant-uptime-tracker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdeekshith066%2Frestaurant-uptime-tracker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdeekshith066%2Frestaurant-uptime-tracker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bdeekshith066","download_url":"https://codeload.github.com/bdeekshith066/restaurant-uptime-tracker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdeekshith066%2Frestaurant-uptime-tracker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31961287,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastapi","python","sqlalchemy","sqlite"],"created_at":"2025-09-13T05:14:23.266Z","updated_at":"2026-04-18T07:33:22.912Z","avatar_url":"https://github.com/bdeekshith066.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Loop Store Monitor\n\n## 📌 Project Overview\nThis project implements a backend system to **monitor store uptime/downtime** based on periodic pings.  \nRestaurant owners can generate reports showing how often their stores were online or offline **during business hours** in the last **hour, day, and week**.\n\nIt is built with **FastAPI**, **SQLAlchemy (async)**, and supports both **SQLite**.\n\n---\n\n## 🚀 Features\n- **CSV Ingestion**: Loads ping logs, business hours, and timezones into the database.\n- **Uptime/Downtime Reports**:\n  - Uptime/downtime **last hour** (minutes)\n  - Uptime/downtime **last day** (hours)\n  - Uptime/downtime **last week** (hours)\n- **Trigger + Poll API**:\n  - `POST /trigger_report` → starts background computation, returns `report_id`.\n  - `GET /get_report?report_id=...` → returns `\"Running\"`, `\"Failed\"`, or streams the finished CSV.\n- **Time-zone aware** (handles local business hours, overnight shifts, DST).\n- **Safe defaults**:\n  - Missing business hours → 24×7 open\n  - Missing timezone → America/Chicago\n  - No pings → assume inactive\n\n---\n\n## 🗂️ Project Structure\n```\n\napp/\napi/         → API endpoints (health, report)\nservices/    → Report computation logic\nutils/       → Time window \u0026 status segment utilities\nmodels.py    → SQLAlchemy ORM models\ndb.py        → Async DB setup + session provider\nconfig.py    → Environment settings (via pydantic-settings)\ningest.py    → Loads CSV data into DB\nmain.py      → FastAPI app entrypoint\ntests/         → Unit and integration tests\nreports/       → Generated CSV reports\n\n````\n\n---\n\n## ⚙️ Setup \u0026 Installation\n```bash\n# 1. Clone repo \u0026 install requirements\ngit clone https://github.com/bdeekshith066/Deekshith_30-08-2025.git\npip install -r requirements.txt\n\n# 2. Configure .env (SQLite default)\ncat \u003c\u003cEOF \u003e .env\nDATABASE_URL=sqlite+aiosqlite:///./store_monitor.sqlite\nSTATUS_CSV=./data/store_status.csv\nHOURS_CSV=./data/business_hours.csv\nTZ_CSV=./data/store_timezone.csv\nEOF\n\n# (Optional) For Postgres instead (requires docker-compose up -d):\n# DATABASE_URL=postgresql+asyncpg://app:app@localhost:5432/store_monitor\n\n# 3. Ingest data\npython -m app.ingest\n\n# 4. Run API\nuvicorn app.main:app --reload\n````\n\n---\n\n## 📡 API Endpoints\n\n### Health\n\n```bash\nGET /healthz       → {\"ok\": true} if DB is reachable\nGET /debug/tables  → lists DB tables\n```\n\n### Report Flow\n\n#### 1. Trigger report\n\n```bash\ncurl -X POST http://127.0.0.1:8000/trigger_report\n# {\"report_id\": \"abcd1234...\"}\n```\n\n#### 2. Poll for result\n\n```bash\ncurl \"http://127.0.0.1:8000/get_report?report_id=abcd1234...\"\n# → \"Running\" | \"Failed\" | CSV file\n```\n\n---\n\n## 📊 Sample CSV Output\n\nSchema:\n\n```\nstore_id,\nuptime_last_hour(in minutes),\nuptime_last_day(in hours),\nuptime_last_week(in hours),\ndowntime_last_hour(in minutes),\ndowntime_last_day(in hours),\ndowntime_last_week(in hours)\n```\n\nExample row:\n\n```\n00017c6a...,60.0,8.53,58.77,0.0,1.97,16.73\n```\n\n---\n\n## ✅ Testing\n\n```bash\npytest\n```\n\nIntegration test (`test_api.py`) runs the trigger → poll → CSV download flow against a running server.\n\n---\n\n## 🧩 Design Choices\n\n* **Async Database (SQLAlchemy + async):** Non-blocking for scalability.\n* **Trigger + Poll Workflow:** Background job avoids request timeouts.\n* **Safe Defaults:** Graceful handling of missing hours/timezones/pings.\n* **CSV Output:** Portable and BI-tool friendly.\n\n---\n\n## 🔮 Improvements\n\n* Switch to Postgres + Alembic migrations for production.\n* Use Celery/Redis for distributed background jobs.\n* Add caching/pre-aggregation for faster repeated reports.\n* Improve observability with logging \u0026 metrics.\n* Add auth \u0026 RBAC for customer-facing use.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdeekshith066%2Frestaurant-uptime-tracker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbdeekshith066%2Frestaurant-uptime-tracker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdeekshith066%2Frestaurant-uptime-tracker/lists"}