Skip to content

Repository files navigation

📊 AutoReport — Automated Report Generation & Delivery

Python FastAPI Streamlit PostgreSQL APScheduler Tests


❓ Problem

Business owners and small teams need recurring reports — sales summaries, KPI check-ins — but generating and sending them is almost always a manual chore: open the data, build the summary, send it, repeat next week. There's rarely a lightweight way to say "just send me this, automatically, on a schedule" without either doing it by hand or paying for a heavyweight BI platform.


💡 Solution

A multi-user platform where anyone can connect a data source, set a schedule, and have a report show up automatically — no code, no dashboard visit required:

  • Bring your own data — upload a CSV, or connect a REST API / PostgreSQL database
  • Set it and forget it — daily, weekly, or monthly schedules, powered by a real background job scheduler
  • Delivered where you already are — straight to Telegram or email, not another dashboard to remember to check
  • Full visibility — a history log of every run, success or failure, with a clear reason when something goes wrong

✨ Features

  • 🔐 Multi-user accounts — JWT authentication, each user's data sources and schedules are private
  • 🗂️ Flexible data sources — CSV upload, REST API endpoint, or external PostgreSQL connection, all behind one common interface
  • Real scheduling — APScheduler-backed daily/weekly/monthly jobs that survive app restarts (reloaded from the database on startup)
  • 📤 Two delivery channels — Telegram bot messages or plain-text email, with graceful truncation for Telegram's message limit
  • 📋 Report history — every scheduled run is logged (success or failure, with the reason), visible per schedule
  • 🖥️ Simple dashboard — a Streamlit UI covering the whole flow: data sources, schedules, and history — no separate admin tool needed
  • 🛡️ Fails safe — a failed report generation or delivery is logged clearly, never crashes the scheduler or blocks other users' jobs
  • 🐳 One-command deploy — Docker Compose brings up the API, dashboard, and database together

🛠️ Tech Stack

Layer Tool Purpose
API / Auth FastAPI JWT auth, REST endpoints for sources/schedules/logs
Dashboard Streamlit Forms and tables — login, data sources, schedules, history
Scheduling APScheduler Background cron-style jobs, persisted across restarts
Database PostgreSQL Users, data sources, schedules, report logs
Delivery Telegram Bot API, smtplib Report delivery channels
Auth python-jose, passlib (bcrypt) JWT signing, password hashing
Deployment Docker Compose App, dashboard, and database together
Testing pytest 45 tests — auth, data sources, scheduler, delivery, all mocked

📡 How It Works

User uploads CSV / connects API/DB
            │
            ▼
   Data Source (stored per user)
            │
            ▼
  Schedule (daily / weekly / monthly)
            │
            ▼
   APScheduler fires on schedule
            │
            ▼
  Load data → build plain-text report
            │
            ▼
     Deliver via Telegram or email
            │
            ▼
      Logged to Report History

⚡ Quick Start

git clone https://github.com/rizalcodes/autoreport.git
cd autoreport

cp .env.example .env
# edit .env: set DB_PASSWORD, JWT_SECRET_KEY, and TELEGRAM_BOT_TOKEN/SMTP credentials

docker compose up --build

Register an account, upload a data source, and create a schedule — reports arrive automatically from then on.

Heads up: there's a SCHEDULER_TEST_INTERVAL_SECONDS dev override for quickly verifying the scheduler fires — it makes every active schedule run every N seconds instead of on its real cadence. Great for testing, dangerous if left on: remove it (and pause test schedules) before walking away, or it'll keep delivering every few seconds until stopped.

Tests

python -m venv venv
venv/Scripts/pip install -r requirements.txt
venv/Scripts/python -m pytest

45 tests, all using in-memory SQLite and mocked Telegram/SMTP — no live services or real credentials required.


📁 Project Structure

autoreport/
├── app.py                  # Streamlit dashboard
├── api_client.py             # HTTP client wrapper (dashboard -> API)
├── api/
│   ├── main.py                 # FastAPI: auth, data sources, schedules
│   ├── auth.py                    # JWT + password hashing
│   └── models.py                    # User, DataSource, ReportSchedule, ReportLog
├── sources/
│   ├── csv_source.py                  # CSV upload handling
│   └── db_source.py                     # API / PostgreSQL connections
├── scheduler/
│   ├── jobs.py                            # APScheduler integration
│   └── report_builder.py                    # Pure DataFrame -> report text
├── delivery/
│   ├── telegram.py                            # Telegram Bot API delivery
│   └── email.py                                 # SMTP email delivery
├── tests/                                         # 45 tests
├── docker-compose.yml                                # app + frontend + db
└── Dockerfile

👤 Author

Rizal

Portfolio GitHub Twitter/X


Built with FastAPI, Streamlit, and the belief that a report you have to remember to generate is a report that eventually doesn't get generated.

About

Multi-user SaaS-lite report automation platform — add a data source (CSV/API/DB), schedule daily/weekly/monthly reports, and receive them automatically via Telegram or email. Built with FastAPI, Streamlit, PostgreSQL, and APScheduler.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages