# piyushjha0409/lavinth architecture

> Architecture diagram of the GitHub repository piyushjha0409/lavinth, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/piyushjha0409/lavinth
- Repository: https://github.com/piyushjha0409/lavinth

## Overview

Lavinth is a Solana security platform: users and integrating applications inspect wallet activity, receive risk alerts, and take protective actions. Its backend exposes authenticated API workflows for approval revocation, compromise monitoring, alerts, freeze requests, forensics, funds tracing, and transaction simulation; the frontend provides dashboard and wallet-check experiences, while the SDKs expose API capabilities to application developers. The README also describes dusting and address-poisoning detection, transaction filtering, and ecosystem security intelligence. Backend service relationships are shown where the sampled endpoint or service evidence supports them; frontend-to-backend wiring is not established by the excerpts.

Main entry points: [`backend/fetchEndpoint.ts`](https://github.com/piyushjha0409/lavinth/blob/main/backend/fetchEndpoint.ts) (API routes), [`backend/services/revocation-engine.ts`](https://github.com/piyushjha0409/lavinth/blob/main/backend/services/revocation-engine.ts) (Approval revocation), [`sdk/lavinth-sdk/src/lavinth.ts`](https://github.com/piyushjha0409/lavinth/blob/main/sdk/lavinth-sdk/src/lavinth.ts) (Lavinth SDK), [`backend/db/config.ts`](https://github.com/piyushjha0409/lavinth/blob/main/backend/db/config.ts) (PostgreSQL pool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and persistence"]
  node_api_server["API routes<br/>[fetchEndpoint.ts]"]
  node_auth["API key validation<br/>[validateApiKey.ts]"]
  node_db[("PostgreSQL pool<br/>[config.ts]")]
end

subgraph group_security["Security workflows"]
  node_revocation["Approval revocation"]
  node_approval_scan["Approval scanning"]
  node_compromise["Compromise detection"]
  node_alerts["Alert delivery<br/>[alert-manager.ts]"]
  node_exchange["Exchange coordination"]
  node_forensics["Forensic analysis"]
  node_funds["Fund tracing<br/>[fund-tracker.ts]"]
  node_threats["Threat intelligence"]
  node_simulation["Transaction simulation"]
end

subgraph group_frontend["User application"]
  node_frontend["Dashboard and wallet UI<br/>[page.tsx]"]
  node_frontend_api["Frontend API routes"]
end

subgraph group_sdk["Developer SDKs"]
  node_sdk_client["HTTP API client<br/>[client.ts]"]
  node_sdk["Lavinth SDK<br/>[lavinth.ts]"]
  node_react["React provider and hooks<br/>[context.tsx]"]
end

node_users(("Users and integrators"))

node_users -->|"requests security actions"| node_api_server
node_api_server -->|"validates API key"| node_auth
node_auth -->|"checks key and usage"| node_db
node_api_server -->|"builds revocation plan"| node_revocation
node_api_server -->|"registers monitoring"| node_compromise
node_api_server -->|"creates subscriptions"| node_alerts
node_api_server -->|"lists freeze requests"| node_exchange
node_api_server -->|"gets report timeline"| node_forensics
node_revocation -->|"updates recovery status"| node_db
node_alerts -->|"stores notifications"| node_db
node_compromise -->|"uses threat intelligence"| node_threats
node_revocation -->|"uses approval scanner"| node_approval_scan
node_users -->|"uses dashboard"| node_frontend
node_frontend -.->|"uses API routes"| node_frontend_api
node_users -->|"integrates security API"| node_sdk
node_sdk -->|"sends HTTP requests"| node_sdk_client
node_react -->|"creates SDK instance"| node_sdk
node_api_server -.->|"serves approval workflows"| node_approval_scan
node_api_server -.->|"serves fund tracing"| node_funds
node_api_server -.->|"serves simulation"| node_simulation
node_api_server -.->|"supports transaction filtering"| node_threats

click node_api_server "https://github.com/piyushjha0409/lavinth/blob/main/backend/fetchEndpoint.ts"
click node_auth "https://github.com/piyushjha0409/lavinth/blob/main/backend/middlewares/validateApiKey.ts"
click node_db "https://github.com/piyushjha0409/lavinth/blob/main/backend/db/config.ts"
click node_revocation "https://github.com/piyushjha0409/lavinth/blob/main/backend/services/revocation-engine.ts"
click node_approval_scan "https://github.com/piyushjha0409/lavinth/blob/main/backend/services/approval-scanner.ts"
click node_compromise "https://github.com/piyushjha0409/lavinth/blob/main/backend/services/compromise-detector.ts"
click node_alerts "https://github.com/piyushjha0409/lavinth/blob/main/backend/services/alert-manager.ts"
click node_exchange "https://github.com/piyushjha0409/lavinth/blob/main/backend/services/exchange-coordinator.ts"
click node_forensics "https://github.com/piyushjha0409/lavinth/blob/main/backend/services/forensic-analyzer.ts"
click node_funds "https://github.com/piyushjha0409/lavinth/blob/main/backend/services/fund-tracker.ts"
click node_threats "https://github.com/piyushjha0409/lavinth/blob/main/backend/services/threat-intelligence.ts"
click node_simulation "https://github.com/piyushjha0409/lavinth/blob/main/backend/services/transaction-simulator.ts"
click node_frontend "https://github.com/piyushjha0409/lavinth/blob/main/frontend/app/dashboard/page.tsx"
click node_frontend_api "https://github.com/piyushjha0409/lavinth/tree/main/frontend/app/api"
click node_sdk_client "https://github.com/piyushjha0409/lavinth/blob/main/sdk/lavinth-sdk/src/client.ts"
click node_sdk "https://github.com/piyushjha0409/lavinth/blob/main/sdk/lavinth-sdk/src/lavinth.ts"
click node_react "https://github.com/piyushjha0409/lavinth/blob/main/sdk/lavinth-react/src/context.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api_server,node_auth,node_db,node_users toneBlue
class node_revocation,node_approval_scan,node_compromise,node_alerts,node_exchange,node_forensics,node_funds,node_threats,node_simulation toneAmber
class node_frontend,node_frontend_api toneMint
class node_sdk_client,node_sdk,node_react toneRose
```

## Components

### API and persistence

- [API routes](https://github.com/piyushjha0409/lavinth/blob/main/backend/fetchEndpoint.ts): `backend/fetchEndpoint.ts`
- [API key validation](https://github.com/piyushjha0409/lavinth/blob/main/backend/middlewares/validateApiKey.ts): `backend/middlewares/validateApiKey.ts`
- [PostgreSQL pool](https://github.com/piyushjha0409/lavinth/blob/main/backend/db/config.ts): `backend/db/config.ts`

### Security workflows

- [Approval revocation](https://github.com/piyushjha0409/lavinth/blob/main/backend/services/revocation-engine.ts): `backend/services/revocation-engine.ts`
- [Approval scanning](https://github.com/piyushjha0409/lavinth/blob/main/backend/services/approval-scanner.ts): `backend/services/approval-scanner.ts`
- [Compromise detection](https://github.com/piyushjha0409/lavinth/blob/main/backend/services/compromise-detector.ts): `backend/services/compromise-detector.ts`
- [Alert delivery](https://github.com/piyushjha0409/lavinth/blob/main/backend/services/alert-manager.ts): `backend/services/alert-manager.ts`
- [Exchange coordination](https://github.com/piyushjha0409/lavinth/blob/main/backend/services/exchange-coordinator.ts): `backend/services/exchange-coordinator.ts`
- [Forensic analysis](https://github.com/piyushjha0409/lavinth/blob/main/backend/services/forensic-analyzer.ts): `backend/services/forensic-analyzer.ts`
- [Fund tracing](https://github.com/piyushjha0409/lavinth/blob/main/backend/services/fund-tracker.ts): `backend/services/fund-tracker.ts`
- [Threat intelligence](https://github.com/piyushjha0409/lavinth/blob/main/backend/services/threat-intelligence.ts): `backend/services/threat-intelligence.ts`
- [Transaction simulation](https://github.com/piyushjha0409/lavinth/blob/main/backend/services/transaction-simulator.ts): `backend/services/transaction-simulator.ts`

### User application

- [Dashboard and wallet UI](https://github.com/piyushjha0409/lavinth/blob/main/frontend/app/dashboard/page.tsx): `frontend/app/dashboard/page.tsx`
- [Frontend API routes](https://github.com/piyushjha0409/lavinth/tree/main/frontend/app/api): `frontend/app/api`

### Developer SDKs

- [HTTP API client](https://github.com/piyushjha0409/lavinth/blob/main/sdk/lavinth-sdk/src/client.ts): `sdk/lavinth-sdk/src/client.ts`
- [Lavinth SDK](https://github.com/piyushjha0409/lavinth/blob/main/sdk/lavinth-sdk/src/lavinth.ts): `sdk/lavinth-sdk/src/lavinth.ts`
- [React provider and hooks](https://github.com/piyushjha0409/lavinth/blob/main/sdk/lavinth-react/src/context.tsx): `sdk/lavinth-react/src/context.tsx`

### Other components

- **Users and integrators**

## Connections

- Users and integrators → API routes: requests security actions (evidence: `README.md`)
- API routes → API key validation: validates API key (evidence: `backend/fetchEndpoint.ts`)
- API key validation → PostgreSQL pool: checks key and usage (evidence: `backend/middlewares/validateApiKey.ts`)
- API routes → Approval revocation: builds revocation plan (evidence: `backend/fetchEndpoint.ts`)
- API routes → Compromise detection: registers monitoring (evidence: `backend/fetchEndpoint.ts`)
- API routes → Alert delivery: creates subscriptions (evidence: `backend/fetchEndpoint.ts`)
- API routes → Exchange coordination: lists freeze requests (evidence: `backend/fetchEndpoint.ts`)
- API routes → Forensic analysis: gets report timeline (evidence: `backend/fetchEndpoint.ts`)
- Approval revocation → PostgreSQL pool: updates recovery status (evidence: `backend/services/revocation-engine.ts`)
- Alert delivery → PostgreSQL pool: stores notifications (evidence: `backend/services/alert-manager.ts`)
- Compromise detection → Threat intelligence: uses threat intelligence (evidence: `backend/services/compromise-detector.ts`)
- Approval revocation → Approval scanning: uses approval scanner (evidence: `backend/services/revocation-engine.ts`)
- Users and integrators → Dashboard and wallet UI: uses dashboard (evidence: `README.md`)
- Dashboard and wallet UI → Frontend API routes: uses API routes
- Users and integrators → Lavinth SDK: integrates security API (evidence: `README.md`)
- Lavinth SDK → HTTP API client: sends HTTP requests (evidence: `sdk/lavinth-sdk/src/lavinth.ts`)
- React provider and hooks → Lavinth SDK: creates SDK instance (evidence: `sdk/lavinth-react/src/context.tsx`)
- API routes → Approval scanning: serves approval workflows (evidence: `backend/fetchEndpoint.ts`)
- API routes → Fund tracing: serves fund tracing (evidence: `backend/fetchEndpoint.ts`)
- API routes → Transaction simulation: serves simulation (evidence: `backend/fetchEndpoint.ts`)
- API routes → Threat intelligence: supports transaction filtering (evidence: `backend/fetchEndpoint.ts`)
