A Web3 application platform built with React, TypeScript, and Vite that allows users to create, manage, and share decentralized applications (dApps) and templates.
- Create and manage Web3 applications: Build, deploy, and share decentralized applications
- Template library: Access pre-built templates to jumpstart your dApp development
- Dashboard interface: Monitor and manage your applications
- Responsive design: Mobile-friendly UI that adapts to different screen sizes
- Web3 integration: Built-in wallet connection and blockchain interaction using DappyKit SDK
- React 18 with TypeScript
- Vite for build tooling
- React Router for navigation
- Redux Toolkit for state management
- React Bootstrap for UI components
- React Query for data fetching
- DappyKit SDK for Web3 functionality
- Fully responsive design for mobile and desktop
- Node.js with Express
- TypeScript
- Knex.js for database migrations and queries
- MySQL/PostgreSQL/SQLite support
- REST API
- Node.js (v20 or higher)
- npm or yarn
- MySQL or another supported database
-
Clone the repository:
git clone https://github.com/DappyKit/web4-apps.git cd web4-apps
-
Install frontend dependencies:
npm install
-
Setup the backend:
cd backend npm install
-
Configure the backend:
- Copy
.env.example
to.env
in the backend directory - Update the database configuration in
.env
- Copy
-
Configure the frontend:
- Copy
.env.example
to.env
in the project root - Update the API URL if needed in
.env
- Copy
-
Create the database:
mysql -u root -p<YOUR_PASSWORD> -e "CREATE DATABASE IF NOT EXISTS dappykit_apps CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
-
Create a dedicated database user:
mysql -u root -p<YOUR_PASSWORD> -e "CREATE USER 'dappykit_apps'@'localhost' IDENTIFIED BY '<DB_USER_PASSWORD>'; GRANT ALL PRIVILEGES ON dappykit_apps.* TO 'dappykit_apps'@'localhost'; FLUSH PRIVILEGES;"
-
Run database migrations:
npm run migrate
-
Seed the database with initial data:
npm run seed
-
Start the backend server:
cd backend npm run dev
-
In a new terminal, start the frontend development server:
# From the project root npm run dev
-
Access the application at http://localhost:5173
npm run migrate
# Make sure your .env file is properly configured with production database credentials
npm run migrate -- --env production
Note: For production migrations, ensure your .env file is in the correct location (backend root directory) with proper database credentials (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME).
If you need to reset the database and start fresh:
npm run backend:new
This script will rollback migrations, run them again, seed the database, and start the backend server.
For a quick recreation of just the development database:
mysql -u root -p -e "DROP DATABASE IF EXISTS dappykit_apps; CREATE DATABASE dappykit_apps CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
Run frontend tests:
npm run ui:test
Run backend tests:
npm run backend:test
Check code formatting:
npm run format:check
Fix formatting issues:
npm run format
Check for lint errors:
npm run lint:check
Check TypeScript types:
npm run types:check
Here's a step-by-step guide to deploy both frontend and backend in production:
-
Clone the repository on your server:
git clone https://github.com/DappyKit/web4-apps.git cd web4-apps
-
Set up frontend environment:
cp .env.example .env nano .env # Adjust API URL to your production server
-
Build frontend:
npm install npm run build
-
Set up backend:
cd backend npm install cp .env.example .env nano .env # Configure database and other settings for production
-
Create the database and user:
mysql -u root -p<YOUR_PASSWORD> -e "CREATE DATABASE IF NOT EXISTS dappykit_apps CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" mysql -u root -p<YOUR_PASSWORD> -e "CREATE USER 'dappykit_apps'@'localhost' IDENTIFIED BY '<DB_USER_PASSWORD>'; GRANT ALL PRIVILEGES ON dappykit_apps.* TO 'dappykit_apps'@'localhost'; FLUSH PRIVILEGES;"
-
Run migrations and build backend:
npm run migrate -- --env production npm run build
-
Deploy with PM2:
npm install -g pm2 npm install -g typescript ts-node pm2 start src/index.ts --name web4 --interpreter ts-node pm2 save pm2 startup # Follow instructions to enable startup on boot
Note: Alternatively, you can deploy compiled JavaScript version if preferred:
npm install -g pm2 npm run build pm2 start dist/index.js --name dappykit-backend pm2 save pm2 startup
-
Configure web server (Nginx) to serve static files and proxy API requests:
server { listen 80; server_name your-domain.com; # Serve frontend static files location / { root /path/to/web4-apps/dist; try_files $uri $uri/ /index.html; } # Proxy API requests to backend location /api { proxy_pass http://localhost:3001; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } }
-
Restart Nginx:
sudo service nginx restart
PM2 is a process manager for Node.js applications that helps keep your application running in production.
npm install -g pm2
This step is optional if you're running TypeScript directly with ts-node:
cd backend
npm run build
Make sure you have your production environment variables set up in .env
in the backend directory:
# Copy example environment file
cp .env.example .env
# Edit with your production settings
nano .env
Start TypeScript directly with PM2:
cd backend
pm2 start src/index.ts --name dappykit-backend --interpreter ts-node
You can also start with specific environment variables:
pm2 start src/index.ts --name dappykit-backend --interpreter ts-node --env production
Alternatively, if you prefer using compiled JavaScript:
cd backend
npm run build
pm2 start dist/index.js --name dappykit-backend
# Check status
pm2 status
# View logs
pm2 logs dappykit-backend
# Restart the backend
pm2 restart dappykit-backend
# Stop the backend
pm2 stop dappykit-backend
# Remove from PM2
pm2 delete dappykit-backend
Save the PM2 process list and configure it to start on boot:
pm2 save
pm2 startup
Then follow the instructions provided by the pm2 startup
command.
web4-apps/
βββ src/ # Frontend source code
β βββ assets/ # Static assets
β βββ components/ # Reusable React components
β βββ css/ # CSS styles
β βββ Header/ # Header components
β βββ pages/ # Page components
β βββ redux/ # Redux store and slices
β βββ services/ # API services
β βββ utils/ # Utility functions
β βββ App.tsx # Main App component
β βββ main.tsx # Entry point
β βββ ...
βββ backend/ # Backend source code
β βββ migrations/ # Database migrations
β βββ src/ # Backend source files
β β βββ routes/ # API routes
β β βββ seeds/ # Database seed files
β β βββ tests/ # Backend tests
β β βββ utils/ # Backend utilities
β β βββ index.ts # Backend entry point
β β βββ ...
β βββ ...
βββ public/ # Static public assets
βββ ...
- Follow TypeScript best practices
- Write JSDoc comments for all functions
- Ensure responsive design works on mobile devices
- Run tests, linters, and formatters before committing
npm run dev
: Start the frontend development servernpm run backend:dev
: Start the backend development servernpm run build
: Build the frontend for productionnpm run backend:build
: Build the backend for productionnpm run ui:test
: Run frontend testsnpm run backend:test
: Run backend tests
VITE_API_URL
: URL for the backend API server (default: http://localhost:3001)
DB_HOST
: Database hostDB_USER
: Database usernameDB_PASSWORD
: Database passwordDB_NAME
: Database namePORT
: Backend server port (default: 3001)