sumukhbarve / trench

Open source fraud prevention tools

Home Page:https://trytrench.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

logo

GitHub Repo stars License: AGPL v3

Discord - Website - Docs

Getting started

Trench provides a core set of fraud prevention tools to help you collect data on users, identify bad actors, and take action on them (e.g. blocking a payment).

Deploying Trench

You can deploy Trench in one click to Vercel or any hosting service.

Sending data to Trench

You can send user events to Trench via the REST API or using the Javascript SDK.

curl \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  'YOUR_TRENCH_URL/api/event' \
  -d '
{
  "type": "payment",
  "data": {
    "card": {
        "fingerprint": "f2xvb823k",
        "brand": "visa",
        "country": "US",
        "last4": "4242",
    },
    "user": {
      "id": "45912",
      "name": "John Doe",
      "email": "john@email.com"
    },
    ...
  }

Applying decisions

Trench lets you automatically apply decisions to events and objects in your events like users and IP addresses. We use a modified version of SQRL, a rules language from Twitter, which lets you easily write rules with counts and aggregations that can be run on thousands of events per second with sub 100ms latency.

LET Card := entity('Card', jsonValue(EventData, '$.data.card.fingerprint'));
LET User := entity('User', jsonValue(EventData, '$.data.user.id'));

LET NumCards := countUnique(Card BY User LAST Week);

CREATE RULE UserUsedTooManyCards
  WHERE NumCards > 4
  WITH REASON "User ${User} used ${NumCards} in the last week";

WHEN UserUsedTooManyCards THEN
  addEventLabel('$BLOCK', 'too many cards'),
  addEntityLabel(User, '$BLOCKLIST', 'too many cards');

Design Philosophy

  • Full customization. You know your product and user interactions better than anyone else. To be effective, you should have full control over the data you collect and integrate.
  • Full access to your data. You shouldn’t be limited to dashboards and reports. Full access to your data is needed to properly understand your fraud.

Local development

  1. Clone the repository
  2. Go to dashboard project: cd dashboard
  3. Install dependencies: yarn or npm i
  4. Run the development server: yarn dev or npm run dev

Join our community

Join the Trench community in Discord if you need support or have anything you'd like to ask. We'd love to chat!

About

Open source fraud prevention tools

https://trytrench.com

License:GNU Affero General Public License v3.0


Languages

Language:TypeScript 97.0%Language:JavaScript 1.9%Language:PLpgSQL 0.4%Language:CSS 0.3%Language:Dockerfile 0.2%Language:Lua 0.1%