algosearch

module
v0.0.0-...-8401909 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: Apache-2.0

README

AlgoSearch

Introduction

AlgoSearch is an open-sourced project that enables you to explore and search the Algorand blockchain for transactions, blocks, addresses, assets, statistics, and more, in real-time. It's a simple, easy-to-deploy, and open-source block explorer to be used alongside an Algorand archival node.

It contains 3 services:

  • Frontend app
    • The website of AlgoSearch
  • RESTful API server
    • It connects to the Algorand archival node (and indexer, optional) and serves a set of API endpoints for the frontend to consume.
  • Metrics server (optional)
    • It connects to the RESTful API and monitors its status

Usage

Prerequisities

Make sure you have a CouchDB database set up and a working Algorand node, ideally an archival node.

If you want to do tracing, you can set up Zipkin too.

CouchDB

If you want to start a CouchDB quickly in your local environment, you can run this command to start one using Docker:

make run-couch
Getting Started
Using Docker

You can start the container with a Docker image which already contains all the three services (RESTful API, metrics and frontend):

docker run \
  -e ALGOSEARCH_WEB_ENABLE_SYNC=true \
  -e ALGOSEARCH_WEB_SYNC_INTERNAL=5s \
  -e ALGOSEARCH_COUCH_DB_HOST=234.567.89.0:5984 \
  -e ALGOSEARCH_COUCH_DB_USER=algorand \
  -e ALGOSEARCH_COUCH_DB_PASSWORD=algorand \
  -e ALGOSEARCH_COUCH_DB_NAME=algosearch \
  -e ALGOSEARCH_ALGOD_PROTOCOL=http \
  -e ALGOSEARCH_ALGOD_ADDR=234.567.89.0:4001 \
  -e ALGOSEARCH_ALGOD_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
  -e ALGOSEARCH_ZIPKIN_REPORTER_URI=http://234.567.89.0:9411/api/v2/spans \
  -e NEXT_PUBLIC_API_URL=http://0.0.0.0:5000 \
  -e NEXT_PUBLIC_ALGOD_PROTOCOL=http \
  -e NEXT_PUBLIC_ALGOD_ADDR=0.0.0.0:4001 \
  -e NEXT_PUBLIC_ALGOD_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
  -e METRICS_COLLECT_FROM=http://0.0.0.0:4000/debug/vars \
  algosearch:1.1

Please modify NEXT_PUBLIC_API_URL only when you are trying to connect to another backend.

Please modify METRICS_COLLECT_FROM only when you are trying to collect metrics from another RESTful API.

NEXT_PUBLIC_ALGOD_PROTOCOL, NEXT_PUBLIC_ALGOD_ADDR, and NEXT_PUBLIC_ALGOD_TOKEN are needed for disassembly of LogicSig, approval program, and clear state program on the transaction page. The feature is only available when NEXT_PUBLIC_ALGOD_ADDR contains 0.0.0.0 or 127.0.0.1 or localhost.

Using Docker-Compose

You can also use docker-compose to start all the services with each of them in separate Docker images.

Go inside PROJECT_FOLDER/zarf/compose/compose-config.yaml and change the environment variables accordingly, and then make use of these commands:

# Start everything using docker-compose
make up

# See the logs
make logs

# Stop the containers
make down

To build the docker images yourself:

# RESTful API
# algosearch-backend:1.1
make algosearch-backend
# algosearch-backend:latest
make algosearch-backend-latest

# Frontend
# algosearch-frontend:1.1
make algosearch-frontend
# algosearch-frontend:latest
make algosearch-frontend-latest

# Metrics
# algosearch-metrics:1.1
make algosearch-metrics
# algosearch-metrics:latest
make algosearch-metrics-latest

Additionally, here are some useful commands for Docker:

# Stop and remove all containers (not only AlgoSearch)
make docker-down-local

# See logging of all containers
make docker-logs-local

# Clean and remove all docker images
make docker-clean
Running Locally

To run AlgoSearch locally, you need to have the following dependencies:

  • npm/yarn, for building and starting the frontend app
  • golang, for building and starting the backend services
  • a couchdb connection, for the backend RESTful API to store and retrieve data
Installation

Install the dependencies for frontend and the other services:

# Install all the dependencies for RESTful API and metric services
make tidy

# Install dependencies for frontend app
cd frontend
yarn install
CouchDB

If you haven't set up a database on CouchDB for AlgoSearch to use, run this command with the appropriate credentials to set it up:

go run backend/app/algo-admin/main.go \
		--couch-db-protocol=http \
		--couch-db-user=admin \
		--couch-db-password=password \
		--couch-db-host=0.0.0.0:5984 \
		--couch-db-name=algosearch \
		migrate
Backend

Both the restful API and metric services are configurable. Run the following commands to see what variables that can be configured through command line arguments or environment variables:

# RESTful API
go run ./backend/app/algosearch/main.go --help

# Metrics
go run ./backend/app/sidecar/metrics/main.go --help

Note that their default values are all set to be compatible with Algorand's sandbox.

RESTful API Service

Start the API service:

go run ./backend/app/algosearch/main.go

# OR this, which is the same command but with
# better logging format
make start-algosearch-backend

If you are connecting to the API to sandbox, run:

make start-sandbox-algosearch-backend
Metric Service

Start the metric service:

go run ./backend/app/sidecar/metrics/main.go

# OR this, which is the same command but with
# better logging format
make start-algosearch-metrics

If you are connecting the metric service to work with the sandbox, run:

make start-sandbox-algosearch-backend
Frontend

Go inside the frontend folder:

cd frontend

yarn dev
# OR
yarn build
yarn start

Core Team


Kevin Lai

Core Services


Golang, Linkin Park, South Park, and Red Bull


Fionna Chan

Frontend & UI/UX Design


Making the world a better place with OSS, one line at a time


Thomas Upfield

Documentation & Business Relations


Algorand Evangelist. DeFi, tokenomics, and analytics

Special Thanks to

  • @ardanlabs for service, which taught us everything we know about Golang and offering a well-designed sample API service as our foundation.

  • @Anish-Agnihotri for his contribution to the original AlgoSearch written with create-react-app and a Node.js backend.

Licensing

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Directories

Path Synopsis
backend
app/algo-admin/commands
Package commands contains the functionality for the set of commands currently supported by the CLI tooling.
Package commands contains the functionality for the set of commands currently supported by the CLI tooling.
app/algosearch/handlers
Package handlers contains the full set of handler functions and routes supported by the web api.
Package handlers contains the full set of handler functions and routes supported by the web api.
app/algosearch/handlers/apidoc/swaggergrp
Package swaggergrp maintains the group of handlers for serving swagger documentation.
Package swaggergrp maintains the group of handlers for serving swagger documentation.
app/algosearch/handlers/debug/checkgrp
Package checkgrp maintains the group of handlers for health checking.
Package checkgrp maintains the group of handlers for health checking.
app/algosearch/handlers/debug/samplegrp
Package samplegrp maintains the group of handlers for sample endpoints.
Package samplegrp maintains the group of handlers for sample endpoints.
app/algosearch/handlers/v1
Package v1 contains the full set of handler functions and routes supported by the v1 web api.
Package v1 contains the full set of handler functions and routes supported by the v1 web api.
app/algosearch/handlers/v1/productgrp
Package productgrp maintains the group of handlers for product access.
Package productgrp maintains the group of handlers for product access.
app/algosearch/handlers/v1/usergrp
Package usergrp maintains the group of handlers for user access.
Package usergrp maintains the group of handlers for user access.
app/logfmt
This program takes the structured log output and makes it readable.
This program takes the structured log output and makes it readable.
app/sidecar/metrics/collector
Package collector is a simple collector for
Package collector is a simple collector for
app/sidecar/metrics/publisher
Package publisher manages the publishing of metrics.
Package publisher manages the publishing of metrics.
app/sidecar/metrics/publisher/datadog
Package datadog provides support for publishing metrics to DD.
Package datadog provides support for publishing metrics to DD.
app/sidecar/metrics/publisher/expvar
Package expvar manages the publishing of metrics to stdout.
Package expvar manages the publishing of metrics to stdout.
business/core/account
Package account provides the core business API of handling everything account related.
Package account provides the core business API of handling everything account related.
business/core/account/db
Package db contains account related CRUD functionality.
Package db contains account related CRUD functionality.
business/core/algod
Package algod provides the core business API of handling everything algod related.
Package algod provides the core business API of handling everything algod related.
business/core/application
Package application provides the core business API of handling everything application related.
Package application provides the core business API of handling everything application related.
business/core/application/db
Package db contains application related CRUD functionality.
Package db contains application related CRUD functionality.
business/core/asset
Package asset provides the core business API of handling everything asset related.
Package asset provides the core business API of handling everything asset related.
business/core/asset/db
Package db contains asset related CRUD functionality.
Package db contains asset related CRUD functionality.
business/core/block
Package block provides the core business API of handling everything block related.
Package block provides the core business API of handling everything block related.
business/core/block/db
Package db contains block related CRUD functionality.
Package db contains block related CRUD functionality.
business/core/indexer
Package indexer provides the core business API of handling everything account related.
Package indexer provides the core business API of handling everything account related.
business/core/product
Package product provides an example of a core business API.
Package product provides an example of a core business API.
business/core/product/db
Package db contains product related CRUD functionality.
Package db contains product related CRUD functionality.
business/core/transaction
Package transaction provides the core business API of handling everything transaction related.
Package transaction provides the core business API of handling everything transaction related.
business/core/transaction/db
Package db contains transaction related CRUD functionality.
Package db contains transaction related CRUD functionality.
business/core/user
Package user provides an example of a core business API.
Package user provides an example of a core business API.
business/core/user/db
Package db contains user related CRUD functionality.
Package db contains user related CRUD functionality.
business/data/dbschema
Package dbschema contains the database schema, migrations and seeding data.
Package dbschema contains the database schema, migrations and seeding data.
business/data/dbtest
Package dbtest contains supporting code for running tests that hit the DB.
Package dbtest contains supporting code for running tests that hit the DB.
business/data/schema
Package schema contains the database schema, migrations and seeding data.
Package schema contains the database schema, migrations and seeding data.
business/sys/auth
Package auth provides authentication and authorization support.
Package auth provides authentication and authorization support.
business/sys/database
Package database provides support for access the database.
Package database provides support for access the database.
business/sys/metrics
Package metrics cosntructs the metrics the application will track.
Package metrics cosntructs the metrics the application will track.
business/sys/validate
Package validate contains the support for validating models.
Package validate contains the support for validating models.
business/web/v1
Package v1 represents types used by the web application for v1.
Package v1 represents types used by the web application for v1.
business/web/v1/mid
Package mid contains the set of middleware functions.
Package mid contains the set of middleware functions.
foundation/couchdb
Package couchdb provides support for access the database.
Package couchdb provides support for access the database.
foundation/docker
Package docker provides support for starting and stopping docker containers for running tests.
Package docker provides support for starting and stopping docker containers for running tests.
foundation/keystore
Package keystore implements the auth.KeyStore interface.
Package keystore implements the auth.KeyStore interface.
foundation/logger
Package logger provides a convience function to constructing a logger for use.
Package logger provides a convience function to constructing a logger for use.
foundation/web
Package web contains a small web framework extension.
Package web contains a small web framework extension.
foundation/worker
Package worker manages a set of registered jobs that execute on demand.
Package worker manages a set of registered jobs that execute on demand.

Jump to

Keyboard shortcuts

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