{"id":51869218,"url":"https://github.com/houas-sarah/smart-bi-assistant","last_synced_at":"2026-07-24T20:30:23.325Z","repository":{"id":368870957,"uuid":"1286165264","full_name":"houas-sarah/smart-bi-assistant","owner":"houas-sarah","description":"Ask business questions in plain English and get SQL, tables and charts \"a natural-language BI tool\"","archived":false,"fork":false,"pushed_at":"2026-07-02T14:33:39.000Z","size":11411,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-02T16:27:52.686Z","etag":null,"topics":["business-intelligence","llm","nlp","python","sqlite","streamlit","text-to-sql"],"latest_commit_sha":null,"homepage":"https://smart-bi-assistant-xnr5vq24a86rt97nzwxaud.streamlit.app/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/houas-sarah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2026-07-01T14:01:36.000Z","updated_at":"2026-07-02T14:36:46.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/houas-sarah/smart-bi-assistant","commit_stats":null,"previous_names":["houas-sarah/smart-bi-assistant"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/houas-sarah/smart-bi-assistant","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houas-sarah%2Fsmart-bi-assistant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houas-sarah%2Fsmart-bi-assistant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houas-sarah%2Fsmart-bi-assistant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houas-sarah%2Fsmart-bi-assistant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/houas-sarah","download_url":"https://codeload.github.com/houas-sarah/smart-bi-assistant/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houas-sarah%2Fsmart-bi-assistant/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35855703,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-24T02:00:07.870Z","response_time":62,"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":["business-intelligence","llm","nlp","python","sqlite","streamlit","text-to-sql"],"created_at":"2026-07-24T20:30:22.381Z","updated_at":"2026-07-24T20:30:23.317Z","avatar_url":"https://github.com/houas-sarah.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Smart BI Assistant\n\nA natural-language interface to a business database. You type a question like\n*\"which products bring in the most revenue?\"* and it writes the SQL, runs it, and\nshows you the answer as a table and a chart — no SQL knowledge needed.\n\nI built it as a personal project to see how far natural-language-to-SQL could go.\nUnder the hood it uses a language model to turn plain English into SQL, running\nagainst the Northwind sample database.\n\n**Live demo:** https://smart-bi-assistant-xnr5vq24a86rt97nzwxaud.streamlit.app/\n\n## What you can do with it\n\n- Ask questions in English instead of writing queries by hand\n- See the exact SQL it generated, and edit it yourself if it got something wrong\n- Browse results as a table, download them as CSV, or switch to a chart\n- Start from a set of example questions if you're not sure what to ask\n\n## Screenshots\n\nAsk a question in plain English:\n\n![Home](docs/home.png)\n\nResults come back as a table with a few quick stats and a CSV download:\n\n![Results](docs/results.png)\n\nThe generated SQL is always shown, and you can edit and re-run it:\n\n![SQL editor](docs/sql-editor.png)\n\n## Running it locally\n\nYou'll need Python and a free Hugging Face token — the app calls a model through\nHugging Face's API to generate the SQL.\n\nClone the repo and install the dependencies:\n\n```bash\ngit clone https://github.com/houas-sarah/smart-bi-assistant.git\ncd smart-bi-assistant\npip install -r requirements.txt\n```\n\nGet a token from https://huggingface.co/settings/tokens and put it in a `.env`\nfile in the project folder:\n\n```\nHF_API_KEY=hf_your_token_here\nHF_MODEL_NAME=Qwen/Qwen2.5-Coder-32B-Instruct\n```\n\nThen run it:\n\n```bash\nstreamlit run app.py\n```\n\nIt opens at http://localhost:8501. The model name is optional — leave it out and\nit falls back to the Qwen coder model above.\n\n## About the database\n\nIt ships with an expanded version of Northwind, the classic sample database for a\nsmall import/export company. This version is much bigger than the original so\nthat trends and aggregations are actually interesting to query — around 16,000\norders and 600,000 order lines, across 93 customers and 77 products, dated\n2012 to 2023.\n\nThe data is synthetic, so don't read too much into the revenue figures. A single\n\"customer\" pulling in millions is just an artifact of how the data was generated.\n\n## How it works\n\nThe pipeline is short:\n\n```\nyour question  →  model writes SQL  →  SQL runs on SQLite  →  table + chart\n```\n\nA few guardrails keep it safe and honest:\n\n- **The SQL is parsed, not string-matched.** Every query is parsed into a syntax\n  tree with [`sqlglot`](https://github.com/tobymao/sqlglot). Only a single\n  read-only statement (`SELECT` / `WITH`) is allowed; anything that writes,\n  changes the schema, chains multiple statements, or can't be parsed is rejected.\n  This is far harder to fool than keyword blocking — and it doesn't wrongly reject\n  a valid query just because a word like `delete` appears inside a text value.\n- **The connection is read-only.** Queries run over a SQLite connection opened in\n  `mode=ro`, so even a query that somehow slipped past validation physically\n  cannot modify the data.\n- **The SQL is always visible and editable.** A language model can misread a\n  question, so you can open the SQL tab, fix the query, and run your edited\n  version — it goes through exactly the same checks.\n\n## Is the SQL always correct?\n\nSafety, yes — it can't modify anything. Correctness, not always. The queries are\nwritten by a language model, so it can misunderstand a question or join the wrong\ntables now and then. That's the reason the app shows you the query and lets you\nedit it: think of it as a fast first draft to check, not a guaranteed answer.\n\n## Tests\n\nThere's a small offline test suite (no API key or network needed) that covers the\nquery validation and the SQL-cleaning logic:\n\n```bash\npip install -r requirements-dev.txt\npytest\n```\n\n## Things I'd add next\n\n- Feed query errors back to the model so it can fix its own mistakes\n- Support databases other than the bundled Northwind file\n- Cache repeated questions\n- Let the model pick the most fitting chart type for each result\n\n## License\n\nMIT — see the [LICENSE](LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhouas-sarah%2Fsmart-bi-assistant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhouas-sarah%2Fsmart-bi-assistant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhouas-sarah%2Fsmart-bi-assistant/lists"}