Skip to content

Commit 4fccb5f

Browse files
Merge pull request #5 from ASCS-eV/siyovush_frontend
Siyovush frontend
2 parents 4fb1800 + bfa539f commit 4fccb5f

25 files changed

Lines changed: 1674 additions & 1023 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
dist
3+
.git
4+
.DS_Store
5+
coverage
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
VITE_TRUST_ANCHOR_ADDRESS=#DIDMultisigController_address
22
VITE_REGISTRY_ADDRESS=
33
VITE_CRSET_REGISTRY_ADDRESS=#CompanyCRSetRegistry_address
4-
VITE_PINATA_JWT=your_pinata_jwt_token_here
4+
VITE_PINATA_JWT=your_pinata_jwt_token

packages/demo-app-frontend/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ dist-ssr
2323
*.sln
2424
*.sw?
2525
.vite/
26-
.vite
26+
.vite
27+
/.vite/
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Stage 1: Build the application
2+
FROM node:20-alpine AS builder
3+
4+
WORKDIR /app
5+
6+
# Install dependencies (cache optimized)
7+
COPY package.json package-lock.json* ./
8+
# Note: If you use yarn or pnpm, copy their lockfiles instead
9+
RUN npm ci
10+
11+
# Copy source code
12+
COPY . .
13+
14+
# Build the application
15+
# Ensure .env is present or variables are passed via build-args if needed for Vite
16+
RUN npm run build
17+
18+
# Stage 2: Serve with Nginx
19+
FROM nginx:alpine
20+
21+
# Remove default nginx static assets
22+
RUN rm -rf /usr/share/nginx/html/*
23+
24+
# Copy static assets from builder stage
25+
COPY --from=builder /app/dist /usr/share/nginx/html
26+
27+
# Copy custom nginx configuration
28+
COPY nginx.conf /etc/nginx/conf.d/default.conf
29+
30+
# Expose port 80
31+
EXPOSE 80
32+
33+
# Start Nginx
34+
CMD ["nginx", "-g", "daemon off;"]
Lines changed: 112 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,125 @@
1-
# React + TypeScript + Vite
1+
# Etherlink SSI Governance Dashboard
22

3-
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
3+
The client-side application for the Etherlink SSI Governance Platform. This dashboard provides two distinct portals: one for the **Trust Anchor** (Governance & Administration) and one for **Companies** (Identity Onboarding & Revocation Management).
44

5-
Currently, two official plugins are available:
5+
## 📋 Prerequisites
66

7-
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8-
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
7+
Before running the frontend, ensure the following requirements are met:
98

10-
## React Compiler
9+
1. **Local Blockchain Node:** A Hardhat node must be running.
10+
2. **Deployed Contracts:** The `CompanyCRSet` module must be deployed to the local network.
11+
3. **Environment Variables:** Create a `.env` file in this directory with your contract addresses and Pinata keys.
1112

12-
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13+
```bash
14+
cp .env.example .env
1315

14-
## Expanding the ESLint configuration
16+
```
1517

16-
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
18+
**Required Variables:**
1719

18-
```js
19-
export default defineConfig([
20-
globalIgnores(['dist']),
21-
{
22-
files: ['**/*.{ts,tsx}'],
23-
extends: [
24-
// Other configs...
20+
```env
2521
26-
// Remove tseslint.configs.recommended and replace with this
27-
tseslint.configs.recommendedTypeChecked,
28-
// Alternatively, use this for stricter rules
29-
tseslint.configs.strictTypeChecked,
30-
// Optionally, add this for stylistic rules
31-
tseslint.configs.stylisticTypeChecked,
22+
VITE_TRUST_ANCHOR_ADDRESS=0x...
23+
VITE_REGISTRY_ADDRESS=0x...
24+
VITE_CRSET_REGISTRY_ADDRESS=0x...
25+
VITE_PINATA_JWT=your_pinata_jwt_token
3226
33-
// Other configs...
34-
],
35-
languageOptions: {
36-
parserOptions: {
37-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
38-
tsconfigRootDir: import.meta.dirname,
39-
},
40-
// other options...
41-
},
42-
},
43-
])
4427
```
4528

46-
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47-
48-
```js
49-
// eslint.config.js
50-
import reactX from 'eslint-plugin-react-x'
51-
import reactDom from 'eslint-plugin-react-dom'
52-
53-
export default defineConfig([
54-
globalIgnores(['dist']),
55-
{
56-
files: ['**/*.{ts,tsx}'],
57-
extends: [
58-
// Other configs...
59-
// Enable lint rules for React
60-
reactX.configs['recommended-typescript'],
61-
// Enable lint rules for React DOM
62-
reactDom.configs.recommended,
63-
],
64-
languageOptions: {
65-
parserOptions: {
66-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
67-
tsconfigRootDir: import.meta.dirname,
68-
},
69-
// other options...
70-
},
71-
},
72-
])
29+
---
30+
31+
## 🐳 Docker Setup (Recommended)
32+
33+
You can containerize this application using the included Dockerfile (Nginx + Alpine).
34+
35+
### 1. Build the Image
36+
37+
*Note: The build process bakes the `.env` variables into the static files. Ensure your `.env` file is correct before building.*
38+
39+
```bash
40+
docker build -t ssi-frontend .
41+
7342
```
43+
44+
### 2. Run the Container
45+
46+
Map port 80 of the container to port 8080 on your host.
47+
48+
```bash
49+
docker run -d -p 8080:80 --name ssi-app ssi-frontend
50+
51+
```
52+
53+
Access the application at: **[http://localhost:8080](https://www.google.com/search?q=http://localhost:8080)**
54+
55+
---
56+
57+
## 💻 Local Development
58+
59+
To run the application in development mode with Hot Module Replacement (HMR):
60+
61+
```bash
62+
# Install dependencies
63+
npm install
64+
65+
# Start Dev Server
66+
npm run dev
67+
68+
```
69+
70+
---
71+
72+
## 📖 Usage Guide
73+
74+
The application supports two distinct user roles. Use MetaMask to switch between wallets to simulate these roles.
75+
76+
### 🏛️ Role 1: Trust Anchor (Administrator)
77+
78+
*Use the wallet address that deployed the contracts (Account #0).*
79+
80+
1. **Dashboard Overview:**
81+
* Navigate to `/trust-anchor`.
82+
* View real-time governance stats, quorum thresholds, and active proposals.
83+
84+
85+
2. **Registering Companies:**
86+
* Go to **Companies**.
87+
* Search for a company's DID address (Wallet Address).
88+
* If the company is "Not Managed", wait for them to delegate control.
89+
* If they have delegated (Yellow status), scroll down to **"CRSet Admins"**.
90+
* Paste the company's address and click **Add**. This completes the registration immediately (no proposal required).
91+
92+
93+
3. **Governance:**
94+
* Go to **Governance**.
95+
* Propose adding/removing admins or updating the multi-sig quorum threshold.
96+
97+
98+
99+
### 🏢 Role 2: Company (User)
100+
101+
*Use any other wallet address (Account #1, #2, etc.).*
102+
103+
1. **Onboarding:**
104+
* Navigate to `/company/onboarding`.
105+
* **Step 1 (Delegate):** Sign the transaction to transfer identity ownership to the Trust Anchor.
106+
* **Step 2 (Verification):** Wait for the Trust Anchor to approve your registration and add you as a CRSet Admin.
107+
* **Step 3 (Complete):** Once verified, the dashboard will unlock.
108+
109+
110+
2. **Revocation Management:**
111+
* Navigate to `/company/revocations`.
112+
* **Upload:** Drag & Drop a W3C-compliant JSON revocation list.
113+
* **Publish:** The app uploads the file to IPFS (via Pinata) and updates the smart contract with the new CID.
114+
115+
116+
117+
---
118+
119+
## 🛠 Tech Stack
120+
121+
* **Framework:** React + Vite
122+
* **Language:** TypeScript
123+
* **Web3 Integration:** Wagmi v2, Viem, TanStack Query
124+
* **Styling:** Tailwind CSS, Lucide Icons
125+
* **Deployment:** Docker, Nginx
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
5+
root /usr/share/nginx/html;
6+
index index.html;
7+
8+
# Gzip compression for performance
9+
gzip on;
10+
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
11+
12+
location / {
13+
# First attempt to serve request as file, then
14+
# as directory, then fall back to redirecting to index.html
15+
try_files $uri $uri/ /index.html;
16+
}
17+
18+
# Cache static assets (images, fonts, etc.)
19+
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
20+
expires 1M;
21+
access_log off;
22+
add_header Cache-Control "public";
23+
}
24+
25+
# Cache css and js bundles
26+
location ~* \.(?:css|js)$ {
27+
try_files $uri =404;
28+
expires 1y;
29+
access_log off;
30+
add_header Cache-Control "public";
31+
}
32+
}

packages/demo-app-frontend/package-lock.json

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

packages/demo-app-frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"react": "^19.2.0",
1818
"react-dom": "^19.2.0",
1919
"react-router-dom": "^7.11.0",
20+
"sonner": "^2.0.7",
2021
"tailwind-merge": "^3.4.0",
2122
"viem": "^2.43.3",
2223
"wagmi": "^3.1.0"

0 commit comments

Comments
 (0)