Skip to content

About

Reusable Filament plugin for fraud-detection network visualizations: device relationship map and referral network explorer

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Filament Network Explorer

CI PHP 8.3+ Laravel 12 | 13 Filament 5 PHPStan level 10 Tests: Pest License: MIT

Filament Network Explorer: see how users, devices and players connect in one interactive 3D graph

A Filament plugin that shows how your users, devices and players are connected, as an interactive 3D picture. Use it for fraud checks, abuse reviews and community insights.

Tutorial: a tour of every page, at 3x speed

▶ Watch the tutorial video (MP4, 3 minutes). The preview above plays at 3x.

What you get

Page Shows
Relationship map Items that share details, for example phones that share accounts.
Referral explorer Who invited whom, top referrers and self-referrals.
Following explorer Who follows whom, communities, and one person's network.
Co-play explorer Who plays with whom, and how often.
Quick look A dialog with one person's links and their rewards per year.
Related graph action A row action that opens one node's graph in a slide-over or on the page.

Every page also works in a client panel, where ids and details are hidden.

Referral network Following network
Referral tree: each branch keeps its own slice, arrows point from inviter to invitee One person's network: green lines are mutual follows
Relationship map Quick look dialog
Groups of items that share details Quick look: partners and reward redemptions per year
Co-play group Client view (ids hidden)
Players linked by matches played together Client view of a referral network
Related graph slide-over Follow explorer overview
A table row opening that person's graph in a slide-over Follow communities and insights
Dark mode Phone
The referral tree in dark mode A co-play group on a phone
More screens
Entity details next to the map Referral networks, biggest first
Co-play highlights and groups Co-play group in a client panel
Relationship map in a client panel Following highlights in a client panel

How it works

flowchart LR
    A[(Your tables)] -->|rebuild job| B[(Summary tables)]
    B --> C[Plugin loads only<br/>what the page needs]
    C --> D{Panel}
    D -->|Admin| E[Full details]
    D -->|Client| F[Ids hidden]
    E --> G[3D picture<br/>in the browser]
    F --> G
Loading
  1. A rebuild job turns your tables into small summary tables. The heavy work happens here, not when someone opens a page.
  2. A page first loads a short list, and loads one network or group only when you open it. Answers are cached until the data changes.
  3. The browser draws the picture in 3D, or in 2D if 3D is not available.

Install

Requires PHP 8.3+, Laravel 12 or 13, and Filament 5.7+. The package lives in a private repository, so add it to composer.json as a VCS repository first.

composer require solutionforest/filament-network-explorer
php artisan migrate
php artisan filament:assets

Add the plugin to a panel:

use SolutionForest\FilamentNetworkExplorer\NetworkExplorerPlugin;

return $panel
    ->plugin(NetworkExplorerPlugin::make()->navigationGroup('Fraud'));

Connect your data

Describe each graph once, in a service provider:

use SolutionForest\FilamentNetworkExplorer\Facades\NetworkGraph;

// Who invited whom: one parent column on your users table.
NetworkGraph::tree('referrals')->model(User::class)->parentKey('referred_by_id');

// Who follows whom: a pivot table.
NetworkGraph::directed('follows')->pivot('follows', from: 'follower_id', to: 'followee_id');

// Who plays with whom: players linked by the matches they share.
NetworkGraph::shared('co-play')->pivot('match_players', node: 'user_id', via: 'match_id');

// Show "26 (ada)" instead of the id, and let search match those columns.
NetworkGraph::nodes(User::class)
    ->label('{id} ({username})')
    ->search('username', 'email');

Then build the summary tables, and schedule the same command:

php artisan network-graph:rebuild --sync

After the first run, a rebuild only updates the networks that changed.

Quick look

Add a quick look to any table row. It shows the person's key numbers, who they are linked to, and their activity per year. Open full view opens the explorer on that person.

use SolutionForest\FilamentNetworkExplorer\Actions\QuickLookAction;

$table->recordActions([
    QuickLookAction::make()->graph('referrals'),
]);

To also count rewards per year in the dialog, register the table that records them:

NetworkGraph::activity('reward-redemptions')
    ->label('Reward redemptions')
    ->model(RewardRedemption::class)
    ->actor('user_id')
    ->item('reward_id')
    ->occurredAt('redeemed_at')
    ->labels('rewards', 'id', 'name')   // show reward names instead of ids
    ->showOn('referrals', 'co-play');   // the graphs whose quick look shows it

It is one query per person. Add an (user_id, redeemed_at) index on big tables.

You can also use QuickLookWidget::make(['graph' => 'follows']) on a dashboard, the Quick look page, or NetworkGraph::quickLook('referrals', '42') in code.

Related graph action

Open a row's relationship graph without leaving the table. The same explorer that powers the full page mounts in a slide-over, already focused on that node. Open full view (or the page variant) goes to the full explorer instead.

use SolutionForest\FilamentNetworkExplorer\Actions\RelatedGraphAction;

$table->recordActions([
    // Slide-over (the default).
    RelatedGraphAction::make()->graph('follows'),

    // Full page, deep-linked with `?focus=`.
    RelatedGraphAction::make('openFollowGraph')
        ->label('Open full view')
        ->graph('follows')
        ->page(),
]);

Use ->kind('directed') (or 'tree' / 'shared') to name the kind instead of the graph. The row key is the node id; pass another id with ->node(fn (User $record) => $record->uuid). It works for the tree, directed and shared graph the panel shows: the action hides itself when the panel has that explorer turned off. Tree and shared graphs open the row's whole network or group; a directed graph opens the person's ego network. Client panels get handles, never raw ids.

The workbench demo has a Follow people resource with both presentations.

Client panel

Use a second panel for people who should only see a safe, read-only view:

NetworkExplorerPlugin::make()->clientView();

Ids become short labels like #c04e5f92 that can't be reversed, and a person keeps the same label on every screen. Clicks still work, because each item carries an encrypted handle that only the server can read.

Settings

Method What it does
clientView() Hide ids and details in this panel.
graphs(['referrals', 'follows']) Show only these graphs in this panel.
entityMap(false), referralExplorer(false) Hide a page.
followExplorer(), sharedExplorer() Show the following or co-play page.
quickLookPage(false) Hide the quick look page.
sharedAcrossTenants() Show the graphs in a panel with tenancy. See Multi-tenant panels.
navigationGroup('Fraud') Group the pages in the navigation.
cacheTtl(300) How long answers are cached, in seconds.
maxNodesPerView(5000) The most dots in one picture.
explorers([...]) Rename, reorder or add explorers. See Extending.

Options also take a Closure, as elsewhere in Filament. clientView() and graphs() are the exceptions, because they decide which pages a panel registers.

Make it yours

use SolutionForest\FilamentNetworkExplorer\Explorers\FollowExplorer;

NetworkExplorerPlugin::make()->explorers([
    FollowExplorer::make()
        ->navigationLabel('Fans')
        ->description('Who follows our creators.')
        ->visible(fn (): bool => auth()->user()->can('viewFans')),
]);

A new explorer is one class with a page and a widget: see Extending. All wording can be translated, the colours follow your panel's primary colour, and every --ne-* CSS variable can be overridden in your theme.

For app-wide defaults, publish the config: php artisan vendor:publish --tag=filament-network-explorer-config. After every upgrade run php artisan filament:assets (or filament:upgrade).

More detail, including your own data sources, the summary tables and the data endpoints, is in the reference.

Multi-tenant panels

The bundled tables have no tenant column, so they cannot tell tenants apart. To keep one tenant from seeing another's data, a panel with Filament tenancy (->tenant(...)) shows nothing by default: the pages, widgets, quick look, table actions and data endpoints are all off.

If the graph is meant to be the same for every tenant, for example company-wide data, opt in:

NetworkExplorerPlugin::make()->sharedAcrossTenants();

To give each tenant its own graph, bind your own sources that filter by GraphScope::$tenantId (see the reference), then opt in the same way. Payload caches are already kept apart per tenant.

Try the demo

composer install
vendor/bin/testbench workbench:build
vendor/bin/testbench serve --host=127.0.0.1 --port=8123

Open http://127.0.0.1:8123/admin (or /client). You are signed in automatically. With the demo running, npm run docs:capture refreshes the screenshots and the tutorial video (it needs Playwright and ffmpeg). It fails instead of saving a screenshot that disagrees with the API.

Development

composer test   # Pest + PHPStan level 10
composer pint   # code style
npm test        # frontend tests
npm run build   # rebuild resources/dist after JS changes

CI runs all of these on PHP 8.3 and 8.4, on the self-hosted runners. It also checks that the committed JavaScript bundle is up to date. See the contributor guide for architecture, naming, testing and performance rules.

Brand assets

The README cover, the GitHub social preview and the Filament plugin icon are committed in docs/images/, with their editable SVG sources. Regenerate all of them with:

npm run docs:images

License

MIT. See LICENSE.md.

About

Reusable Filament plugin for fraud-detection network visualizations: device relationship map and referral network explorer

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages