Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
7,027 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,48 @@ | ||
# cip25-search-engine | ||
# CIP-25 Search Engine | ||
|
||
A reference app that uses Oura + Elasticsearch + React to buid a Cardano CIP-25 search engine | ||
|
||
## Introduction | ||
|
||
This is a reference app to show how _Oura_ can be leveradged to build a search engine for CIP-25 tokens. | ||
|
||
The frontend is built using React and Remix. | ||
|
||
The backend is a combination of a Cardano node, Oura and Elasticsearch. | ||
|
||
Everthing is deployed together using Kubernetes | ||
|
||
If I missed any buzzwords, let me know :) | ||
|
||
## Deployment | ||
|
||
Prerequisites | ||
|
||
- K8s Cluster | ||
- Skaffold | ||
|
||
Install operator | ||
|
||
``` | ||
kubectl create -f https://download.elastic.co/downloads/eck/1.9.1/crds.yaml | ||
kubectl apply -f https://download.elastic.co/downloads/eck/1.9.1/operator.yaml | ||
``` | ||
|
||
Build & Deploy | ||
|
||
``` | ||
skaffold dev | ||
``` | ||
|
||
Setup Index Template | ||
|
||
``` | ||
export ELASTIC_AUTH=user:pass | ||
cd scripts && ./setup-index.sh | ||
``` | ||
|
||
## Dev | ||
|
||
``` | ||
skaffold dev --default-repo ghcr.io/txpipe --namespace cip25 --module web --cleanup=false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
apiVersion: elasticsearch.k8s.elastic.co/v1 | ||
kind: Elasticsearch | ||
metadata: | ||
name: sink | ||
spec: | ||
version: 7.16.1 | ||
nodeSets: | ||
- name: default | ||
count: 1 | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: elasticsearch-data # Do not change this name unless you set up a volume mount for the data path. | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 50Gi | ||
podTemplate: | ||
spec: | ||
containers: | ||
- name: elasticsearch | ||
env: | ||
- name: ES_JAVA_OPTS | ||
value: -Xms2g -Xmx2g | ||
resources: | ||
requests: | ||
memory: 4Gi | ||
cpu: 1 | ||
limits: | ||
memory: 4Gi | ||
--- | ||
apiVersion: kibana.k8s.elastic.co/v1 | ||
kind: Kibana | ||
metadata: | ||
name: sink | ||
spec: | ||
version: 7.16.1 | ||
count: 1 | ||
elasticsearchRef: | ||
name: sink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: oura | ||
data: | ||
daemon.toml: |- | ||
[source] | ||
type = "N2N" | ||
address = ["Tcp", "relays-new.cardano-mainnet.iohk.io:3001"] | ||
magic = "mainnet" | ||
#since = [26785934, "92d994d49e93b1b4c47383647bd71a965371976d33e84a74a91eae0a3c47b45d"] | ||
#since = [29100429, "8a4f144f0b195522b9d5f7a4c798611cca6e0313c8bd1a01e17386d92bec41be"] | ||
since = [47494387, "8741e7ef3c24c1940df89930bce63a2cb2471a3efdf9ae7957c63c5d5170011e"] | ||
[[filters]] | ||
type = "Fingerprint" | ||
[[filters]] | ||
type = "Selection" | ||
[filters.check] | ||
predicate = "variant_in" | ||
argument = ["CIP25Asset"] | ||
[sink] | ||
type = "Elastic" | ||
url = "https://sink-es-http:9200" | ||
index = "oura.sink.cip25assets" | ||
idempotency = true | ||
[sink.credentials] | ||
type = "Basic" | ||
username = "elastic" | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: oura | ||
labels: | ||
app: oura | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: oura | ||
template: | ||
metadata: | ||
labels: | ||
app: oura | ||
spec: | ||
containers: | ||
- name: main | ||
image: ghcr.io/txpipe/oura:v1.0.0 | ||
env: | ||
- name: "RUST_LOG" | ||
value: "info" | ||
- name: "OURA_SINK_CREDENTIALS_PASSWORD" | ||
valueFrom: | ||
secretKeyRef: | ||
key: elastic | ||
name: sink-es-elastic-user | ||
resources: | ||
requests: | ||
memory: 100Mi | ||
cpu: 50m | ||
limits: | ||
memory: 500Mi | ||
cpu: 200m | ||
args: | ||
- "daemon" | ||
volumeMounts: | ||
- mountPath: /etc/oura | ||
name: oura-config | ||
volumes: | ||
- name: oura-config | ||
configMap: | ||
name: oura |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: web | ||
labels: | ||
app: web | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: web | ||
template: | ||
metadata: | ||
labels: | ||
app: web | ||
spec: | ||
containers: | ||
- name: main | ||
image: web | ||
env: | ||
- name: "RUST_LOG" | ||
value: "info" | ||
resources: | ||
requests: | ||
memory: 100Mi | ||
cpu: 50m | ||
limits: | ||
memory: 500Mi | ||
cpu: 200m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"template": { | ||
"mappings": { | ||
"properties": { | ||
"@timestamp": { | ||
"type": "date" | ||
}, | ||
"context": { | ||
"properties": { | ||
"block_number": { | ||
"type": "long" | ||
}, | ||
"block_hash": { | ||
"type": "keyword" | ||
}, | ||
"input_idx": { | ||
"type": "long" | ||
}, | ||
"output_idx": { | ||
"type": "long" | ||
}, | ||
"certificate_idx": { | ||
"type": "long" | ||
}, | ||
"slot": { | ||
"type": "long" | ||
}, | ||
"timestamp": { | ||
"type": "long" | ||
}, | ||
"tx_hash": { | ||
"type": "keyword" | ||
}, | ||
"tx_idx": { | ||
"type": "long" | ||
} | ||
} | ||
}, | ||
"cip25_asset": { | ||
"properties": { | ||
"policy": { | ||
"type": "keyword" | ||
}, | ||
"asset": { | ||
"type": "keyword" | ||
}, | ||
"name": { | ||
"type": "text" | ||
}, | ||
"mediatType": { | ||
"type": "keyword" | ||
}, | ||
"image": { | ||
"type": "keyword" | ||
}, | ||
"description": { | ||
"type": "text" | ||
}, | ||
"raw_json": { | ||
"enabled": false | ||
} | ||
} | ||
}, | ||
"fingerprint": { | ||
"type": "keyword", | ||
"ignore_above": 256 | ||
}, | ||
"variant": { | ||
"type": "keyword", | ||
"ignore_above": 256 | ||
} | ||
} | ||
} | ||
}, | ||
"data_stream": {}, | ||
"index_patterns": [ | ||
"oura.sink.cip25" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
curl -k -X PUT https://localhost:9200/_index_template/oura.sink.cip25 \ | ||
-u ${ELASTIC_AUTH} \ | ||
-H 'Content-Type: application/json' \ | ||
-d @index-template.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apiVersion: skaffold/v2beta26 | ||
kind: Config | ||
metadata: | ||
name: elastic | ||
deploy: | ||
kubectl: | ||
manifests: | ||
- k8s/elastic.yaml | ||
--- | ||
apiVersion: skaffold/v2beta26 | ||
kind: Config | ||
metadata: | ||
name: oura | ||
requires: | ||
- configs: [elastic] | ||
deploy: | ||
kubectl: | ||
manifests: | ||
- k8s/oura.yaml | ||
--- | ||
apiVersion: skaffold/v2beta26 | ||
kind: Config | ||
metadata: | ||
name: web | ||
requires: | ||
- configs: [elastic, oura] | ||
build: | ||
artifacts: | ||
- image: web | ||
context: web | ||
deploy: | ||
kubectl: | ||
manifests: | ||
- k8s/web.yaml | ||
portForward: | ||
- resourceType: deployment | ||
resourceName: web | ||
port: 3000 | ||
localPort: 3000 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
|
||
/.cache | ||
/build | ||
/public/build | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM node:14-alpine AS build | ||
|
||
WORKDIR /code | ||
|
||
COPY ./package.json ./package.json | ||
COPY ./package-lock.json ./package-lock.json | ||
|
||
RUN npm install --loglevel warn | ||
|
||
COPY . ./ | ||
|
||
RUN npm run build | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["npm", "start"] |
Oops, something went wrong.