blnk

package module
v0.0.0-...-1cb5593 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

README

Blnk logo

Status at a Glance

Build and Test Status Deploy to Docker Status Linter Status Contributor Covenant

Open-source fintech ledger for the internet

Blnk Ledger is an open-source fintech database for building fintech products to standard and at scale. We designed Blnk to help developers do three things well:

  1. Accurately record transactions in their system.
  2. Correctly manage complex flow of funds and transaction data.
  3. Reliably manage the size of your transactions as your product scales.

About Blnk

Building fintech starts off simple, and gets quickly difficult & complex the more time you spend with it. Blnk offers specialized tools to help developers today manage and navigate this complexity correctly for their respective organizations.

Every fintech product is made up of transactions — happening concurrently, moving all the time from one place to another. Sometimes, they will interact with parties outside of your application like cards, deposits, bank accounts, etc; sometimes, they happen within your application between user balances or to/fro your organization accounts.

With Blnk, you get a full-service starting point for building, managing and operating money movement and store of value in a reliable, secure and scaleable way. Here are some use-cases of the Blnk Ledger:

Quickstart

The fastest way to get acquainted with Blnk is by installing Blnk. If you'd like to read more information about how Blnk works, you can get started here:

Installation

To install Blnk, make sure you have Docker and Compose installed and running on your machine.

To get started with Blnk, first clone the repository into your machine:

git clone https://github.com/blnkledger/Blnk && cd Blnk

and create a configuration file, blnk.json:

touch blnk.json

then copy and save the following configuration:

{
  "project_name": "Blnk",
  "data_source": {
    "dns": "postgres://postgres:password@postgres:5432/blnk?sslmode=disable"
  },
  "redis": {
    "dns": "redis:6379"
  },
  "server": {
    "domain": "blnk.io",
    "ssl": false,
    "ssl_email": "jerryenebeli@gmail.com",
    "port": "5001"
  },
  "notification": {
    "slack": {
      "webhook_url": "https://hooks.slack.com"
    }
  }
}

then start your Blnk server with Docker Compose:

docker compose up

Contributions

Contributions and feedback are welcome and encouraged. Join our Discord community to do so, and connect with other developers from around the world.

License

This project uses the Apache License 2.0.

Documentation

Index

Constants

View Source
const (
	StatusQueued    = "QUEUED"
	StatusApplied   = "APPLIED"
	StatusScheduled = "SCHEDULED"
	StatusInflight  = "INFLIGHT"
	StatusVoid      = "VOID"
	StatusRejected  = "REJECTED"
)
View Source
const EXPIREDINFLIGHT_QUEUE = "new:inflight-expiry"
View Source
const (
	GeneralLedgerID = "general_ledger_id"
)
View Source
const NumberOfQueues = 20
View Source
const TRANSACTION_QUEUE = "new:transaction"
View Source
const WEBHOOK_QUEUE = "new:webhoook"

Variables

View Source
var SQLFiles embed.FS

Functions

func EnsureCollectionsExist

func EnsureCollectionsExist(client *TypesenseClient, ctx context.Context) error

func Init

func Init(ctx context.Context, service string) trace.Tracer

Init returns an instance of Jaeger Tracer.

func NewBalanceTracker

func NewBalanceTracker() *model.BalanceTracker

func ProcessWebhook

func ProcessWebhook(_ context.Context, task *asynq.Task) error

func SendWebhook

func SendWebhook(newWebhook NewWebhook) error

Types

type Blnk

type Blnk struct {
	// contains filtered or unexported fields
}

func NewBlnk

func NewBlnk(db database.IDataSource) (*Blnk, error)

func (*Blnk) CommitInflightTransaction

func (l *Blnk) CommitInflightTransaction(ctx context.Context, transactionID string, amount float64) (*model.Transaction, error)

func (*Blnk) CreateAccount

func (l *Blnk) CreateAccount(account model.Account) (model.Account, error)

CreateAccount creates a new account in the database.

func (*Blnk) CreateBalance

func (l *Blnk) CreateBalance(balance model.Balance) (model.Balance, error)

func (*Blnk) CreateIdentity

func (l *Blnk) CreateIdentity(identity model.Identity) (model.Identity, error)

func (*Blnk) CreateLedger

func (l *Blnk) CreateLedger(ledger model.Ledger) (model.Ledger, error)

func (*Blnk) CreateMonitor

func (l *Blnk) CreateMonitor(monitor model.BalanceMonitor) (model.BalanceMonitor, error)

func (*Blnk) DeleteIdentity

func (l *Blnk) DeleteIdentity(id string) error

func (*Blnk) DeleteMonitor

func (l *Blnk) DeleteMonitor(id string) error

func (*Blnk) GetAccount

func (l *Blnk) GetAccount(id string, include []string) (*model.Account, error)

func (*Blnk) GetAccountByNumber

func (l *Blnk) GetAccountByNumber(id string) (*model.Account, error)

GetAccountByNumber retrieves an account from the database by ID.

func (*Blnk) GetAllAccounts

func (l *Blnk) GetAllAccounts() ([]model.Account, error)

GetAllAccounts retrieves all accounts from the database.

func (*Blnk) GetAllBalances

func (l *Blnk) GetAllBalances() ([]model.Balance, error)

func (*Blnk) GetAllIdentities

func (l *Blnk) GetAllIdentities() ([]model.Identity, error)

func (*Blnk) GetAllLedgers

func (l *Blnk) GetAllLedgers() ([]model.Ledger, error)

func (*Blnk) GetAllMonitors

func (l *Blnk) GetAllMonitors() ([]model.BalanceMonitor, error)

func (*Blnk) GetAllTransactions

func (l *Blnk) GetAllTransactions() ([]model.Transaction, error)

func (*Blnk) GetBalanceByID

func (l *Blnk) GetBalanceByID(id string, include []string) (*model.Balance, error)

func (*Blnk) GetBalanceByIndicator

func (l *Blnk) GetBalanceByIndicator(indicator, currency string) (*model.Balance, error)

func (*Blnk) GetBalanceMonitors

func (l *Blnk) GetBalanceMonitors(balanceId string) ([]model.BalanceMonitor, error)

func (*Blnk) GetIdentity

func (l *Blnk) GetIdentity(id string) (*model.Identity, error)

func (*Blnk) GetLedgerByID

func (l *Blnk) GetLedgerByID(id string) (*model.Ledger, error)

func (*Blnk) GetMonitorByID

func (l *Blnk) GetMonitorByID(id string) (*model.BalanceMonitor, error)

func (*Blnk) GetTransaction

func (l *Blnk) GetTransaction(TransactionID string) (*model.Transaction, error)

func (*Blnk) GetTransactionByRef

func (l *Blnk) GetTransactionByRef(cxt context.Context, reference string) (model.Transaction, error)

func (*Blnk) QueueTransaction

func (l *Blnk) QueueTransaction(ctx context.Context, transaction *model.Transaction) (*model.Transaction, error)

func (*Blnk) RecordTransaction

func (l *Blnk) RecordTransaction(ctx context.Context, transaction *model.Transaction) (*model.Transaction, error)

func (*Blnk) RefundTransaction

func (l *Blnk) RefundTransaction(transactionID string) (*model.Transaction, error)

func (*Blnk) RejectTransaction

func (l *Blnk) RejectTransaction(ctx context.Context, transaction *model.Transaction, reason string) (*model.Transaction, error)

func (*Blnk) Search

func (l *Blnk) Search(collection string, query *api.SearchCollectionParams) (interface{}, error)

func (*Blnk) UpdateIdentity

func (l *Blnk) UpdateIdentity(identity *model.Identity) error

func (*Blnk) UpdateMonitor

func (l *Blnk) UpdateMonitor(monitor *model.BalanceMonitor) error

func (*Blnk) UpdateTransactionStatus

func (l *Blnk) UpdateTransactionStatus(id string, status string) error

func (*Blnk) VoidInflightTransaction

func (l *Blnk) VoidInflightTransaction(ctx context.Context, transactionID string) (*model.Transaction, error)

type NewWebhook

type NewWebhook struct {
	Event   string      `json:"event"`
	Payload interface{} `json:"data"`
}

type NotificationPayload

type NotificationPayload struct {
	Table string                 `json:"table"`
	Data  map[string]interface{} `json:"data"` // This structure may need to be adjusted based on your actual data
}

type Queue

type Queue struct {
	Client    *asynq.Client
	Inspector *asynq.Inspector
}

func NewQueue

func NewQueue(conf *config.Configuration) *Queue

func (*Queue) Enqueue

func (q *Queue) Enqueue(_ context.Context, transaction *model.Transaction) error

type TransactionTypePayload

type TransactionTypePayload struct {
	Data model.Transaction
}

type TypesenseClient

type TypesenseClient struct {
	Client *typesense.Client
}

func NewTypesenseClient

func NewTypesenseClient(apiKey string, hosts []string) *TypesenseClient

func (*TypesenseClient) CreateCollection

func (t *TypesenseClient) CreateCollection(ctx context.Context, schema *api.CollectionSchema) (*api.CollectionResponse, error)

func (*TypesenseClient) HandleNotification

func (t *TypesenseClient) HandleNotification(table string, data map[string]interface{}) error

func (*TypesenseClient) Search

func (t *TypesenseClient) Search(ctx context.Context, collection string, searchParams *api.SearchCollectionParams) (*api.SearchResult, error)

type TypesenseError

type TypesenseError struct {
	Message string `json:"message"`
}

Directories

Path Synopsis
api
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL