The Problem

People who want a personal analytics dashboard for social‑media accounts must either trust third‑party SaaS platforms with their data or build a custom stack from scratch. Maintaining a local database, handling OAuth flows, and exporting to CSV/Notion are repetitive, error‑prone tasks that most hobbyists cannot afford to implement securely.

What This Does

rpsync is a self‑hosted Go service that pulls post‑level statistics from Instagram, TikTok, YouTube, Bluesky, and other networks, stores them in a SQLite/PostgreSQL DB, and serves a React‑based UI. Core logic lives under internal/; the HTTP server is started from main.go (line 43) and renders templates such as templates/index.html. Docker support is provided by Dockerfile and docker-compose.yml, while the one‑shot installer lives in install.sh.

Key modules:

  • internal/fetcher/* – API clients for each network (e.g. telegram.go, tiktok.go).
  • internal/database/*.sql.go – autogenerated query wrappers (e.g. sources.sql.go, analytics.sql.go).
  • internal/api/handlers/*.go – Gin HTTP handlers (e.g. auth_login.go, redirects.go).
  • internal/worker/worker.go – background sync orchestration (SyncAll, SyncSource).

How It Is Wired

Execution begins in main.go:43 → main creates a DB (LoadDatabase → sql.Open), loads configuration (LoadConfig), and registers routes via internal/api/handlers/handlers.go. The root router calls CommonData (used by 32 handlers) to assemble user‑specific context, making it the widest‑impact function.

A typical sync cycle follows the internal call graph:

  1. main → LoadDatabase (filesystem) → internal/database/db.go.New.
  2. Start (worker) → Check (network http.Get).
  3. SyncAll → RunSync → DeleteOldStats (DB q.db.ExecContext).

The most invoked symbols are New, Redirect, and CommonData, each referenced from >30 distinct callers, indicating high blast radius for any change. Database‑write hot spots reside in internal/database/sources.sql.go (8 functions, 4 types, called from 17 files) and internal/database/db.go (core DB wrapper). Network outbound calls appear in 15 functions (e.g., fetcher clients) and file I/O in 6 functions (e.g., token encryption).

The import graph shows a single internal module with no circular dependencies, but deep nesting (max depth 8) and duplicated 6‑line blocks across many handlers inflate cognitive load. internal/database/analytics.sql.go is 645 lines, and internal/pusher/common/helpers.go contains 18 branch points in 53 lines, both flagged as maintenance hotspots.

How To Use It

# Clone the repo
git clone https://github.com/moses-y/rpsync.git
cd rpsync

# Build the container (Dockerfile uses golang:1.25.5 + debian:bookworm)
docker compose build

# Create a .env file (see README for required keys)
cp .env.example .env   # if the repo provided one; otherwise create manually

# Start services
docker compose up -d

The installer script (install.sh) automates the above steps and generates TLS certificates when run on a Linux host. Once the containers are healthy, the UI is reachable at the address printed by the script (default https://<IP>:8443).

Real‑World Use

A user runs the Docker stack on a home server, adds their Instagram and TikTok accounts via the web UI, and schedules a nightly sync. The worker (internal/worker/worker.go) polls each network, stores per‑post metrics in internal/database/posts.sql.go, and the dashboard (templates/*.html) visualises trends without any external data collection.

Code Health & Issues

  • Critical – golang.org/x/crypto@0.47.0 (CVE‑2026‑42508) and google.golang.org/grpc@1.78.0 (CVE‑2026‑33186) are pinned; upgrade required.
  • High – github.com/gotd/td@0.137.0 (CVE‑2026‑54638) and go.opentelemetry.io/otel@1.39.0 (CVE‑2026‑29181) need updating.
  • High – No test suite (79 source files, 0 test files). Add unit/integration tests and CI gate.
  • High – No GitHub Actions workflow; add a build‑and‑test pipeline.
  • High – Dockerfile lacks a build‑gate; introduce a CI step that builds the image and validates manifests.
  • Medium – Enable Dependabot/Renovate for automated dependency updates.
  • Medium – Pin base images by digest to avoid mutable tag drift.

Additional SDLC observations: repository contains a LICENSE and lockfile (go.sum), but no CI configuration, and documentation is limited to two Markdown files.

The Bottom Line

rpsync delivers a functional, locally hosted analytics hub with a clear separation between fetchers, DB wrappers, and HTTP handlers. However, deep nesting, duplicated handler logic, and an oversized analytics file make future changes risky. The most pressing actions are upgrading critical dependencies, introducing automated testing/CI, and refactoring the high‑complexity modules. Suitable for developers comfortable with Go and Docker who need a privacy‑first analytics stack and are willing to invest in improving test coverage and maintainability.