A Next.js web application designed to help Bitmask users update their usernames during the transition from campaign/testnet to mainnet. The application provides a streamlined 3-step process for users to verify and update their usernames, along with an admin dashboard for managing campaign data and viewing analytics.
This application facilitates the migration of Bitmask usernames from campaign/testnet to mainnet. Users can submit their username updates through a guided 3-step process, while administrators can manage campaign data via CSV uploads and monitor submission analytics.
- Welcome Page: Instructions and overview of the update process
- 3-Step Update Flow:
- Input old Bitmask username (from campaign)
- Verify Telegram account associated with the campaign
- Update to new mainnet Bitmask wallet username
- Validation: Automatic validation against campaign records
- Success Confirmation: Clear feedback upon successful submission
- Secure Authentication: Admin login system using InstantDB
- Multi-Admin Support:
- Regular admins can upload their own CSV files with scoped data
- Each admin's CSV uploads are tracked separately
- Superadmins can manage other admins
- CSV Upload: Upload and manage campaign data (old username, Telegram account, new username)
- Each admin maintains their own CSV dataset
- Uploading a new CSV replaces only that admin's previous upload
- Analytics Dashboard:
- Superadmins: See 100% analytics of ALL data from all admins
- Regular Admins: See analytics scoped to their own CSV data only
- Total updates submitted
- Daily and weekly update statistics
- Success rate tracking
- Activity timeline with interactive charts
- Real-time Username Updates Feed:
- Live feed of new bitmask username updates as they are submitted
- Shows old username β new username transitions
- Displays telegram account and timestamp
- Updates automatically without page refresh
- Real-time Data: Analytics refresh every 30 seconds
- Framework: Next.js 16 (App Router)
- Language: TypeScript
- UI: React 19, Tailwind CSS 4
- Database: InstantDB (real-time database)
- Charts: Recharts
- Authentication: InstantDB Auth
- Node.js 18+ and npm/yarn/pnpm/bun
- InstantDB account and App ID
- (Optional) InstantDB Admin Token for production
npm install
# or
yarn install
# or
pnpm installCreate a .env.local file in the root directory:
# Required: Your InstantDB App ID
NEXT_PUBLIC_INSTANT_APP_ID=your-app-id-here
# Optional: For production admin operations
INSTANT_ADMIN_TOKEN=your-admin-token-hereNote: For detailed InstantDB setup instructions, see INSTANTDB_SETUP.md
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devThe application will be available at http://localhost:3000
npm run build
npm startβββ app/ # Next.js App Router
β βββ admin/ # Admin routes
β β βββ dashboard/ # Admin dashboard page
β β βββ login/ # Admin login page
β βββ api/ # API routes
β β βββ analytics/ # Analytics data endpoint
β β βββ csv/ # CSV upload endpoint
β β βββ users/ # User update endpoints
β βββ update/ # User update flow page
β βββ layout.tsx # Root layout
β βββ page.tsx # Home/instructions page
βββ components/ # React components
β βββ AdminDashboard.tsx # Admin dashboard component
β βββ AdminLogin.tsx # Admin login component
β βββ Analytics.tsx # Analytics charts component
β βββ CSVUpload.tsx # CSV upload component
β βββ InstructionsPage.tsx # Welcome/instructions page
β βββ Step1Form.tsx # Step 1: Old username input
β βββ Step2Form.tsx # Step 2: Telegram verification
β βββ Step3Form.tsx # Step 3: New username input
β βββ StepIndicator.tsx # Progress indicator
β βββ SuccessMessage.tsx # Success confirmation
β βββ UpdateFlow.tsx # Main update flow orchestrator
βββ lib/ # Utility libraries
β βββ auth.ts # Authentication helpers
β βββ instantdb.ts # InstantDB configuration
β βββ storage.ts # Database operations
β βββ utils.ts # Utility functions
βββ types/ # TypeScript type definitions
β βββ index.ts # Type definitions and schema
βββ public/ # Static assets
Submit a username update request.
Request Body:
{
"oldUsername": "old_username",
"telegramAccount": "@telegram_handle",
"newUsername": "new_username"
}Response:
200: Update successful400: Validation error (missing fields, account not found, username mismatch)409: Duplicate submission500: Server error
Upload CSV file with campaign data. Requires admin authentication.
Request:
Content-Type: multipart/form-datafile: CSV file with columns:oldUsername,telegramAccount,newUsername
Response:
{
"message": "CSV uploaded successfully",
"rowCount": 100
}Get analytics data for the dashboard.
Response:
{
"totalUpdates": 150,
"updatesPerDay": [{ "date": "2024-01-01", "count": 10 }],
"updatesPerWeek": [{ "week": "2024-01-01", "count": 50 }],
"successRate": 100,
"activityTimeline": [{ "date": "2024-01-01", "count": 10 }]
}The application uses InstantDB with the following schema:
-
csv_records: Campaign data records
oldUsername: stringtelegramAccount: stringnewUsername: stringcreatedAt: number (timestamp)uploadedBy: string (email of admin who uploaded the CSV)
-
user_updates: Submitted username updates
oldUsername: stringtelegramAccount: stringnewUsername: stringsubmittedAt: number (timestamp)
-
admin_users: Admin user records
email: stringrole: string ('admin' | 'superadmin')createdAt: number (timestamp)
The admin dashboard uses InstantDB authentication. Admin users must log in through /admin/login to access:
- CSV upload functionality
- Analytics dashboard
The CSV file should have the following columns:
oldUsername: The username used during the campaigntelegramAccount: The Telegram handle (with or without @)newUsername: The new mainnet username
Example:
oldUsername,telegramAccount,newUsername
user123,@telegram_user,newuser123
user456,@another_user,newuser456
- Dark Theme: Black background with yellow accent color
- Responsive Design: Works on desktop and mobile devices
- Step Indicator: Visual progress tracking through the update process
- Form Validation: Real-time validation with clear error messages
- Interactive Charts: Recharts-powered analytics visualization
- Loading States: Clear feedback during async operations
npm run dev: Start development server with Turbonpm run dev:no-turbo: Start development server without Turbonpm run build: Build for productionnpm start: Start production servernpm run lint: Run ESLint
- TypeScript strict mode enabled
- ESLint configured with Next.js rules
- Tailwind CSS for styling
- INSTANTDB_SETUP.md - Detailed InstantDB configuration guide
- LOCAL_SETUP_GUIDE.md - Local development setup guide
The application can be deployed to any platform that supports Next.js:
- Push your code to GitHub
- Import your repository in Vercel
- Add environment variables in Vercel dashboard
- Deploy
Ensure you set the following environment variables:
NEXT_PUBLIC_INSTANT_APP_IDINSTANT_ADMIN_TOKEN(for production)
- Admin routes are protected with authentication
- CSV data is validated before processing
- User submissions are validated against campaign records
- Duplicate submissions are prevented
- Error messages are sanitized in production
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is private and proprietary.
If you encounter errors like "Module factory is not available" during development:
- Refresh the browser - The app uses lazy initialization to handle HMR gracefully
- Restart the dev server if the error persists:
# Stop server (Ctrl+C) npm run dev - Clear Next.js cache if issues continue:
rm -rf .next npm run dev
- Use non-Turbo mode as a fallback:
npm run dev:no-turbo
- Verify
.env.localexists in the root directory - Check the file contains:
NEXT_PUBLIC_INSTANT_APP_ID=e183332d-f1ca-469a-a705-d24f4f39eb12 - Restart the development server after creating/modifying
.env.local
- Check spam/junk folder
- Verify email delivery is configured in InstantDB dashboard
- Wait a few minutes and try again
- Check browser console for errors
- Admin must upload CSV file first via
/admin/dashboard - Ensure CSV contains the user's Telegram account
- Verify CSV format is correct (oldUsername,telegramAccount,newUsername)
# Kill the process using port 3000
lsof -ti:3000 | xargs kill -9
# Or use a different port
PORT=3001 npm run dev- Delete
node_modulesandpackage-lock.json - Run
npm installagain - Clear Next.js cache:
rm -rf .next - Restart the development server
For issues or questions:
- Check the setup guides in the documentation files
- Verify your InstantDB configuration
- Check the browser console for errors
- Review the API response messages
- See the Troubleshooting section above
Built with β€οΈ for Bitmask community