Giter Club home page Giter Club logo

9cscan-cloud's Introduction

9cscan-cloud

9cscan backend is built on the aws serverless architecture.

API

[APIGateway] -> [Lambda] -> [Dynamodb]

Provides a rest API that can inquire blocks and transactions.

Sync

[EventBridge] -> [StepFunction] -> [Lambda] -> [Dynamodb]

Synchronize the Nine Chronicles chain data to dynamodb.

WS

[DynamoStream] -> [Lambda] -> [APIGateway]

When a new block is created, it is broadcast through WebSocket.

Getting started

1. IAM (in the AWS console)

  1. Manually create a new IAM policy using /bootstrap/iam/9cscan-policy.json https://console.aws.amazon.com/iamv2/home#/policies
  2. Manually create a new IAM role using /bootstrap/iam/9cscan-role-trust.json https://console.aws.amazon.com/iamv2/home#/roles
  3. Manually create a new IAM user with the policy you created.

2. Pull this project to local

git clone https://github.com/planetarium/9cscan-cloud
cd 9cscan-cloud
npm install

3. Create and fill .config file

{
  // Required.
  "region": "ap-northeast-2",
  
  // Required. AccessKey of user you created (1.3)
  "credentials": {
    "accessKeyId": "",
    "secretAccessKey": ""
  },
  
  // Required. Arn of role you created (1.2)
  "iamRoleArn": "",

  // Optional. to fetch WNCG price
  "coinMarketCapKeys": {
    "alias": "key" 
  },
  
  //Required. Nine Chronicles graphql endpoints
  "graphqlEndpoints": [
    "http://your-host1/graphql",
    "http://your-host2/graphql"
  ],
  
  //Required.
  "namespace": "prod",
  
  //Required.
  "s3WebBucketName": "9cscan-bucket"
}

4. Create serverless environments

npm run create-s3

------------------------------

SUCCESS : https://your-s3-endpoint/index.html

Before proceeding, make sure that the endpoint is working.

npm run create-db

------------------------------

Dynamodb : create table Prod.Account
SUCCESS : Prod.Account : arn:aws:dynamodb
Dynamodb : create table Prod.AccountTransaction
SUCCESS : Prod.AccountTransaction : arn:aws:dynamodb
Dynamodb : create table Prod.Action
SUCCESS : Prod.Action : arn:aws:dynamodb
Dynamodb : create table Prod.Block
SUCCESS : Prod.Block : arn:aws:dynamodb
Dynamodb : create table Prod.Cache
SUCCESS : Prod.Cache : arn:aws:dynamodb
Dynamodb : create table Prod.LatestBlocks
SUCCESS : Prod.LatestBlocks : arn:aws:dynamodb
Dynamodb : create table Prod.Transaction
SUCCESS : Prod.Transaction : arn:aws:dynamodb
Dynamodb : create table Prod.WebsocketConnection
SUCCESS : Prod.WebsocketConnection : arn:aws:dynamodb

npm run create-api
npm run create-sync
npm run create-ws

5. Deploy projects

npm run deploy-api
npm run deploy-sync
npm run deploy-ws

6. Check status

npm run check-api

...
GET /blocks api response
...
npm run check-ws

...
Subscribe new block event
...
npm run check-s3

...
Get index.html
...

7. Web Client

For the web client, use the following project:

https://github.com/planetarium/9cscan.com

License

Apache 2.0

9cscan-cloud's People

Contributors

kimwz avatar tx0x-karl avatar xxshiftxx avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.