Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Each folder in this repo is a standalone project. Dive in to see how to solve re
| [stay-scout-hub](./stay-scout-hub) | Searches across all sites for places to stay when traveling for conventions or events |
| [summer-school-finder](./summer-school-finder) | Discover and compare summer school programs from universities around the world |
| [tenders-finder](./tenders-finder) | AI-powered Singapore government tender discovery tool scraping multiple tender portals in parallel |
| [TinyDetective](./TinyDetective) | Brand protection for Vietnam's ecommerce industry, using TinyFish agent swarms for parallel counterfeit detection & reporting |
| [tinyskills](./tinyskills) | Multi-source AI skill guide generator |
| [tutor-finder](./tutor-finder) | AI-powered tutor discovery platform for competitive exams across multiple platforms |
| [viet-bike-scout](./viet-bike-scout) | Motorbike rental price comparison tool across Vietnamese cities using parallel browser agents |
Expand Down Expand Up @@ -222,4 +223,3 @@ This repository is a community-driven space for sharing derivatives, code sample
<img src="https://github.com/user-attachments/assets/2cf004f0-0065-4f21-9835-12ac693964f1" width="100%" />



24 changes: 24 additions & 0 deletions TinyDetective/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# TinyFish API configuration
INVESTIGATION_STORE_PATH=data/investigations.sqlite3
TINYFISH_API_KEY=replace-with-your-tinyfish-api-key
TINYFISH_BASE_URL=https://agent.tinyfish.ai
TINYFISH_BROWSER_PROFILE=stealth
TINYFISH_PROXY_ENABLED=false
TINYFISH_PROXY_COUNTRY_CODE=SG
TINYFISH_POLL_INTERVAL_SECONDS=2.0
TINYFISH_HTTP_TIMEOUT_SECONDS=15.0
TINYFISH_RUN_SOFT_TIMEOUT_SECONDS=300.0
TINYFISH_RUN_HARD_TIMEOUT_SECONDS=1800.0
TINYFISH_RUN_STALL_TIMEOUT_SECONDS=120.0

# OpenAI candidate triage configuration
OPENAI_API_KEY=replace-with-your-openai-api-key
OPENAI_BASE_URL=https://api.openai.com
OPENAI_TRIAGE_MODEL=gpt-5-mini
OPENAI_REASONING_MODEL=gpt-5-mini
OPENAI_HTTP_TIMEOUT_SECONDS=30.0
OPENAI_SHORTLIST_LIMIT=6

# Brand and marketplace targets
BRAND_LANDING_PAGE_URL=https://www.yourbrand.com/
ECOMMERCE_STORE_URLS=https://shopee.sg/,https://www.lazada.sg/
211 changes: 211 additions & 0 deletions TinyDetective/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[codz]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py.cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
data/*.sqlite3
data/*.sqlite
data/*.sqlite-journal
data/*.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
#poetry.toml

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
#pdm.lock
#pdm.toml
.pdm-python
.pdm-build/

# pixi
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
#pixi.lock
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
# in the .venv directory. It is recommended not to include this directory in version control.
.pixi

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.envrc
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Abstra
# Abstra is an AI-powered process automation framework.
# Ignore directories containing user credentials, local state, and settings.
# Learn more at https://abstra.io/docs
.abstra/

# Visual Studio Code
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# you could uncomment the following to ignore the entire vscode folder
# .vscode/

# Ruff stuff:
.ruff_cache/

# PyPI configuration file
.pypirc

# Cursor
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
# refer to https://docs.cursor.com/context/ignore-files
.cursorignore
.cursorindexingignore

# Marimo
marimo/_static/
marimo/_lsp/
__marimo__/
125 changes: 125 additions & 0 deletions TinyDetective/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# TinyDetective

## Creators

- [Darrius](https://github.com/darriusnjh)
- [Wei Sin Tai](https://github.com/weisintai)
- [Zane Chee](https://github.com/injaneity)

TinyDetective was built at **LotusHacks x HackHarvard Vietnam 2026**, where it placed **second in the Enterprise track**. The project came out of the TinyFish-sponsored challenge and focused on a practical enterprise workflow: counterfeit research across official brand sites and marketplace listings.

**Live link:** Local run only

**Source repo:** https://github.com/darriusnjh/TinyDetective

TinyDetective is a counterfeit research platform with a modular multi-agent pipeline. It accepts an official product URL plus marketplace URLs, runs TinyFish-powered source extraction and listing analysis, then returns ranked findings with evidence and a short risk summary.

The app keeps the workflow intentionally modular: adapters handle site-specific extraction, agents score and summarize results, and the backend persists investigations so unfinished runs can resume after restarts.

## Demo

![TinyDetective](./frontend/tinydetective.png)

## TinyFish API usage

TinyDetective uses the official [`tinyfish`](https://pypi.org/project/tinyfish/) Python SDK. The app queues TinyFish runs with `AsyncTinyFish.agent.queue(...)`, then resumes or polls them with `AsyncTinyFish.runs.get(...)` until structured JSON is ready:

```python
from tinyfish import AsyncTinyFish

client = AsyncTinyFish(api_key=settings.tinyfish_api_key)
queued = await client.agent.queue(
goal=goal,
url=url,
browser_profile=self._browser_profile(),
proxy_config=self._proxy_config(),
)

run = await client.runs.get(queued.run_id)
```

## How to run

```bash
uv sync --dev
uv run python -m backend
```

You can also run the backend entry file directly:

```bash
cd backend
uv run main.py
```

Open `http://127.0.0.1:8000`.

Create `.env` from `.env.example` and set:

```bash
TINYFISH_API_KEY=your-real-key
TINYFISH_HTTP_TIMEOUT_SECONDS=15.0
TINYFISH_RUN_SOFT_TIMEOUT_SECONDS=300.0
TINYFISH_RUN_HARD_TIMEOUT_SECONDS=1800.0
TINYFISH_RUN_STALL_TIMEOUT_SECONDS=120.0
BRAND_LANDING_PAGE_URL=https://www.yourbrand.com/
ECOMMERCE_STORE_URLS=https://shopee.sg/,https://www.lazada.sg/
INVESTIGATION_STORE_PATH=data/investigations.sqlite3
```

If `comparison_sites` is omitted from `POST /investigate`, the backend falls back to `ECOMMERCE_STORE_URLS`.

Run tests with:

```bash
uv run pytest
```

## Architecture diagram

```mermaid
graph TD
User[User] --> UI[Static frontend]
UI --> API[FastAPI backend]
API --> Orchestrator[Investigation orchestrator]
Orchestrator --> Store[(SQLite investigation store)]
Orchestrator --> SourceAdapter[Official product adapter]
Orchestrator --> DiscoveryAdapter[Comparison site adapter]
SourceAdapter --> TinyFish[TinyFish async runs]
DiscoveryAdapter --> TinyFish
Orchestrator --> SourceAgent[SourceExtractionAgent]
Orchestrator --> DiscoveryAgent[CandidateDiscoveryAgent]
Orchestrator --> ComparisonAgent[ProductComparisonAgent]
Orchestrator --> EvidenceAgent[EvidenceAgent]
Orchestrator --> RankingAgent[RankingAgent]
Orchestrator --> SummaryAgent[ResearchSummaryAgent]
```

## Project structure

- `backend/`: FastAPI app and API entrypoint.
- `agents/`: Source extraction, discovery, comparison, evidence, ranking, and summary agents.
- `adapters/`: TinyFish-backed official-product extraction and marketplace candidate discovery adapters.
- `models/`: Typed Pydantic schemas for API payloads and pipeline data.
- `services/`: Investigation orchestrator, SQLite-backed persistence, and TinyFish runtime/client abstractions.
- `frontend/`: Minimal static UI for launching investigations and inspecting results.
- `tests/`: Basic tests and sample fixture output.

## Workflow

1. `POST /investigate` creates an investigation and starts async orchestration.
2. `SourceExtractionAgent` extracts a normalized `SourceProduct`.
3. `CandidateDiscoveryAgent` searches the target comparison sites with TinyFish.
4. `ProductComparisonAgent` scores similarity and counterfeit risk.
5. `EvidenceAgent` converts comparisons into audit-friendly evidence.
6. `RankingAgent` returns up to 5 precision-oriented matches.
7. `ResearchSummaryAgent` writes the final investigation summary.
8. `GET /investigation/{id}` returns status, reports, and raw agent outputs.

## Notes

- Investigation runs are stored in SQLite and survive backend restarts by default.
- The default database file is `data/investigations.sqlite3`, configurable with `INVESTIGATION_STORE_PATH`.
- The frontend restores the latest saved investigation after a page refresh using browser local storage.
- On backend startup, unfinished investigations are resumed from SQLite, including pending TinyFish provider runs that already have a saved `run_id`.
- Backend agent activity is written to `logs/tinydetective.log`.
1 change: 1 addition & 0 deletions TinyDetective/adapters/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Pluggable adapters for extraction and candidate discovery."""
Loading