Skip to content

Commit aaf0f17

Browse files
committed
Project initialised with AlgoKit CLI using template: https://github.com/algorandfoundation/algokit-fullstack-template.git
0 parents  commit aaf0f17

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+12815
-0
lines changed

.copier-answers.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
2+
_commit: 0.4.3
3+
_src_path: gh:algorandfoundation/algokit-fullstack-template
4+
author_email: [email protected]
5+
author_name: Vandyck
6+
cloud_provider: none
7+
contract_name: smart_contract
8+
deployment_language: python
9+
ide_vscode: true
10+
preset_name: starter
11+
project_name: fund-raising
12+
python_linter: none
13+
use_dispenser: false
14+
use_github_actions: true
15+
use_python_black: true
16+
use_python_mypy: false
17+
use_python_pip_audit: true
18+
use_python_pytest: true
19+

.editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[*]
2+
charset = utf-8
3+
insert_final_newline = true
4+
end_of_line = lf
5+
indent_style = space
6+
indent_size = 2
7+
tab_width = 2
8+
max_line_length = 140
9+
trim_trailing_whitespace = true
10+
single_quote = true

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/frontend-cd.yaml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Frontend CD
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
packages: read
9+
10+
jobs:
11+
lint-and-build:
12+
name: CI dApp
13+
uses: ./.github/workflows/frontend-ci.yaml
14+
15+
deploy:
16+
runs-on: ubuntu-latest
17+
name: Deploy to Netlify
18+
environment: Prod
19+
concurrency: "${{ github.workflow }}-prod"
20+
needs:
21+
- lint-and-build
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v2
25+
26+
- name: Download build artifacts
27+
uses: actions/download-artifact@v3
28+
with:
29+
name: dist
30+
path: frontend/dist
31+
32+
- name: Replace template vars
33+
uses: makerxstudio/shared-config/.github/actions/placeholder-transforms@main
34+
with:
35+
app-artifact-path: ./frontend/dist
36+
static-site-transforms: |-
37+
VITE_ALGOD_TOKEN:${{ secrets.VITE_ALGOD_TOKEN }}
38+
VITE_ALGOD_SERVER:${{ vars.VITE_ALGOD_SERVER }}
39+
VITE_ALGOD_PORT:${{ vars.VITE_ALGOD_PORT }}
40+
VITE_ALGOD_NETWORK:${{ vars.VITE_ALGOD_NETWORK }}
41+
VITE_INDEXER_SERVER:${{ vars.VITE_INDEXER_SERVER }}
42+
VITE_INDEXER_PORT:${{ vars.VITE_INDEXER_PORT }}
43+
VITE_INDEXER_TOKEN:${{ secrets.VITE_INDEXER_TOKEN }}
44+
VITE_ENVIRONMENT:${{ vars.VITE_ENVIRONMENT }}
45+
46+
- name: Install netlify cli
47+
working-directory: ./frontend
48+
run: npm i netlify-cli
49+
50+
- name: Publish to netlify
51+
working-directory: ./frontend
52+
run: netlify deploy --prod --dir "dist"
53+
env:
54+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
55+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
56+

.github/workflows/frontend-ci.yaml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Frontend CI
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
run-build:
7+
required: false
8+
type: boolean
9+
default: false
10+
11+
jobs:
12+
checks:
13+
runs-on: "ubuntu-latest"
14+
steps:
15+
- name: Check out repository
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Setup node
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: 18
24+
25+
- name: Set up Python 3.10
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: "3.10"
29+
30+
- name: Install algokit
31+
run: pipx install algokit
32+
33+
- name: Install dependencies
34+
working-directory: ./frontend
35+
run: npm ci
36+
37+
- name: Run linters
38+
working-directory: ./frontend
39+
run: npm run lint
40+
41+
- name: Run unit tests
42+
working-directory: ./frontend
43+
run: npm run test
44+
45+
- name: Create placeholder .env file
46+
if: ${{ inputs.run-build }}
47+
uses: makerxstudio/shared-config/.github/actions/env-to-placeholders@main
48+
with:
49+
env-output-path: ./frontend/.env
50+
env-template-path: ./frontend/.env.template
51+
env-variable-prefix: VITE_
52+
53+
- name: Build
54+
if: ${{ inputs.run-build }}
55+
working-directory: ./frontend
56+
run: npm run build
57+
58+
- name: Archive
59+
if: ${{ inputs.run-build }}
60+
uses: actions/upload-artifact@v3
61+
with:
62+
name: dist
63+
path: frontend/dist/

.github/workflows/pr.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Pull Request validation
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
smart-contracts-ci:
7+
name: Smart Contracts CI
8+
uses: ./.github/workflows/smart-contracts-ci.yaml
9+
10+
frontend-ci:
11+
name: Frontend CI
12+
uses: ./.github/workflows/frontend-ci.yaml

.github/workflows/release.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- "docs/**"
9+
- "**.md"
10+
- ".vscode/**"
11+
- ".idea/**"
12+
13+
permissions:
14+
contents: read
15+
packages: read
16+
17+
jobs:
18+
backend-release:
19+
name: Backend Release
20+
secrets: inherit
21+
uses: ./.github/workflows/smart-contracts-cd.yaml
22+
23+
frontend-release:
24+
name: Frontend Release
25+
secrets: inherit
26+
uses: ./.github/workflows/frontend-cd.yaml
27+
needs: backend-release
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Backend CD
2+
3+
on:
4+
workflow_call:
5+
6+
concurrency: release
7+
8+
jobs:
9+
ci-check:
10+
name: Perform smart contract checks
11+
uses: ./.github/workflows/smart-contracts-ci.yaml
12+
13+
deploy-testnet:
14+
runs-on: 'ubuntu-latest'
15+
needs: ci-check
16+
environment: Test
17+
steps:
18+
- name: Checkout source code
19+
uses: actions/checkout@v3
20+
21+
- name: Install poetry
22+
run: pipx install poetry
23+
24+
- name: Set up Python 3.10
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: '3.10'
28+
cache: 'poetry'
29+
30+
- name: Install algokit
31+
run: pipx install algokit
32+
33+
- name: Bootstrap dependencies
34+
working-directory: ./backend
35+
run: algokit bootstrap all
36+
37+
- name: Configure git
38+
shell: bash
39+
working-directory: ./backend
40+
run: |
41+
# set git user and email as test invoke git
42+
git config --global user.email "[email protected]" && git config --global user.name "github-actions"
43+
44+
- name: Deploy to testnet
45+
working-directory: ./backend
46+
run: algokit deploy testnet
47+
env:
48+
# This is the account that becomes the creator of the contract.
49+
# Since we are not using the optional dispenser account (via DISPENSER_MNEMONIC),
50+
# it must also be funded with enough Algos to deploy and fund the smart contracts created
51+
DEPLOYER_MNEMONIC: ${{ secrets.DEPLOYER_MNEMONIC }}
+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Backend CI
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
checks:
8+
runs-on: 'ubuntu-latest'
9+
steps:
10+
- name: Checkout source code
11+
uses: actions/checkout@v3
12+
13+
- name: Install poetry
14+
run: pipx install poetry
15+
16+
- name: Set up Python 3.10
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.10'
20+
cache: 'poetry'
21+
22+
- name: Install algokit
23+
run: pipx install algokit
24+
25+
- name: Start LocalNet
26+
run: algokit localnet start
27+
28+
- name: Bootstrap dependencies
29+
run: algokit bootstrap all
30+
working-directory: ./backend
31+
32+
- name: Configure git
33+
shell: bash
34+
working-directory: ./backend
35+
run: |
36+
# set git user and email as test invoke git
37+
git config --global user.email "[email protected]" && git config --global user.name "github-actions"
38+
39+
- name: Audit with pip-audit
40+
working-directory: ./backend
41+
run: |
42+
# audit non dev dependencies, no exclusions
43+
poetry export --without=dev > requirements.txt && poetry run pip-audit -r requirements.txt
44+
45+
# audit all dependencies, with exclusions.
46+
# If a vulnerability is found in a dev dependency without an available fix,
47+
# it can be temporarily ignored by adding --ignore-vuln e.g.
48+
# --ignore-vuln "GHSA-hcpj-qp55-gfph" # GitPython vulnerability, dev only dependency
49+
poetry run pip-audit
50+
51+
- name: Check formatting with Black
52+
working-directory: ./backend
53+
run: |
54+
# stop the build if there are files that don't meet formatting requirements
55+
poetry run black --check .
56+
57+
- name: Run tests
58+
working-directory: ./backend
59+
shell: bash
60+
run: |
61+
set -o pipefail
62+
poetry run pytest --junitxml=pytest-junit.xml
63+
64+
- name: Build smart contracts
65+
working-directory: ./backend
66+
run: poetry run python -m smart_contracts build
67+
68+
- name: Check output stability of the smart contracts
69+
shell: bash
70+
working-directory: ./backend
71+
run: |
72+
# Add untracked files as empty so they come up in diff
73+
git add -N ./smart_contracts/artifacts
74+
# Error out if there are any changes in teal after generating output
75+
git diff --exit-code --minimal ./smart_contracts/artifacts || (echo "::error ::Smart contract artifacts have changed, ensure committed artifacts are up to date" && exit 1);

.vscode/launch.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": []
7+
}

README.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# fund-raising
2+
3+
This starter full stack project has been generated using AlgoKit. See below for default getting started instructions.
4+
5+
## Setup
6+
7+
### Initial setup
8+
9+
1. Clone this repository locally.
10+
2. Install pre-requisites:
11+
- Make sure to have [Docker](https://www.docker.com/) installed and running on your machine.
12+
- Install `AlgoKit` - [Link](https://github.com/algorandfoundation/algokit-cli#install): The minimum required version is `1.3.0`. Ensure you can execute `algokit --version` and get `1.3.0` or later.
13+
- Bootstrap your local environment; run `algokit bootstrap all` within this folder, which will install Poetry, run `npm install` and `poetry install` in the root directory to install NPM and Python packages respectively, set up a `.venv` folder with a Python virtual environment and also install all Python dependencies.
14+
- For TypeScript projects, it will also run `npm install` to install NPM packages.
15+
- For all projects, it will copy `.env.template` to `.env`.
16+
- Run `algokit localnet start` to start a local Algorand network in Docker. If you are using VS Code launch configurations provided by the template, this will be done automatically for you.
17+
3. Open the project and start debugging / developing on:
18+
- [Backend](backend/README.md) - Refer to the README for more information on how to work with smart contracts.
19+
- [Frontend](frontend/README.md) - Refer to the README for more information on how to work with the frontend application.
20+
21+
22+
### Subsequently
23+
24+
1. If you update to the latest source code and there are new dependencies, you will need to run `algokit bootstrap all` again.
25+
2. Follow step 3 above.
26+
27+
### Continuous Integration / Continuous Deployment (CI/CD)
28+
29+
This project uses [GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions) to define CI/CD workflows, which are located in the [`.github/workflows`](./.github/workflows) folder. You can configure these actions to suit your project's needs, including CI checks, audits, linting, type checking, testing, and deployments to TestNet.
30+
31+
For pushes to `main` branch, after the above checks pass, the following deployment actions are performed:
32+
- The smart contract(s) are deployed to TestNet using [AlgoNode](https://algonode.io).
33+
- The frontend application is deployed to a provider of your choice (Netlify, Vercel, etc.). See [frontend README](frontend/README.md) for more information.
34+
35+
> Please note deployment of smart contracts is done via `algokit deploy` command which can be invoked both via CI as seen on this project, or locally. For more information on how to use `algokit deploy` please see [AlgoKit documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/deploy.md).
36+
37+
## Tools
38+
39+
This project makes use of Python and React to build Algorand smart contracts and to provide a base project configuration to develop frontends for your Algorand dApps and interactions with smart contracts. The following tools are in use:
40+
41+
- Algorand, AlgoKit, and AlgoKit Utils
42+
- Python dependencies including Poetry, Black, Ruff or Flake8, mypy, pytest, and pip-audit
43+
- React and related dependencies including AlgoKit Utils, Tailwind CSS, daisyUI, use-wallet, npm, jest, playwright, Prettier, ESLint, and Github Actions workflows for build validation
44+
45+
It has also been configured to have a productive dev experience out of the box in [VS Code](https://code.visualstudio.com/), see the [backend .vscode](./backend/.vscode) and [frontend .vscode](./frontend/.vscode) folders for more details.
46+
47+
## Integrating with smart contracts and application clients
48+
49+
Refer to the [backend](backend/README.md) folder for overview of working with smart contracts, [frontend](frontend/README.md) for overview of the React project and the [frontend/contracts](frontend/src/contracts/README.md) folder for README on adding new smart contracts from backend as application clients on your frontend. The templates provided in these folders will help you get started.
50+
When you compile and generate smart contract artifacts, your frontend component will automatically generate typescript application clients from smart contract artifacts and move them to `frontend/src/contracts` folder, see [`generate:app-clients` in package.json](frontend/package.json). Afterwards, you are free to import and use them in your frontend application.
51+
52+
The frontend starter also provides an example of interactions with your SmartContractClient in [`AppCalls.tsx`](frontend/src/components/AppCalls.tsx) component by default.
53+
54+
## Next Steps
55+
56+
You can take this project and customize it to build your own decentralized applications on Algorand. Make sure to understand how to use AlgoKit and how to write smart contracts for Algorand before you start.

0 commit comments

Comments
 (0)