Skip to content

Commit

Permalink
Initial public commit
Browse files Browse the repository at this point in the history
Co-authored-by: Rafael Appelt <[email protected]>
Co-authored-by: Artur Dolzan <[email protected]>
Co-authored-by: Thomas Alvarenga <[email protected]>
Co-authored-by: Daniel Hidalgo <[email protected]>
Co-authored-by: Joshua Sing <[email protected]>
Co-authored-by: Bebe <[email protected]>
  • Loading branch information
6 people committed Oct 17, 2024
0 parents commit bde459d
Show file tree
Hide file tree
Showing 265 changed files with 40,039 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This configuration only applies to the package manager root.
/** @type {import("eslint").Linter.Config} */
module.exports = {
ignorePatterns: ["apps/**", "packages/**"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: false,
},
}
71 changes: 71 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright (c) 2024 Hemi Labs, Inc.
# Use of this source code is governed by the MIT License,
# which can be found in the LICENSE file.

# GitHub Actions workflow to deploy to the staging environment.
name: "Staging"
on:
push:
branches: [ "master" ]
workflow_dispatch:

concurrency:
group: "staging-deploy-${{ github.event.number || github.ref }}"
cancel-in-progress: false

jobs:
# Build and push Docker image
docker:
name: "Docker (${{ matrix.component }})"
uses: hemilabs/actions/.github/workflows/docker.yml@main
permissions:
contents: read
packages: write # Needed to push to the GitHub Container Registry
strategy:
matrix:
component: [ "api", "web" ]
with:
version: "${{ github.sha }}"
context: "."
file: "./Dockerfile.${{ matrix.component }}"
dockerhub: true
tags: |
hemilabs/cryptochords-${{ matrix.component }}:${{ github.sha }}
ghcr.io/hemilabs/cryptochords-${{ matrix.component }}:${{ github.sha }}
secrets:
DOCKERHUB_USERNAME: "${{ secrets.DOCKER_USERNAME }}"
DOCKERHUB_PASSWORD: "${{ secrets.DOCKER_PASSWORD }}"

deploy-registry:
name: "Deploy registry secret"
uses: hemilabs/actions/.github/workflows/docker-registry-secret.yml@main
permissions:
contents: read
with:
secret-name: "dockerhub-secret"
namespace: "cryptochords"
secrets:
KUBECONFIG: "${{ secrets.VKE_STAGING_KUBECONFIG }}"
KUBECONFIG_CONTEXT: "${{ secrets.VKE_STAGING_KUBECONFIG_CONTEXT }}"
DOCKER_USERNAME: "${{ secrets.DOCKER_USERNAME }}"
DOCKER_PASSWORD: "${{ secrets.DOCKER_PASSWORD }}"
DOCKER_EMAIL: "${{ secrets.DOCKER_EMAIL }}"

# Deploy to Kubernetes cluster
deploy:
name: "Deploy to staging"
uses: hemilabs/actions/.github/workflows/deploy-kustomize.yml@main
needs: [ "docker", "deploy-registry" ]
permissions:
contents: read
with:
namespace: "cryptochords"
kustomize: "./infrastructure/kustomize/overlays/staging/"
environment-name: "staging"
environment-url: "https://cryptochords.letshamsterdance.xyz/"
image: |
hemilabs/cryptochords-api:${{ github.sha }}
hemilabs/cryptochords-web:${{ github.sha }}
secrets:
KUBECONFIG: "${{ secrets.VKE_STAGING_KUBECONFIG }}"
KUBECONFIG_CONTEXT: "${{ secrets.VKE_STAGING_KUBECONFIG_CONTEXT }}"
106 changes: 106 additions & 0 deletions .github/workflows/deploy-testnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Copyright (c) 2024 Hemi Labs, Inc.
# Use of this source code is governed by the MIT License,
# which can be found in the LICENSE file.

# GitHub Actions workflow to deploy to the testnet prod environment.
name: "Testnet"
on:
release:
types: [published]

concurrency:
group: "testnet-deploy-${{ github.event.number || github.ref }}"
cancel-in-progress: false

jobs:
# Prepare to deploy and release
prepare:
name: "Prepare"
runs-on: "ubuntu-latest"
permissions:
contents: read
outputs:
version: "${{ steps.data.outputs.version }}"
tag: "${{ steps.data.outputs.tag }}"
version_type: "${{ steps.version.outputs.type }}"
steps:
- name: "Checkout repository"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: "Retrieve build data"
id: "data"
env:
RAW_VERSION: "${{ github.ref_name }}"
run: |
VERSION=$(echo "$RAW_VERSION" | sed -e 's/^v//')
TAG=$(echo "$RAW_VERSION" | sed -E 's/^([^v])/v\1/g')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
TYPE=unstable
if echo "$VERSION" | grep -Eq '^[1-9][0-9]*\.[0-9]+\.[0-9]+$'; then
TYPE=stable
fi
echo "Detected that $TAG is $TYPE"
echo "type=$TYPE" >> "$GITHUB_OUTPUT"
# Build and push Docker image
docker:
name: "Docker (${{ matrix.component }})"
uses: hemilabs/actions/.github/workflows/docker.yml@main
needs: [ "prepare" ]
permissions:
contents: read
packages: write # Needed to push to the GitHub Container Registry
strategy:
matrix:
component: [ "api", "web" ]
with:
version: "${{ needs.prepare.outputs.version }}"
context: "."
file: "./Dockerfile.${{ matrix.component }}"
dockerhub: true
tags: |
hemilabs/cryptochords-${{ matrix.component }}:latest
hemilabs/cryptochords-${{ matrix.component }}:${{ needs.prepare.outputs.tag }}
hemilabs/cryptochords-${{ matrix.component }}:${{ github.sha }}
ghcr.io/hemilabs/cryptochords-${{ matrix.component }}:latest
ghcr.io/hemilabs/cryptochords-${{ matrix.component }}:${{ needs.prepare.outputs.tag }}
ghcr.io/hemilabs/cryptochords-${{ matrix.component }}:${{ github.sha }}
secrets:
DOCKERHUB_USERNAME: "${{ secrets.DOCKER_USERNAME }}"
DOCKERHUB_PASSWORD: "${{ secrets.DOCKER_PASSWORD }}"

deploy-registry:
name: "Deploy registry secret"
uses: hemilabs/actions/.github/workflows/docker-registry-secret.yml@main
permissions:
contents: read
with:
secret-name: "dockerhub-secret"
namespace: "cryptochords"
secrets:
KUBECONFIG: "${{ secrets.VKE_TESTNET_KUBECONFIG }}"
KUBECONFIG_CONTEXT: "${{ secrets.VKE_TESTNET_KUBECONFIG_CONTEXT }}"
DOCKER_USERNAME: "${{ secrets.DOCKER_USERNAME }}"
DOCKER_PASSWORD: "${{ secrets.DOCKER_PASSWORD }}"
DOCKER_EMAIL: "${{ secrets.DOCKER_EMAIL }}"

# Deploy to Kubernetes cluster
deploy:
name: "Deploy to testnet"
uses: hemilabs/actions/.github/workflows/deploy-kustomize.yml@main
needs: [ "prepare", "docker", "deploy-registry" ]
permissions:
contents: read
with:
namespace: "cryptochords"
kustomize: "./infrastructure/kustomize/overlays/testnet/"
environment-name: "testnet"
environment-url: "https://cryptochords.hemi.xyz/"
image: |
hemilabs/cryptochords-api:${{ needs.prepare.outputs.tag }}
hemilabs/cryptochords-web:${{ needs.prepare.outputs.tag }}
secrets:
KUBECONFIG: "${{ secrets.VKE_TESTNET_KUBECONFIG }}"
KUBECONFIG_CONTEXT: "${{ secrets.VKE_TESTNET_KUBECONFIG_CONTEXT }}"
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Dependencies
node_modules
.pnp
.pnp.js

# Local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# Testing
coverage

# Turbo
.turbo

# Vercel
.vercel

# Build Outputs
.next/
out/
build
dist


# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Misc
.DS_Store
*.pem
.vscode/
138 changes: 138 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Contributing to Crypto Chords

## Thank you for your interest in contributing!

The following describes the guidelines to contribute to the Crypto Chords dapp, documentation, API reference and code examples.
The purpose of this document is to create a contribution process that:

- Encourages new community contributions.
- Encourages contributors to remain involved.
- Avoids unnecessary processes and bureaucracy whenever possible.
- Creates a transparent decision making process that makes it clear how contributors can be involved in - decision making.

## Table of contents

How can I contribute?

1. Fork and Edit
2. About the Code
3. Reporting Bugs
4. Suggesting Enhancements
5. Pull Requests
6. Issue and Pull Request labels

### 1. Fork and edit

To contribute to this repository, you will need to fork it, make changes and submit a pull request. This section is a brief guide on how to do this whilst making sure your forked repository stays up to date the with the official one.

- Fork this repository to your own GitHub account and then clone it to your local device.
- Create a new branch: `git checkout -b MY_BRANCH_NAME`
- Follow the next steps detailed in the README.md file

### 2. About the Code

You don't need to set any special code styling, since our repos already includes ESLinting once you clone it. Every time you commit and push your contributions, all code is stylized according to our standards.

- Start reading our code and you'll get the hang of it. We optimize it for readability.
- This is a monorepo repository managed by [Turborepo](https://turbo.build/repo/docs)
- There is a [API](./apps/api/), a [WEB](./apps/web/) applications and both are following the [Domain Driven Design](https://en.wikipedia.org/wiki/Domain-driven_design) principles.
- There is also a [Shared](./packages/shared/) package that contains code that both apps can use.

### Documentation Styleguide

Use [Markdown](https://daringfireball.net/projects/markdown)

### Git Commit Messages

- Use the present tense ("Add feature" not "Added feature")
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
- Limit the first line to 72 characters or less
- Reference issues and pull requests liberally after the first line

### 3. Reporting bugs

First of all make sure that the bug was not already reported by searching on GitHub under `Issues`.
When you are creating a bug report, please include as many details as possible.

General tips:

- If you're unable to find an open issue addressing the problem, open a new one. Be sure to include a title and clear description, as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behaviour that is not occurring.
- Determine which repository the problem should be reported in.
- Perform a cursory search to see if the problem has already been reported. If it has and the issue is still open, add a comment to the existing issue instead of opening a new one.
- Provide a step-by-step description of the suggested enhancement in as many details as possible.
- Provide specific examples to demonstrate the steps. Include copy/pasteable snippets (when applicable) which you use in those steps, as Markdown code blocks.
- Describe the current behaviour and explain which behaviour you expected to see instead and why.
- Include screenshots and/or animated GIFs which help you demonstrate the steps or point out the part of Crypto Chords which the issue is related to. You can use this tool to record GIFs on macOS and Windows, and [this tool](https://github.com/raiseerco/peek) on Linux.
- Specify the name and version of the OS/Browser/other applicable software you're using.

### 4. Suggesting Enhancements

This section guides you through submitting an enhancement suggestion for Crypto Chords, including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers and the community understand your suggestion and find related suggestions.

Note: Please don't file an issue to ask a question. You'll get faster results by using the resources below.

Before submitting an enhancement suggestion, check if there is already a filed one which provides that enhancement.

First of all, you can validate it with the community, our official channels are:

- [Discord](https://discord.gg/hemixyz)
- [Twitter](https://twitter.com/hemi_xyz)

How Do I Submit A (Good) Enhancement Suggestion?

General tips:

- Use a clear and descriptive title to identify the suggestion.
- Provide a step-by-step description of the suggested enhancement in as many details as possible.
- Provide specific examples to demonstrate the steps. Include copy/pasteable snippets which you use in those examples, as Markdown code blocks.
- Describe the current behaviour and explain which behaviour you expected to see instead and why.
- Include screenshots and/or animated GIFs which help you demonstrate the steps or point out the part of Crypto Chords which the suggestion is related to. You can use this tool to record GIFs on macOS and Windows, and [this tool](https://github.com/raiseerco/peek) on Linux.
- Explain why this enhancement would be useful to most Crypto Chords users.
- Specify the name and version of the OS/Browser/other applicable software you're using.

### 5. Pull Requests

The process described here has several goals:

- Maintain repository quality
- Fix problems that are important to users
- Engage the community in working toward the best possible product
- Enable a sustainable system for Crypto Chords's maintainers to review contributions

Please follow these steps to have your contribution considered by the maintainers:

- Follow the styleguides as stated in step [#2](#2-code-styleguides)
- If the pull request features a UI improvement, please include a screenshot in order to let maintainers to have a glimpse of it.
- After you submit your pull request, verify that all [status checks](https://help.github.com/articles/about-status-checks/) are passing.

`If a status check is failing, and you believe that the failure is unrelated to your change, please leave a comment on the pull request explaining why you believe the failure is unrelated. A maintainer will re-run the status check for you. If we conclude that the failure was a false positive, then we will open an issue to track that problem with our status check suite.`

While the prerequisites above must be satisfied prior to having your pull request reviewed, the reviewer(s) may ask you to complete additional design work, tests, or other changes before your pull request can be ultimately accepted.

### 6. Issue and Pull Request Labels

#### Type of Issue and Issue State

| Label name | Description |
| ------------- | ------------------------------------------------------------------------- |
| `enhancement` | Feature requests. |
| `bug` | Confirmed bugs or reports that are very likely to be bugs. |
| `question` | Questions more than bug reports or feature requests (e.g. how do I do X). |
| `feedback` | General feedback more than bug reports or feature requests. |

### 6. README Template

## Description
Describe your project here

## Prerequisites, Dependencies, Versions
Please add anything here you've built that requires the above specifics

## Licensing
Please state if license is CC, MIT or ISC or other (please no GPL)

## Outside Libraries
Link any outside open source libraries used

## Steps
Tell us how to run it locally
18 changes: 18 additions & 0 deletions Dockerfile.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## -*- docker-image-name: "hemilabs/cryptochords-api:1.0.0" -*-
FROM node:20

COPY package*.json ./

RUN mkdir -p /usr/src/app

WORKDIR /usr/src/app

COPY . .

RUN npm install

RUN npm run build

EXPOSE 3000

CMD [ "npm", "run", "start:api" ]
Loading

0 comments on commit bde459d

Please sign in to comment.