Skip to content

Repository files navigation

TinyHog

A miniature self-hosted analytics platform. Capture events from your app, view dashboards, and roll out features with percentage-based feature flags. [Just for learning purposes, not production-ready.]


Features

  • Event ingestion via API key — POST /api/capture/
  • Dashboard: total events, unique users, events per day
  • Redis caching and rate limiting on the capture endpoint
  • Background tasks with Celery and Celery Beat
  • Activity log on project changes via Django signals
  • PostgreSQL for relational data, ClickHouse for event storage
  • Redpanda (Kafka-compatible) as the message broker between capture and ClickHouse
  • JWT authentication — signup, login, token refresh
  • Organization membership with three roles: Member, Admin, Owner
  • Feature flags with hash-based percentage rollout — GET /api/decide/
  • React frontend — projects, dashboard, API key management, feature flags

Stack

Layer Technology
Web framework Django 6 + Django REST Framework
Database PostgreSQL 16
Cache + task broker Redis 7
Message broker Redpanda v26.1.12 (Kafka-compatible)
Analytics store ClickHouse 26.6
Background tasks Celery + Celery Beat
Auth djangorestframework-simplejwt
Frontend React + Vite + TypeScript + Tailwind CSS

Running locally

Prerequisites: Docker, Python 3.12, Node.js / Bun

1. Start infrastructure

docker compose up -d

2. Backend

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

cp .env.example .env

python manage.py migrate
python manage.py setup_clickhouse
python manage.py createsuperuser
python manage.py runserver

3. Celery (optional)

celery -A config worker -l info
celery -A config beat -l info

4. Frontend

cd frontend
bun install
bun run dev

Frontend at http://localhost:5173. Backend at http://localhost:8000.


Tests

unset PYTHONPATH
source .venv/bin/activate
python -m pytest

Project structure

tinyhog/
  config/          settings, urls, celery
  accounts/        User, Organization, OrganizationMembership
  projects/        Project, ActivityLog, signals
  events/          capture endpoint, Redpanda producer, ClickHouse queries
  flags/           FeatureFlag model, /api/decide/ endpoint
  frontend/        React + Vite app
  docker-compose.yaml

About

A miniature self-hosted analytics platform. Capture events from your app, view dashboards, and roll out features with percentage-based feature flags based on posthog

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages