Complete guide for setting up and developing the Invoisio legacy webapp
This document provides step-by-step instructions for setting up the legacy webapp (legacy/webapp), understanding its architecture, and contributing to the codebase.
- Prerequisites
- Installation
- Environment Variables
- Available Scripts
- Project Structure
- Development Workflow
- Linting & Formatting
- Troubleshooting
Before you begin, ensure you have the following installed on your system:
| Tool | Version | Purpose |
|---|---|---|
| Node.js | 18.x or higher | JavaScript runtime |
| npm | 9.x or higher | Package manager (comes with Node.js) |
| pnpm (optional) | 8.x or higher | Alternative package manager |
| Git | Latest | Version control |
| EVM Wallet | - | MetaMask or Coinbase Wallet for testing |
node --version # Should show v18.x or higher
npm --version # Should show 9.x or highernpm install -g pnpmcd legacy/webappChoose your preferred package manager:
# Using npm
npm install
# Using pnpm (recommended for faster installs)
pnpm install
# Using yarn
yarn installThis will install all dependencies listed in package.json, including:
- Next.js 14.2.16 (App Router)
- React 18
- TypeScript 5
- Tailwind CSS 4.1.9
- Radix UI components
- Wagmi & Coinbase OnchainKit for Web3 integration
npm run devThe application will be available at http://localhost:3000
The webapp uses environment variables for configuration. Create a .env.local file in the legacy/webapp directory:
touch .env.local| Variable | Description | Default | Example |
|---|---|---|---|
NEXT_PUBLIC_API_BASE |
Backend API base URL | http://localhost:3001 |
https://api.invoisio.com |
| Variable | Description | Default | Example |
|---|---|---|---|
NEXT_PUBLIC_CHAIN_ID |
Blockchain network ID | 8453 (Base) |
84532 (Base Sepolia) |
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID |
WalletConnect project ID | - | abc123... |
# Backend API
NEXT_PUBLIC_API_BASE=http://localhost:3001
# Optional: Blockchain Configuration
NEXT_PUBLIC_CHAIN_ID=8453- API Configuration:
lib/api.ts,lib/axios.ts,utils/api-config.ts - Wagmi Configuration:
lib/wagmi.ts - Next.js Config:
next.config.mjs
All scripts are defined in package.json:
| Script | Command | Description |
|---|---|---|
| dev | npm run dev |
Start development server on http://localhost:3000 |
| build | npm run build |
Build production-ready application |
| start | npm run start |
Start production server (requires build first) |
| lint | npm run lint |
Run ESLint to check code quality |
npm run dev- Starts Next.js development server with hot reload
- Enables React Fast Refresh
- Shows detailed error messages
- Runs on port 3000 by default
npm run build
npm run start- Creates optimized production bundle
- Minifies JavaScript and CSS
- Generates static pages where possible
- Runs production server on port 3000
npx tsc --noEmit- Checks TypeScript types without emitting files
- Useful for catching type errors before build
legacy/webapp/
├── app/ # Next.js App Router (pages & layouts)
│ ├── create/ # Invoice creation page
│ ├── dashboard/ # User dashboard
│ ├── invoices/ # Invoice management pages
│ ├── payment/ # Payment processing pages
│ ├── preview/ # Invoice preview page
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout with providers
│ ├── page.tsx # Landing page
│ └── providers.tsx # Context providers wrapper
│
├── components/ # Reusable React components
│ ├── ui/ # Shadcn/ui base components
│ ├── crypto-payment.tsx # Crypto payment widget
│ ├── invoice-preview.tsx # Invoice preview component
│ ├── navigation.tsx # Main navigation bar
│ ├── theme-provider.tsx # Dark/light theme provider
│ ├── wallet-connect-modal.tsx # Wallet connection modal
│ └── ... # Feature-specific components
│
├── hooks/ # Custom React hooks
│ ├── use-auth-store.ts # Authentication state management
│ ├── use-evm-wallet.ts # EVM wallet integration
│ ├── use-invoice-store.ts # Invoice state management
│ ├── use-payment-store.ts # Payment state management
│ └── use-mobile.ts # Mobile detection hook
│
├── lib/ # Utility libraries & configurations
│ ├── api.ts # API client (fetch-based)
│ ├── axios.ts # Axios instance with interceptors
│ ├── wagmi.ts # Wagmi Web3 configuration
│ ├── utils.ts # General utility functions
│ └── pdf-generator.tsx # PDF generation utilities
│
├── utils/ # Helper utilities
│ ├── api-config.ts # API configuration constants
│ ├── basename.ts # Base name utilities
│ └── get-cookie.ts # Cookie management
│
├── styles/ # Additional stylesheets
│ ├── globals.css # Global CSS variables
│ └── neumorphic.css # Neumorphic design styles
│
├── types/ # TypeScript type definitions
│ ├── user.ts # User-related types
│ └── *.d.ts # Module declarations
│
├── public/ # Static assets
│ ├── assest/ # Images and icons
│ ├── wallets/ # Wallet icons
│ ├── manifest.webmanifest # PWA manifest
│ └── sw.js # Service worker
│
├── stubs/ # Webpack alias stubs
│ └── empty.js # Empty module for native deps
│
├── next.config.mjs # Next.js configuration
├── tsconfig.json # TypeScript configuration
├── postcss.config.mjs # PostCSS configuration
├── components.json # Shadcn/ui configuration
└── package.json # Dependencies & scripts
app/: Next.js 14 App Router structure. Each folder represents a route.components/: Reusable UI components. Theui/subfolder contains Shadcn/ui primitives.hooks/: Custom React hooks for state management and side effects.lib/: Core utilities and third-party library configurations.styles/: Global CSS and custom design system styles.types/: TypeScript type definitions and module declarations.
The webapp requires the backend API to be running. See api-endpoints-auth.md for backend setup.
# In a separate terminal, from the project root
cd backend
npm install
npm run start:devThe backend should be running on http://localhost:3001
cd legacy/webapp
npm run dev- Open http://localhost:3000
- Click "Connect Wallet" in the navigation
- Choose Coinbase Wallet or MetaMask
- Approve the connection request
- Components: Edit files in
components/and see changes instantly - Pages: Modify files in
app/to update routes - Styles: Update Tailwind classes or edit
styles/files - API Calls: Modify
lib/api.tsorlib/axios.ts
# Type checking
npx tsc --noEmit
# Linting
npm run lint
# Build test
npm run buildnpm run lintThis checks for:
- Code quality issues
- React best practices
- Next.js-specific rules
- TypeScript errors
npm run lint -- --fix| Issue | Fix |
|---|---|
'React' must be in scope |
Not needed in Next.js 14+ (auto-imported) |
img elements must have alt |
Add alt="" or descriptive text |
Unexpected console statement |
Remove or use // eslint-disable-next-line |
Missing return type |
Add explicit return type to functions |
# Check types without building
npx tsc --noEmit
# Check specific file
npx tsc --noEmit path/to/file.tsError: Port 3000 is already in use
Solution:
# Kill the process using port 3000
lsof -ti:3000 | xargs kill -9
# Or use a different port
PORT=3001 npm run devError: Module not found: Can't resolve '@/components/...'
Solution:
# Reinstall dependencies
rm -rf node_modules package-lock.json
npm install
# Clear Next.js cache
rm -rf .next
npm run devError: Wallet doesn't connect or shows errors
Solution:
- Ensure you're using a supported wallet (Coinbase Wallet recommended)
- Check that you're on the correct network (Base or Base Sepolia)
- Clear browser cache and localStorage
- Check
lib/wagmi.tsconfiguration
Error: API 404 or Network Error
Solution:
- Verify backend is running on http://localhost:3001
- Check
NEXT_PUBLIC_API_BASEin.env.local - Verify CORS is enabled in backend
- Check network tab in browser DevTools
Error: Build fails with TypeScript or ESLint errors
Solution:
# The build ignores errors by default (see next.config.mjs)
# To fix properly:
npm run lint -- --fix
npx tsc --noEmit
# Check next.config.mjs settings:
# - eslint.ignoreDuringBuilds: true
# - typescript.ignoreBuildErrors: trueError: Tailwind classes don't apply
Solution:
- Ensure
globals.cssis imported inapp/layout.tsx - Check
postcss.config.mjsis correct - Clear
.nextcache:rm -rf .next && npm run dev - Verify Tailwind v4 syntax (uses
@tailwindcss/postcss)
Error: Text content does not match server-rendered HTML
Solution:
- Avoid using
windoworlocalStorageduring initial render - Use
useEffectfor client-only code - Check theme provider implementation
- Ensure consistent data between server and client
If you see errors about static generation:
# Check if dynamic routes are properly configured
# Ensure data fetching uses proper Next.js patternsImages are unoptimized by default (see next.config.mjs). To enable:
// next.config.mjs
images: {
unoptimized: false, // Change to false
}If you encounter issues not covered here:
- Check the Next.js documentation
- Review Tailwind CSS v4 docs
- Check Wagmi documentation for Web3 issues
- Open an issue on GitHub with:
- Error message
- Steps to reproduce
- Your environment (Node version, OS, etc.)
- Next.js Documentation: https://nextjs.org/docs
- Tailwind CSS: https://tailwindcss.com/docs
- Radix UI: https://www.radix-ui.com/
- Wagmi: https://wagmi.sh/
- Coinbase OnchainKit: https://onchainkit.xyz/
- API Endpoints & Auth - Backend API documentation
- Database Migrations - Database setup guide
- Smart Contracts - Contract deployment guide
Last Updated: March 2026
Maintainer: Development Team