Skip to content
EliteGamer007Public

About

A modern federated social media application with DID (Decentralized Identity) authentication, End-to-End Encrypted DM's and multiple federated instance servers to choose from. You control what you want to see. Built with Go, Echo framework, and PostgreSQL (Neon Cloud).

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

205 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Splitter

Federated social media platform built with Go, ActivityPub, and Next.js. Run your own instance and communicate across the network.

Go Next.js PostgreSQL License: MIT

Live Demo: https://splitter-red-phi.vercel.app
Backend API: https://splitter-m0kv.onrender.com/api/v1/health


Table of Contents


Overview

Splitter is a full-stack federated social network. Each instance is independent but communicates with others via the ActivityPub protocol β€” users on one instance can follow and exchange content with users on any other Splitter (or compatible) instance.

Core Features:

  • Federated social graph β€” follow, posts, boosts, replies across instances
  • End-to-end encrypted DMs β€” Ed25519 key-pairs per device; server never sees plaintext
  • Dual authentication β€” password/JWT and DID (Decentralized Identity) cryptographic login
  • Hashtag trending β€” regex extraction + real-time trending tab backed by PostgreSQL full-text search
  • AI @split bot β€” mention @split in any post to receive a synchronous AI reply (Gemini 1.5 Flash / GPT-4o-mini)
  • Automated bot population β€” GitHub Actions cron job seeds the network with realistic content every 30 minutes
  • Circle visibility β€” posts visible only to curated "circle" members
  • Admin & moderation β€” role management, content reports, AI-assisted screening

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     HTTPS      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Next.js Frontend   β”‚ ◄────────────► β”‚  Go/Echo Backend    β”‚
β”‚  (Vercel)           β”‚                β”‚  (Render)           β”‚
β”‚  React + Tailwind   β”‚                β”‚  REST API + AP      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                   β”‚ pgx/v5
                                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                       β”‚  PostgreSQL 15        β”‚
                                       β”‚  (Neon β€” serverless)  β”‚
                                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Federation:
  Instance 1  ◄──── ActivityPub (HTTP Signatures) ────►  Instance 2
  splitter-m0kv.onrender.com                             splitter-2.onrender.com
Component Technology
Backend API Go 1.24 / Echo v4
Database PostgreSQL 15 (Neon serverless)
ORM / Driver jackc/pgx v5
Frontend Next.js 16 / React 19 / Tailwind CSS
Auth bcrypt + JWT (RS256) / Ed25519 DID keypairs
Federation ActivityPub (W3C), HTTP Signatures, WebFinger
AI Google Gemini 1.5 Flash / OpenAI GPT-4o-mini
Bots Python 3 + GitHub Actions cron
Hosting Render (backend) + Vercel (frontend) + Neon (DB)

Project Structure

splitter/
β”œβ”€β”€ cmd/
β”‚   β”œβ”€β”€ server/             # Main server entrypoint
β”‚   └── migrate/            # Standalone migration runner
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ auth/               # DID keypair generation & verification
β”‚   β”œβ”€β”€ config/             # Environment-based configuration
β”‚   β”œβ”€β”€ db/                 # Database connection (Neon + SSL)
β”‚   β”œβ”€β”€ federation/         # ActivityPub delivery, signatures, peer health
β”‚   β”œβ”€β”€ handlers/           # HTTP request handlers (one file per domain)
β”‚   β”œβ”€β”€ helpers/            # Shared utility functions
β”‚   β”œβ”€β”€ middleware/         # JWT auth, optional auth, CORS
β”‚   β”œβ”€β”€ models/             # Domain model structs
β”‚   β”œβ”€β”€ repository/         # Data-access layer (pgx queries)
β”‚   └── server/             # Router setup & middleware wiring
β”œβ”€β”€ migrations/             # Ordered SQL migration files
β”œβ”€β”€ scripts/
β”‚   └── bots/               # Python bot population scripts
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ docs/               # Testing documentation (01–08)
β”‚   β”œβ”€β”€ unit/               # Unit tests (auth, posts, replies, users, security)
β”‚   β”œβ”€β”€ integration/        # Integration test suite
β”‚   β”œβ”€β”€ e2e_test/           # End-to-end tests
β”‚   β”œβ”€β”€ load/               # Load tests (k6 / Go)
β”‚   β”œβ”€β”€ seeder/             # Test data seeder
β”‚   └── results/            # Captured test output
β”œβ”€β”€ diagrams/               # Architecture, ER, sequence, class diagrams (Mermaid)
β”œβ”€β”€ .env.example            # Environment variables template
β”œβ”€β”€ Dockerfile              # Multi-stage Docker build
β”œβ”€β”€ docker-compose.instances.yml  # Two-instance local federation setup
β”œβ”€β”€ Makefile                # Common dev commands
└── go.mod

Quick Start

Prerequisites

Tool Version Notes
Go 1.21+ go.dev/dl
Node.js 18+ nodejs.org
Docker Any For running psql migrations
Neon account β€” Free tier at neon.tech

1. Clone & Configure

git clone <repository-url>
cd splitter
cp .env.example .env

Edit .env with your Neon credentials:

DB_HOST=ep-your-endpoint.region.aws.neon.tech
DB_PORT=5432
DB_USER=neondb_owner
DB_PASSWORD=your-password
DB_NAME=neondb
PORT=8000
ENV=development
BASE_URL=http://localhost:8000
JWT_SECRET=change-this-to-a-secure-random-string

2. Apply Database Migrations

docker run --rm postgres:15 psql \
  'postgres://USER:PASS@HOST/DBNAME?sslmode=require' \
  -f migrations/000_master_schema.sql

3. Start the Backend

go mod download
go run ./cmd/server
# β†’ Server listening on http://localhost:8000

Default admin account created on first startup:

Username: admin
Password: splitteradmin   ⚠️ Change immediately in production

4. Start the Frontend

cd ../Splitter-frontend
npm install
npm run dev
# β†’ Frontend at http://localhost:3000

5. Two-Instance Local Federation (Optional)

docker compose -f docker-compose.instances.yml up

This spins up two backend instances that federate with each other locally.


API Reference

Base URL: http://localhost:8000/api/v1
πŸ”’ = Requires Authorization: Bearer <jwt_token>

Authentication

Method Endpoint Description
POST /auth/register Register with username/email/password
POST /auth/login Login β†’ returns JWT
POST /auth/challenge Request a DID auth nonce
POST /auth/verify Verify DID signature β†’ returns JWT
POST /auth/refresh πŸ”’ Rotate JWT
POST /auth/logout πŸ”’ Invalidate token

Users

Method Endpoint Description
GET /users/:id Get user by ID
GET /users/did Get user by DID
GET πŸ”’ /users/me Get own profile
PUT πŸ”’ /users/me Update profile
DELETE πŸ”’ /users/me Delete account
GET πŸ”’ /users/search Search users
POST πŸ”’ /users/me/circle/:id Add user to circle
DELETE πŸ”’ /users/me/circle/:id Remove from circle
GET πŸ”’ /users/me/circle/:id/check Check circle membership

Posts

Method Endpoint Description
GET /posts/public Public feed
GET /posts/:id Get post
GET /posts/user/:did Posts by user DID
GET πŸ”’ /posts/feed Personalized feed (follows + own)
POST πŸ”’ /posts Create post (multipart/form-data)
PUT πŸ”’ /posts/:id Update post
DELETE πŸ”’ /posts/:id Delete post

Replies

Method Endpoint Description
GET /posts/:id/replies Threaded replies for a post
POST πŸ”’ /posts/:id/replies Reply to a post

Social

Method Endpoint Description
POST πŸ”’ /users/:id/follow Follow user
DELETE πŸ”’ /users/:id/follow Unfollow
GET /users/:id/followers Followers list
GET /users/:id/following Following list
POST πŸ”’ /posts/:id/like Like post
DELETE πŸ”’ /posts/:id/like Unlike post
POST πŸ”’ /posts/:id/repost Boost/repost
POST πŸ”’ /posts/:id/bookmark Bookmark post

Direct Messages

Method Endpoint Description
GET πŸ”’ /messages/threads All message threads
GET πŸ”’ /messages/conversation/:userId Messages with a user
POST πŸ”’ /messages/send Send encrypted message

Federation

Method Endpoint Description
GET /federation/timeline Cross-instance federated timeline
GET /federation/users Search users across instances
POST /ap/users/:username/inbox ActivityPub inbox
GET /ap/users/:username ActivityPub Actor JSON-LD
GET /.well-known/webfinger WebFinger discovery

Admin πŸ”’ Admin role required

Method Endpoint Description
GET /admin/users List all users
PUT /admin/users/:id/role Change role
POST /admin/users/:id/suspend Suspend account
POST /admin/users/:id/unsuspend Unsuspend account
GET /admin/moderation-requests Content reports queue
POST /admin/moderation-requests/:id/approve Approve moderator

Full annotated reference with request/response examples: API_ENDPOINTS.md


Authentication

Password Login

Standard username + password flow returning a JWT:

curl -X POST http://localhost:8000/api/v1/auth/login \
  -H 'Content-Type: application/json' \
  -d '{"username":"alice","password":"secret"}'
# β†’ {"token":"eyJ..."}

Use the token as Authorization: Bearer <token> on subsequent requests.

DID (Decentralized Identity)

Challenge-response using Ed25519 keypairs β€” the server never receives the private key:

1. POST /auth/challenge   { did: "did:web:..." }   β†’ { challenge: "nonce" }
2. Client signs nonce with private key
3. POST /auth/verify      { did, challenge, signature } β†’ { token: "JWT" }

Private keys are stored locally (encrypted) in the browser. Recovery requires the encrypted backup file downloaded at registration.


Federation

Splitter implements a subset of ActivityPub:

Supported Activities

Create Β· Follow Β· Accept Β· Like Β· Announce Β· Undo Β· Delete

Security

All inbound federation POSTs require:

  • Signature header β€” HTTP Signatures (RSA-SHA256)
  • Digest header β€” SHA-256 body digest
  • Date header β€” within Β±30 seconds (keep clocks synced via NTP)

Environmental Requirements

FEDERATION_ENABLED=true
FEDERATION_DOMAIN=your-instance-id
FEDERATION_URL=https://your-public-url

For full well-known endpoints and ActivityPub routes, see API_ENDPOINTS.md.


Configuration

All configuration is via environment variables. See .env.example for the full list.

Variable Required Description
DB_HOST βœ… PostgreSQL host (Neon endpoint)
DB_PORT βœ… PostgreSQL port (default: 5432)
DB_USER βœ… Database username
DB_PASSWORD βœ… Database password
DB_NAME βœ… Database name
PORT βœ… HTTP server port
ENV βœ… development or production
JWT_SECRET βœ… Secret for JWT signing
BASE_URL βœ… Public base URL of this instance
SPLIT_BOT_API_KEY Optional OpenAI / Gemini key for @split bot
FEDERATION_ENABLED Optional Enable ActivityPub federation
FEDERATION_DOMAIN Optional Canonical domain/ID for this instance
FEDERATION_URL Optional Public HTTPS URL for federation

Testing

# Run all tests
make test

# Run with coverage report
make test-cover

# Test a specific package
go test ./tests/unit/auth -v

# Integration tests (requires live DB in .env)
go test ./tests/integration/... -v

# Load tests
go test ./tests/load -v

Test documentation is in tests/docs/:

Doc Coverage
01_UNIT_TESTING.md Unit test strategy & examples
02_INTEGRATION_TESTING.md Integration flows
03_E2E_TESTING.md End-to-end scenarios
04_DATABASE_TESTING.md Schema & migration tests
05_LOAD_TESTING.md k6 / Go load benchmarks
06_TEST_SEEDING.md Data seeder usage
07_TEST_REPORTS.md Report format & CI integration
08_REGRESSION_TESTING.md Regression suite

Documentation Index

Document Description
DEPLOYMENT.md Live services, Render + Neon setup, CI/CD, deploy checklist
API_ENDPOINTS.md Full annotated API reference with cURL examples
DATABASE_SCHEMA.md Schema tables, indexes, relationships
CONTRIBUTING.md Dev workflow, code standards, extension recipes
SECURITY.md Security model, DID auth, E2EE, threat model
TROUBLESHOOTING.md Common issues β€” DB connection, federation, DID
CODING_STANDARDS.md Go style guide & naming conventions
OPS.md Operational runbooks
DESIGN.md Design decisions & ADRs
ROADMAP.md Planned features & milestones
BOTS.md Bot system architecture
GLOSSARY.md Domain terminology
diagrams/ Architecture, ER, sequence, state diagrams (Mermaid)
migrations/README.md Migration file inventory
tests/docs/ Full testing documentation suite

Contributing

See CONTRIBUTING.md for:

  • Development setup
  • Branch & commit conventions
  • Code standards (Go formatting, error handling, naming)
  • How to add new endpoints, models, and handlers
  • Developer recipes (ActivityPub extensions, theming, bots)
  • PR checklist

License

MIT β€” see LICENSE.

About

A modern federated social media application with DID (Decentralized Identity) authentication, End-to-End Encrypted DM's and multiple federated instance servers to choose from. You control what you want to see. Built with Go, Echo framework, and PostgreSQL (Neon Cloud).

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages