Skip to content

Commit 04aab19

Browse files
Integrates GraphQL/Redux (#5) (#6)
1 parent 3669fd7 commit 04aab19

Some content is hidden

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

55 files changed

+994
-246
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
name: 看看这里 👉
2-
1+
name: Bitcoin Hash Continuous integration 👉
32
on: [pull_request]
4-
53
jobs:
64
run-ci:
75
env:
86
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9-
10-
name: 👌 Listingslab AI Test
7+
name: 👌 Listingslab AI
118
runs-on: ubuntu-latest
12-
139
steps:
14-
- name: 🦹‍♀️ Checkout
10+
- name: 👉 Repository
1511
uses: actions/checkout@v3
1612
with:
1713
fetch-depth: 0
1814

19-
- name: 👼 React jest suite
20-
run: cd react-app && npm install && npm test
15+
- name: 👌 Build/run React jest suite
16+
run: cd react-app && npm install && npm test

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,32 @@
1-
## Bitcoin Hash
1+
## ![alt text](./react-app/public/svg/logo16.svg "Bitcoin Hash Logo") Bitcoin Hash
2+
3+
Bootstrapping from recent work, everything needed to build an app quickly is already written. Even the [Documentation](./react-app/public/markdown/)
4+
5+
### [Challenge](./react-app/public/markdown/00_challenge.md)
6+
7+
### Solution
8+
9+
#### Install & run
10+
11+
> To connect to Bitquery requires an API key, which can't be exposed in a public repo and is therefore abstracted to an `.env`. Just un-zip `/react-app/env.zip` for a cheaty workaround
12+
13+
```shell
14+
# REACT_APP_BITQUERY_API_KEY=""
15+
```
16+
17+
#### Features
18+
19+
- [Tests](./react-app/public/markdown/05_tests.md)
20+
CI, Jest, GitHub Workflows, TDD.
21+
22+
- Highly Portable
23+
Copy the folder [/src/BitcoinHash/](https://github.com/listingslab/bitcoin-hash/tree/master/react-app/src/BitcoinHash) into any JS app and it _should just work_. (If all the dependencies exist)
24+
25+
- [Custom Design System](./react-app/public/markdown/30_design-system.md)
26+
Based on several years of constant iteration, the project is bootstrapped with Material UI, listingslab custom components containing all the features I need to rapidly create a full PWA. Example: [<Icon icon="rocket" />](https://github.com/listingslab/bitcoin-hash/blob/master/react-app/src/BitcoinHash/components/Icon.tsx)
27+
28+
- Persistant Data
29+
Instead of saving anything to a DB, we're using a [persisted Redux store with LocalStorage](https://github.com/listingslab/bitcoin-hash/blob/master/react-app/src/BitcoinHash/redux/store.ts). This means a returning visit does not require a DB request and even better; the entire app state is saved. As a next step I would also save the redux state to a cloud based NoSQL DB at certain times for good measure
30+
31+
- [GraphQL](https://github.com/listingslab/bitcoin-hash/blob/feature/graphql/react-app/public/markdown/40_graphql.md)
32+
Combining [Bitquery's GraphQL API](https://bitquery.io/labs/graphql) service with [@apollo/client](https://www.npmjs.com/package/@apollo/client) in React, we developed an async data layer interface which is used via [redux actions](https://github.com/listingslab/bitcoin-hash/tree/master/react-app/src/BitcoinHash/redux/actions)

react-app/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

3+
.env
4+
35
# dependencies
46
/node_modules
57
/.pnp

react-app/env.zip

247 Bytes
Binary file not shown.

react-app/package-lock.json

Lines changed: 157 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

react-app/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "bitcoin-hash",
3-
"version": "1.0.4",
3+
"version": "1.0.6",
44
"dependencies": {
5+
"@apollo/client": "^3.7.14",
56
"@emotion/react": "^11.11.0",
67
"@emotion/styled": "^11.11.0",
78
"@mui/icons-material": "^5.11.16",
@@ -14,6 +15,7 @@
1415
"@types/node": "^17.0.45",
1516
"@types/react": "^18.2.6",
1617
"@types/react-dom": "^18.2.4",
18+
"graphql": "^16.6.0",
1719
"react": "^18.2.0",
1820
"react-dom": "^18.2.0",
1921
"react-redux": "^8.0.5",

react-app/public/markdown/challenge.md renamed to react-app/public/markdown/00_challenge.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
55
#### Introduction
66

7-
Hi, thank you for taking on our challenge! We hope that you'll learn a lot,
8-
create an awesome project and join our team!
7+
Hi, thank you for taking on our challenge! We hope that you'll learn a lot, create an awesome project and join our team!
98

109
In this test we will evaluate your technical skills, namely, code structure, code quality, naming conventions, knowledge of commonly used frameworks, and overall problem-solving skills.
1110

react-app/public/markdown/05_tests.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## ![alt text](../svg/logo16.svg "Bitcoin Hash Logo") Tests
2+
3+
#### Pull Request checks
4+
![alt text](../png/github-pr-checks.png "TDD")
5+
6+
#### [Github Continuous Integration](https://github.com/listingslab/bitcoin-hash/blob/master/.github/workflows/ci.yml)
7+
8+
`/.github/workflows/ci.yml`
9+
10+
![alt text](../png/github-ci-workflow.png "TDD")
11+
12+
#### React Jest
13+
![alt text](../png/test-driven-developemnt.png "TDD")
14+
![alt text](../png/test-driven-developemnt-fail.png "TDD")
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## ![alt text](../svg/logo16.svg "Bitcoin Hash Logo") Initialise project
2+
3+
Thinking first about the delivery of the project, requirements are a github repo with CI workflow and a live, publicly accessible demo
4+
5+
- GitHub
6+
- [Repo](https://github.com/listingslab/bitcoin-hash)
7+
- [Firebase Demo](https://bitcoin-hash-demo.web.app)
8+
9+
#### React App
10+
11+
`npx create-react-app react-app --template redux-typescript`
12+
13+
First I make sure that whatever code I write from this point is modular enough to pick up and place in any other JS app. I’ll do that by creating a folder called /src/BitcoinHash in which all code lives. The idea is that so long as the required dependencies exist in the main project, the Bitcoin Hash model/app/whatever should work anywhere. Like Storybook.
14+
15+
Now we’ve initialised the project by creating a repo, setting up a firebase environment and using create-react app to bootstrap the frontend app and chosen an API it’s time to code

react-app/public/markdown/20_react.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## ![alt text](../svg/logo16.svg "Bitcoin Hash Logo") React
2+
3+
We use a TDD (Test Driven Development) approach to this project. React has Jest built in, so we'll use that. What we’ll do is start the test suite and keep it running during development time.
4+
5+
#### Test Driven Development
6+
7+
Install dependencies and start the React test suite
8+
9+
```javascript
10+
cd <working-dir>
11+
git clone https://github.com/listingslab/bitcoin-hash
12+
cd bitcoin-hash
13+
npm install
14+
npm test
15+
```
16+
17+
![alt text](../png/test-driven-developemnt.png "TDD")
18+
19+
Any time any test breaks, we investigate and thus build better software. The same tests are used in the Continuous Integration [ci.yaml](https://github.com/listingslab/bitcoin-hash/blob/master/.github/workflows/ci.yml) so team members can’t merge broken code into important branches
20+
21+
![alt text](../png/test-driven-developemnt-fail.png "TDD")
22+
23+
> Fun Fact. Know what yaml stands for? Yet Another Markup Language

0 commit comments

Comments
 (0)