A full-stack web application for decentralized identity verification using blockchain technology, built with React, Express, and Firebase.
- Blockchain Integration: Connect with MetaMask wallet for identity verification
- Role-Based Access Control: Admin, Officer, and User roles with different permissions
- Real-time Database: Firebase Realtime Database for storing user data
- File Upload: IPFS integration for decentralized file storage
- Modern UI: Built with React, TypeScript, and Tailwind CSS
- Smart Contract Integration: Ethereum blockchain integration for user verification
- React 18 with TypeScript
- Vite for fast development and building
- Tailwind CSS for styling
- Radix UI components for accessibility
- TanStack Query for data fetching
- Wouter for routing
- Ethers.js for blockchain integration
- Express.js with TypeScript
- Firebase for real-time database and authentication
- Drizzle ORM for database operations
- IPFS HTTP Client for file storage
- WebSocket support for real-time features
Before running this project, make sure you have:
- Node.js (version 18 or higher)
- npm or yarn package manager
- MetaMask browser extension
- Firebase project with Realtime Database enabled
- IPFS node (optional, for file uploads)
Create a .env file in the root directory with the following variables:
# Firebase Configuration
FIREBASE_API_KEY=your_firebase_api_key
FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
FIREBASE_DATABASE_URL=https://your_project-default-rtdb.firebaseio.com/
FIREBASE_PROJECT_ID=your_project_id
FIREBASE_STORAGE_BUCKET=your_project.appspot.com
FIREBASE_MESSAGING_SENDER_ID=your_sender_id
FIREBASE_APP_ID=your_app_id
# Firebase Admin SDK (for server-side operations)
FIREBASE_ADMIN_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nyour_private_key\n-----END PRIVATE KEY-----\n"
FIREBASE_ADMIN_CLIENT_EMAIL=firebase-adminsdk-xxxxx@your_project.iam.gserviceaccount.com
FIREBASE_ADMIN_PROJECT_ID=your_project_id
# Optional: IPFS Configuration
IPFS_API_URL=http://localhost:5001
IPFS_GATEWAY_URL=http://localhost:8080
# Development
NODE_ENV=development
PORT=5000-
Clone the repository
git clone <your-repository-url> cd decentralized-identity-verification
-
Install dependencies
npm install
-
**
Then replace the content ofvite.config.tswithvite.config.standalone.ts:cp vite.config.standalone.ts vite.config.ts
-
Set up environment variables
- Copy
.env.exampleto.env - Fill in your Firebase and other service credentials
- Copy
-
Set up Firebase
- Create a Firebase project at https://console.firebase.google.com/
- Enable Realtime Database
- Generate service account credentials for admin SDK
- Add your web app configuration
npm run devThis starts both the Express server and Vite development server on port 5000.
npm run build
npm start# Push database schema changes
npm run db:push
# Type checking
npm run check├── client/ # Frontend React application
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ ├── pages/ # Page components
│ │ ├── lib/ # Utility functions
│ │ └── hooks/ # Custom React hooks
│ └── index.html # HTML template
├── server/ # Backend Express application
│ ├── routes.ts # API routes
│ ├── storage.ts # Database abstraction layer
│ ├── firebase-*.ts # Firebase integration
│ └── index.ts # Server entry point
├── shared/ # Shared types and schemas
│ ├── schema.ts # Database schemas
│ └── firebase-schema.ts # Firebase-specific schemas
└── attached_assets/ # Static assets
POST /api/auth/login- User loginPOST /api/auth/logout- User logoutGET /api/auth/user- Get current user
GET /api/users- Get all usersPOST /api/users- Create new userPUT /api/users/:id- Update userDELETE /api/users/:id- Delete user
POST /api/verify-user- Verify user on blockchainGET /api/pending-users- Get pending verification users
The application integrates with Ethereum smart contracts for identity verification:
- Connect MetaMask: Users connect their MetaMask wallet
- Submit Verification: Users submit identity documents
- Officer Review: Officers review and approve/reject submissions
- Blockchain Verification: Approved users are verified on-chain
- Access Granted: Verified users gain access to protected features
{
"users": {
"userId": {
"walletAddress": "0x...",
"email": "user@example.com",
"role": "user|officer|admin",
"verified": true,
"documents": ["ipfs_hash_1", "ipfs_hash_2"]
}
}
}Make sure to configure Firebase security rules to protect user data:
{
"rules": {
"users": {
"$uid": {
".read": "$uid === auth.uid || root.child('users').child(auth.uid).child('role').val() === 'admin'",
".write": "$uid === auth.uid || root.child('users').child(auth.uid).child('role').val() === 'admin'"
}
}
}
}# Build the application
npm run build
# Create Dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist ./dist
EXPOSE 5000
CMD ["npm", "start"]npm install -g pm2
npm run build
pm2 start dist/index.js --name "identity-verification"- Build command:
npm run build - Output directory:
dist/public - Make sure to configure environment variables in your deployment platform
-
MetaMask Connection Issues
- Ensure MetaMask is installed and unlocked
- Check that you're connected to the correct network
- Clear browser cache and cookies
-
Firebase Connection Issues
- Verify all environment variables are set correctly
- Check Firebase security rules
- Ensure Firebase services are enabled
-
Build Issues
- Clear node_modules and reinstall:
rm -rf node_modules package-lock.json && npm install - Check Node.js version compatibility
- Verify all environment variables are set
- Clear node_modules and reinstall:
- Use browser developer tools to debug frontend issues
- Check server logs for backend errors
- Use Firebase console to monitor database operations
- Test with different MetaMask accounts for role testing
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-feature - Commit changes:
git commit -am 'Add new feature' - Push to branch:
git push origin feature/new-feature - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue in the GitHub repository
- Check the troubleshooting section above
- Review Firebase and blockchain integration documentation