{"id":21827030,"url":"https://github.com/frigadehq/trench","last_synced_at":"2025-05-14T05:11:16.049Z","repository":{"id":258029181,"uuid":"865585945","full_name":"FrigadeHQ/trench","owner":"FrigadeHQ","description":"Trench — Open-Source Analytics Infrastructure. A single production-ready Docker image built on ClickHouse, Kafka, and Node.js for tracking events, page views. Easily build product analytics dashboards, LLM RAGs, observability platforms, or any other analytics product.","archived":false,"fork":false,"pushed_at":"2025-05-01T19:55:49.000Z","size":6128,"stargazers_count":1550,"open_issues_count":3,"forks_count":55,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-08T09:19:18.787Z","etag":null,"topics":["analytics","clickhouse","clickhouse-database","clickhouse-server","dashboard","dashboards","event-replay","kafka","kafka-engine","llm","matomo","matomo-analytics","nodejs","open-source","plausible-analytics","posthog","product-analytics","rag","tracking","tracking-events"],"latest_commit_sha":null,"homepage":"https://trench.dev","language":"TypeScript","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/FrigadeHQ.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}},"created_at":"2024-09-30T19:19:01.000Z","updated_at":"2025-05-07T20:56:41.000Z","dependencies_parsed_at":"2024-10-24T23:11:44.716Z","dependency_job_id":"fc3a0c0a-d066-45a7-8ca3-33c67672eea4","html_url":"https://github.com/FrigadeHQ/trench","commit_stats":{"total_commits":159,"total_committers":9,"mean_commits":"17.666666666666668","dds":0.2515723270440252,"last_synced_commit":"ab6c7c9d1872a61e87286a18609b6865e9c1bd76"},"previous_names":["frigadehq/trench"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrigadeHQ%2Ftrench","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrigadeHQ%2Ftrench/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrigadeHQ%2Ftrench/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrigadeHQ%2Ftrench/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FrigadeHQ","download_url":"https://codeload.github.com/FrigadeHQ/trench/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253678837,"owners_count":21946314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["analytics","clickhouse","clickhouse-database","clickhouse-server","dashboard","dashboards","event-replay","kafka","kafka-engine","llm","matomo","matomo-analytics","nodejs","open-source","plausible-analytics","posthog","product-analytics","rag","tracking","tracking-events"],"created_at":"2024-11-27T18:11:56.378Z","updated_at":"2025-05-14T05:11:10.996Z","avatar_url":"https://github.com/FrigadeHQ.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://trench.dev?utm_source=github\" target=\"_blank\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"/img/trench-dark.png\"\u003e\n    \u003cimg alt=\"Trench Logo\" src=\"/img/trench-light.png\" width=\"220\"/\u003e\n  \u003c/picture\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cbr/\u003e\n\n\u003ch1 align=\"center\"\u003eOpen-Source Analytics Infrastructure\u003c/h1\u003e\n\n  \u003cp align=\"center\"\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://docs.trench.dev\" rel=\"dofollow\"\u003e\u003cstrong\u003eDocumentation\u003c/strong\u003e\u003c/a\u003e · \n   \u003ca href=\"https://trench.dev\" rel=\"dofollow\"\u003e\u003cstrong\u003eWebsite\u003c/strong\u003e\u003c/a\u003e · \n   \u003ca href=\"https://join.slack.com/t/trench-community/shared_invite/zt-2sjet5kh2-v31As3yC_zRIadk_AGn~3A\"\u003e\u003cstrong\u003eSlack Community\u003c/strong\u003e\u003c/a\u003e · \n    \u003ca href=\"https://demo.trench.dev\"\u003e\u003cstrong\u003eDemo\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr/\u003e\n    \u003cbr/\u003e\n  \u003c/p\u003e\n\n## 🌊 What is Trench?\n\nTrench is an event tracking system built on top of Apache Kafka and ClickHouse. It can handle large event volumes and provides real-time analytics. Trench is no-cookie, GDPR, and PECR compliant. Users have full control to access, rectify, or delete their data.\n\nOur team built Trench to scale up the real-time event tracking pipeline at \u003ca href=\"https://frigade.com?utm_source=github-trench-readme\" target=\"_blank\"\u003eFrigade\u003c/a\u003e.\n\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"/img/trench-cover.png\"\u003e\n    \u003cimg src=\"/img/trench-cover.png\" width=\"100%\" alt=\"Trench Code Snippet\" /\u003e\n  \u003c/picture\u003e\n\n## ⭐ Features\n\n- 🤝 Compliant with the Segment API (Track, Group, Identify)\n- 🐳 Deploy quickly with a single production-ready Docker image\n- 💻 Process thousands of events per second on a single node\n- ⚡ Query data in real-time\n- 🔗 Connect data to other destinations with webhooks\n- 👥 Open-source and MIT Licensed\n\n## 🖥️ Demo\n\n**Live demo:**\n[https://demo.trench.dev](https://demo.trench.dev)\n\n**Video demo:**\n\nWatch the following demo to see how you can build a basic version of Google Analytics using Trench and Grafana.\n\nhttps://github.com/user-attachments/assets/e3f64590-6e7e-41b9-b425-7adb5a1e19b1\n\n## 🚀 Quickstart\n\nTrench has two methods of deployment:\n\n1. **Trench Self-Hosted**: An open-source version to deploy and manage Trench on your own infrastructure.\n2. **Trench Cloud**: A fully-managed serverless solution with zero ops, autoscaling, and 99.99% SLAs.\n\n### 1. Trench Self-Hosted 💻\n\nFollow our self-hosting instructions below and in our [quickstart guide](https://docs.trench.dev/quickstart) to begin using Trench Self-Hosted.\n\nIf you have questions or need assistance, you can join our [Slack group](https://join.slack.com/t/trench-community/shared_invite/zt-2sjet5kh2-v31As3yC_zRIadk_AGn~3A) for support.\n\n#### Quickstart\n\n1. **Deploy Trench Dev Server**:\n   The only prerequisite for Trench is a system that has Docker and Docker Compose installed [see installation guide](https://docs.docker.com/compose/install/). We recommend having at least 4GB of RAM and 4 CPU cores for optimal performance if you're running a production environment.\n\n   After installing Docker, you can start the local development server by running the following commands:\n\n   ```sh\n   git clone https://github.com/frigadehq/trench.git\n   cd trench/apps/trench\n   cp .env.example .env\n   docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --build --force-recreate --renew-anon-volumes\n   ```\n\n   The above command will start the Trench server that includes a local ClickHouse and Kafka instance on `http://localhost:4000`. You can open this URL in your browser and you should see the message `Trench server is running`. You shouldupdate the `.env` file to change any of the configuration options.\n\n2. **Send a sample event**:\n   You can find and update the default public and private API key in the `.env` file. Using your public API key, you can send a sample event to Trench as such:\n\n   ```sh\n   curl -i -X POST \\\n      -H \"Authorization:Bearer public-d613be4e-di03-4b02-9058-70aa4j04ff28\" \\\n      -H \"Content-Type:application/json\" \\\n      -d \\\n   '{\n     \"events\": [\n       {\n         \"userId\": \"550e8400-e29b-41d4-a716-446655440000\",\n         \"type\": \"track\",\n         \"event\": \"ConnectedAccount\",\n         \"properties\": {\n           \"totalAccounts\": 4,\n           \"country\": \"Denmark\"\n         },\n       }]\n   }' \\\n    'http://localhost:4000/events'\n   ```\n\n3. **Querying events**:\n   You can query events using the `/events` endpoint (see [API reference](https://docs.trench.dev/api-reference/events-get) for more details).\n\n   You can also query events directly from your local Trench server. For example, to query events of type `ConnectedAccount`, you can use the following URL:\n\n   ```sh\n   curl -i -X GET \\\n      -H \"Authorization: Bearer private-d613be4e-di03-4b02-9058-70aa4j04ff28\" \\\n      'http://localhost:4000/events?event=ConnectedAccount'\n   ```\n\n   This will return a JSON response with the event that was just sent:\n\n   ```json\n   {\n     \"results\": [\n       {\n         \"uuid\": \"25f7c712-dd86-4db0-89a8-d07d11b73e57\",\n         \"type\": \"track\",\n         \"event\": \"ConnectedAccount\",\n         \"userId\": \"550e8400-e29b-41d4-a716-446655440000\",\n         \"properties\": {\n           \"totalAccounts\": 4,\n           \"country\": \"Denmark\"\n         },\n         \"timestamp\": \"2024-10-22T19:34:56.000Z\",\n         \"parsedAt\": \"2024-10-22T19:34:59.530Z\"\n       }\n     ],\n     \"limit\": 1000,\n     \"offset\": 0,\n     \"total\": 1\n   }\n   ```\n\n4. **Execute raw SQL queries**:\n   Use the queries endpoint to analyze your data. Example:\n\n   ```sh\n   curl -i -X POST \\\n      -H \"Authorization:Bearer public-d613be4e-di03-4b02-9058-70aa4j04ff28\" \\\n      -H \"Content-Type:application/json\" \\\n      -d \\\n   '{\n     \"queries\": [\n       \"SELECT COUNT(*) FROM events WHERE userId = '550e8400-e29b-41d4-a716-446655440000'\"\n     ]\n   }' \\\n    'http://localhost:4000/queries'\n   ```\n\n   Sample query result:\n\n   ```json\n   {\n     \"results\": [\n       {\n         \"count\": 5\n       }\n     ],\n     \"limit\": 0,\n     \"offset\": 0,\n     \"total\": 1\n   }\n   ```\n\n### 2. Trench Cloud ☁️\n\nIf you don't want to selfhost, you can get started with Trench in a few minutes via:\n* our [Cloud web interface](https://app.trench.dev/sign-up)\n* our [Cloud quickstart guide](https://docs.trench.dev/cloud-quickstart)\n\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"/img/trench-dashboard-dark.png\"\u003e\n  \u003cimg src=\"/img/trench-dashboard.png\" width=\"100%\" alt=\"Trench Code Snippet\" /\u003e\n\u003c/picture\u003e\n\n## 🔗 Links\n\n- [Website](https://trench.dev?utm_campaign=github-readme)\n- [Documentation](https://docs.trench.dev/)\n- [Slack community](https://join.slack.com/t/trench-community/shared_invite/zt-2sjet5kh2-v31As3yC_zRIadk_AGn~3A)\n\n## 📚 Authors\n\nTrench is a project built by [Frigade](https://frigade.com).\n\n## 📄 License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrigadehq%2Ftrench","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrigadehq%2Ftrench","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrigadehq%2Ftrench/lists"}