Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

digit-recognition frontend #3

Merged
merged 35 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7205723
init digit-recognition frontend
vraja-nayaka Dec 25, 2024
948c725
remove tailwind styles
vraja-nayaka Dec 26, 2024
89a9a65
remove tailwind config
vraja-nayaka Dec 26, 2024
44e15ea
init digit-recognition frontend
vraja-nayaka Dec 25, 2024
e701ff7
remove tailwind styles
vraja-nayaka Dec 26, 2024
372a873
remove tailwind config
vraja-nayaka Dec 26, 2024
a9d5431
upd Dockerfile
kvs96 Dec 26, 2024
dc2f631
Merge branch 'vt-digit-recognition-frontend' of github.com:gear-found…
vraja-nayaka Jan 7, 2025
9238252
Merge remote-tracking branch 'origin/master' into vt-digit-recognitio…
vraja-nayaka Jan 7, 2025
df43068
fix envs
vraja-nayaka Jan 9, 2025
7608cba
fix build
vraja-nayaka Jan 9, 2025
1fc3b3d
Merge remote-tracking branch 'origin/master' into vt-digit-recognitio…
vraja-nayaka Jan 15, 2025
e83e47d
add contract api
vraja-nayaka Jan 15, 2025
e50afcf
debug envs
vraja-nayaka Jan 15, 2025
c371cc0
Update Dockerfile
sergeyfilyanin Jan 16, 2025
0eaf81e
Update Dockerfile
sergeyfilyanin Jan 16, 2025
3033344
Update Dockerfile
sergeyfilyanin Jan 16, 2025
a266a88
Update consts.ts
sergeyfilyanin Jan 17, 2025
2897cc8
Update consts.ts
sergeyfilyanin Jan 17, 2025
bbce1d1
Update CI-CD_digit-recognition-frontend.yaml
sergeyfilyanin Jan 17, 2025
08bef76
debug event subscription
vraja-nayaka Jan 17, 2025
b89b864
fix event subscription
vraja-nayaka Jan 17, 2025
0cc7368
Merge branch 'vt-digit-recognition-frontend' of github.com:gear-found…
vraja-nayaka Jan 17, 2025
ddff3cd
fix read state
vraja-nayaka Jan 20, 2025
578f724
bebug envs
vraja-nayaka Jan 20, 2025
4bb9048
fix ci cd
vraja-nayaka Jan 20, 2025
7d9476f
remove envs debugger
vraja-nayaka Jan 20, 2025
8cad172
remove unused abi
vraja-nayaka Jan 22, 2025
1fcea35
Update CI-CD-Distributed-Computation-fe.yml
sergeyfilyanin Jan 28, 2025
d7a44a2
fix digit recorgnition
vraja-nayaka Jan 29, 2025
28f8ec5
remove unused deps
vraja-nayaka Jan 29, 2025
580096d
Merge branch 'vt-digit-recognition-frontend' of github.com:gear-found…
vraja-nayaka Jan 29, 2025
dfb8869
remove unused deps
vraja-nayaka Jan 29, 2025
0678856
Merge remote-tracking branch 'origin/master' into vt-digit-recognitio…
vraja-nayaka Feb 6, 2025
8970124
fix review
vraja-nayaka Feb 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/CI-CD_digit-recognition-frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ jobs:
push: true
build-args: |
NODE_ENV=${{ env.NODE_ENV }}
VITE_WALLET_CONNECT_PROJECT_ID=${{ env.VITE_WALLET_CONNECT_PROJECT_ID }}
VITE_GEAR_API_NODE=${{ env.VITE_GEAR_API_NODE }}
VITE_ETH_NODE_ADDRESS=${{ env.VITE_ETH_NODE_ADDRESS }}
VITE_CONTRACT_ADDRESS=${{ env.VITE_CONTRACT_ADDRESS }}
VITE_WALLET_CONNECT_PROJECT_ID=${{ secrets.VITE_WALLET_CONNECT_PROJECT_ID_DIGIT_RECOGNITION }}
VITE_GEAR_API_NODE=${{ secrets.VITE_GEAR_API_NODE }}
VITE_ETH_NODE_ADDRESS=${{ secrets.VITE_ETH_NODE_ADDRESS }}
VITE_CONTRACT_ADDRESS_DIGIT_RECOGNITION=${{ secrets.VITE_CONTRACT_ADDRESS_DIGIT_RECOGNITION }}
tags: ${{ needs.prepair.outputs.image_name }}

deploy-to-k8s:
Expand Down
4 changes: 4 additions & 0 deletions digit-recognition/frontend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
VITE_WALLET_CONNECT_PROJECT_ID=
VITE_GEAR_API_NODE=
VITE_ETH_NODE_ADDRESS=
VITE_CONTRACT_ADDRESS_DIGIT_RECOGNITION=
25 changes: 25 additions & 0 deletions digit-recognition/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local
.env

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
30 changes: 30 additions & 0 deletions digit-recognition/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM node:18-alpine

WORKDIR /opt

RUN apk add --no-cache xsel

COPY package.json yarn.lock ./

RUN yarn install --frozen-lockfile

COPY . .

ARG VITE_WALLET_CONNECT_PROJECT_ID \
VITE_GEAR_API_NODE \
VITE_ETH_NODE_ADDRESS \
VITE_CONTRACT_ADDRESS_DIGIT_RECOGNITION

ENV VITE_WALLET_CONNECT_PROJECT_ID=${VITE_WALLET_CONNECT_PROJECT_ID} \
VITE_CONTRACT_ADDRESS_DIGIT_RECOGNITION=${VITE_CONTRACT_ADDRESS_DIGIT_RECOGNITION} \
VITE_GEAR_API_NODE=${VITE_GEAR_API_NODE} \
VITE_ETH_NODE_ADDRESS=${VITE_ETH_NODE_ADDRESS} \
DISABLE_ESLINT_PLUGIN=true

RUN yarn build

RUN npm install --global serve

EXPOSE 4173

CMD ["serve", "-s", "/opt/dist"]
23 changes: 23 additions & 0 deletions digit-recognition/frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# AI Image Recognition

## Description

React application of AI Image Recognition.

## Getting started

### Install packages:

```sh
yarn install
```

### Declare environment variables:

Create `.env` file, `.env.example` will let you know what variables are expected.

### Run the app:

```sh
yarn start
```
28 changes: 28 additions & 0 deletions digit-recognition/frontend/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
)
Binary file added digit-recognition/frontend/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions digit-recognition/frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en" class="dark">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/favicon.png" sizes="any" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AI Image Recognition</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions digit-recognition/frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "distributed-computation",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@polkadot/types": "14.3.1",
"@reown/appkit": "^1.6.0",
"@reown/appkit-adapter-wagmi": "^1.6.0",
"@tanstack/react-query": "^5.59.20",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"wagmi": "^2.12.29"
},
"devDependencies": {
"@eslint/js": "^9.13.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.3",
"eslint": "^9.13.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.14",
"globals": "^15.11.0",
"typescript": "~5.6.2",
"typescript-eslint": "^8.11.0",
"vite": "^5.4.10",
"vite-plugin-checker": "0.8.0",
"vite-plugin-svgr": "^4.3.0",
"sass": "1.62.0"
}
}
9 changes: 9 additions & 0 deletions digit-recognition/frontend/src/App.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.connectionWrapper {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 48px;
padding-top: 0;
min-height: calc(100vh - 78px);
}
30 changes: 30 additions & 0 deletions digit-recognition/frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import "./index.css";
import { useAccount } from "wagmi";

import { WalletButton, Header, Layout } from "@/components";
import { Recognition } from "./components/recognition/Recognition";
import { ETH_CHAIN_ID } from "./consts";
import styles from "./App.module.scss";

function App() {
const ethAccount = useAccount();
const isConnected = Boolean(
ethAccount.chain && ethAccount.chain.id === ETH_CHAIN_ID
);

return (
<>
<Header />
{!isConnected && (
<Layout className={styles.connectionWrapper}>
<h1>AI Image Recognition</h1>

<WalletButton />
</Layout>
)}
{isConnected && <Recognition />}
</>
);
}

export default App;
3 changes: 3 additions & 0 deletions digit-recognition/frontend/src/assets/icons/burger-menu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions digit-recognition/frontend/src/assets/icons/cross.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions digit-recognition/frontend/src/assets/icons/document-copy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions digit-recognition/frontend/src/assets/icons/loading.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added digit-recognition/frontend/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.container {
width: 100vw;
max-width: 1440px;
margin: 0 auto;
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px 24px;
height: 78px;
}

.logo {
width: 107px;
}
13 changes: 13 additions & 0 deletions digit-recognition/frontend/src/components/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import logo from "@/assets/logo.png";
import { WalletButton } from "../wallet/WalletButton";
import styles from "./Header.module.scss";

export const Header = () => {
return (
<header className={styles.container}>
<img src={logo} className={styles.logo} alt="Gear logo" />

<WalletButton />
</header>
);
};
5 changes: 5 additions & 0 deletions digit-recognition/frontend/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export { Header } from "./header/Header";
export { Layout } from "./layout/Layout";
export { WalletButton } from "./wallet/WalletButton";
export { Button } from "./ui/button/Button";
export { Card } from "./ui/card/Card";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.container {
max-width: 946px;
margin: 0 auto;
padding: 97px 20px 20px;
}
11 changes: 11 additions & 0 deletions digit-recognition/frontend/src/components/layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { clsx } from "clsx";
import { PropsWithChildren } from "react";
import styles from "./Layout.module.scss";

type Props = PropsWithChildren & {
className?: string;
};

export const Layout = ({ children, className }: Props) => {
return <div className={clsx(styles.container, className)}>{children}</div>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.title {
padding: 0 8px;
}

.description {
padding: 0 8px;
margin-top: 40px;
margin-bottom: 56px;
}

.list {
display: flex;
justify-content: space-between;
gap: 32px;
}

@media (max-width: 768px) {
.list {
flex-direction: column;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { DigitRecognizer, CatIdentifier } from "@/features";
import { Layout } from "@/components";
import styles from "./Recognition.module.scss";

export const Recognition = () => {
return (
<Layout>
<h1 className={styles.title}>AI Image Recognition</h1>

<p className={styles.description}>
//_Draw a digit or upload an image to experience the power of AI.
Gear.EXE recognition model identifies handwritten numbers (0–9) or
determines if an image contains cats. Submit, see results instantly, and
start again.
</p>

<div className={styles.list}>
<DigitRecognizer />

<CatIdentifier />
</div>
</Layout>
);
};
Loading