|
1 | | -# React + TypeScript + Vite |
2 | | - |
3 | | -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. |
4 | | - |
5 | | -Currently, two official plugins are available: |
6 | | - |
7 | | -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) 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 |
9 | | - |
10 | | -## Expanding the ESLint configuration |
11 | | - |
12 | | -If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: |
13 | | - |
14 | | -```js |
15 | | -export default tseslint.config({ |
16 | | - extends: [ |
17 | | - // Remove ...tseslint.configs.recommended and replace with this |
18 | | - ...tseslint.configs.recommendedTypeChecked, |
19 | | - // Alternatively, use this for stricter rules |
20 | | - ...tseslint.configs.strictTypeChecked, |
21 | | - // Optionally, add this for stylistic rules |
22 | | - ...tseslint.configs.stylisticTypeChecked, |
23 | | - ], |
24 | | - languageOptions: { |
25 | | - // other options... |
26 | | - parserOptions: { |
27 | | - project: ['./tsconfig.node.json', './tsconfig.app.json'], |
28 | | - tsconfigRootDir: import.meta.dirname, |
29 | | - }, |
30 | | - }, |
31 | | -}) |
| 1 | +# Deeploy dApp |
| 2 | + |
| 3 | +Ratio1's Deeploy front-end for deploying and operating services on the Ratio1 network. The app is built with Next.js (App Router) and provides wallet-based authentication, Deeploy job management, tunneling setup, and project drafting tools. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Wallet sign-in with SIWE via ConnectKit/Wagmi (Base & Base Sepolia networks pulled from `src/lib/config.ts`). |
| 8 | +- Create and manage Deeploy jobs and projects; drafts are stored locally with Dexie for offline-friendly editing. |
| 9 | +- Monitor running deployments, resend commands, scale workers, and review Deeploy API responses. |
| 10 | +- Cloudflare tunnel management with signed messages to fetch and store secrets securely. |
| 11 | +- Service catalog with scripted additions (`npm run add-service`) and validation (`npm run validate-services`). |
| 12 | +- Shared contexts for authentication, blockchain state, tunneling, and deployment data (`src/lib/contexts`). |
| 13 | + |
| 14 | +## Getting Started |
| 15 | + |
| 16 | +Prerequisites: Node.js 20+ and npm. |
| 17 | + |
| 18 | +1. Install dependencies: |
| 19 | + |
32 | 20 | ``` |
| 21 | +npm install |
| 22 | +``` |
| 23 | + |
| 24 | +2. Create `.env.local` (prefer this over `.env`): |
| 25 | + |
| 26 | +``` |
| 27 | +NEXT_PUBLIC_ENVIRONMENT=devnet # devnet | testnet | mainnet |
| 28 | +NEXT_PUBLIC_API_URL=http://localhost:5000 # Deeploy edge_node base URL |
| 29 | +NEXT_PUBLIC_DEV_ADDRESS=0xYourDevWallet # optional; forces this address in dev |
| 30 | +NEXT_PUBLIC_APP_VERSION=local # optional; shown in the UI footer |
| 31 | +``` |
| 32 | + |
| 33 | +- `NEXT_PUBLIC_API_URL` should point to your running [edge_node](https://github.com/Ratio1/edge_node) instance or the hosted Deeploy API. |
| 34 | +- `NEXT_PUBLIC_ENVIRONMENT` selects the chain and backend/oracle endpoints defined in `src/lib/config.ts`. |
33 | 35 |
|
34 | | -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: |
35 | | - |
36 | | -```js |
37 | | -// eslint.config.js |
38 | | -import reactX from 'eslint-plugin-react-x' |
39 | | -import reactDom from 'eslint-plugin-react-dom' |
40 | | - |
41 | | -export default tseslint.config({ |
42 | | - plugins: { |
43 | | - // Add the react-x and react-dom plugins |
44 | | - 'react-x': reactX, |
45 | | - 'react-dom': reactDom, |
46 | | - }, |
47 | | - rules: { |
48 | | - // other rules... |
49 | | - // Enable its recommended typescript rules |
50 | | - ...reactX.configs['recommended-typescript'].rules, |
51 | | - ...reactDom.configs.recommended.rules, |
52 | | - }, |
53 | | -}) |
| 36 | +3. Start the dev server (HTTPS by default): |
| 37 | + |
| 38 | +``` |
| 39 | +npm run dev |
54 | 40 | ``` |
| 41 | + |
| 42 | +Visit https://localhost:3000 and trust the local certificate if prompted. |
| 43 | + |
| 44 | +## Usage Notes |
| 45 | + |
| 46 | +- Authentication uses SIWE; tokens (`accessToken`, `refreshToken`) are kept in `localStorage` and reused by the Axios interceptors in `src/lib/api`. |
| 47 | +- Most protected routes live under `app/(protected)/…`; the public login screen is under `app/(public)/login`. |
| 48 | +- Draft projects/jobs are stored in IndexedDB (`src/lib/storage/db.ts`); clearing browser storage removes drafts. |
| 49 | +- When pointing to a local edge_node, start that server first, then set `NEXT_PUBLIC_API_URL` to its port (e.g., `http://localhost:5000`). |
| 50 | + |
| 51 | +## Scripts |
| 52 | + |
| 53 | +- `npm run dev` – Next.js dev server (`next dev --turbo --experimental-https`). |
| 54 | +- `npm run build` / `npm run start` – production build and serve. |
| 55 | +- `npm run lint` – ESLint with the project rules. |
| 56 | +- `npm run add-service` – interactive wizard to append a service to `src/data/services.ts`. |
| 57 | +- `npm run validate-services` – checks service definitions, color variants, and dynamic env types. |
| 58 | + |
| 59 | +## Project Structure |
| 60 | + |
| 61 | +- `app/` – Next.js App Router entrypoints (`(public)` and `(protected)` route groups, layouts, error pages). |
| 62 | +- `src/components/` – feature components (auth, create-job, deeploys, tunnels, etc.). |
| 63 | +- `src/shared/` – shared UI primitives and layout helpers. |
| 64 | +- `src/lib/` – configs, API clients (Deeploy, backend, oracles, tunnels), providers, contexts, hooks, utilities. |
| 65 | +- `src/data/` – static data (services catalog, color types, dynamic env types) and scripts targets. |
| 66 | +- `src/blockchain/` – contract helpers and wagmi/viem bindings. |
| 67 | +- `public/` – static assets and manifest; `certificates/` holds local HTTPS certs for dev. |
| 68 | +- `scripts/` – maintenance scripts for services and data validation. |
| 69 | + |
| 70 | +## Deployment |
| 71 | + |
| 72 | +Dockerfiles are provided per environment (`Dockerfile_devnet`, `_testnet`, `_mainnet`) and expect build args `NEXT_PUBLIC_API_URL`, `NEXT_PUBLIC_ENVIRONMENT`, and `VERSION` (mapped to `NEXT_PUBLIC_APP_VERSION`). |
| 73 | + |
| 74 | +## Testing |
| 75 | + |
| 76 | +Automated tests are not wired up yet; use `npm run lint` locally and document manual QA steps when making changes. |
0 commit comments