A blockchain-based government spending transparency web application for Malaysia, built with React, Node.js, and smart contracts on the Polygon network.
- 📊 Real-time Dashboard - Interactive spending visualization with charts
- 🔍 Advanced Search & Filtering - Find projects by department, location, type, and amount
- 🌐 Multi-language Support - English and Bahasa Malaysia
- 📱 Mobile Responsive - Malaysian color scheme (Red, Blue, Yellow)
- 📋 Project Details - Individual pages showing budget vs actual spending
- 💬 Citizen Feedback System - Rate and comment on projects
- 🛠️ Admin Interface - Government officials can add spending records
- ⛓️ Smart Contracts - Immutable transaction records on Polygon
- 🏛️ Government Departments - Pre-configured Malaysian ministries
- 📈 API Endpoints - RESTful API for data access and manipulation
- 🔒 Secure & Transparent - Blockchain-based verification
- 📊 Real-time Analytics - Spending statistics and trends
- Ministry of Health (Kementerian Kesihatan)
- Ministry of Education (Kementerian Pendidikan)
- Ministry of Transport (Kementerian Pengangkutan)
- Ministry of Finance (Kementerian Kewangan)
- Ministry of Defence (Kementerian Pertahanan)
- Ministry of Home Affairs (Kementerian Dalam Negeri)
- Ministry of Science, Technology and Innovation (Kementerian Sains, Teknologi dan Inovasi)
- Ministry of Tourism, Arts and Culture (Kementerian Pelancongan, Seni dan Budaya)
- Frontend: React 18, TypeScript, Tailwind CSS, Recharts, React Router
- Backend: Node.js, Express, TypeScript
- Blockchain: Solidity, Hardhat, Ethers.js, Polygon Network
- Styling: Tailwind CSS with Malaysian flag colors
- Internationalization: react-i18next for English/Bahasa Malaysia support
tranparencymy/
├── frontend/ # React TypeScript application
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── pages/ # Page components
│ │ ├── hooks/ # Custom React hooks
│ │ ├── utils/ # Utility functions and API
│ │ └── types/ # TypeScript type definitions
│ ├── public/ # Static assets
│ └── package.json
├── backend/ # Node.js Express API
│ ├── src/
│ │ ├── routes/ # API route handlers
│ │ ├── controllers/ # Business logic
│ │ ├── middleware/ # Express middleware
│ │ ├── models/ # Data models
│ │ └── utils/ # Utility functions
│ ├── contracts/ # Solidity smart contracts
│ ├── scripts/ # Deployment scripts
│ ├── test/ # Contract tests
│ └── package.json
└── README.md
- Node.js 16+ and npm
- Git
- MetaMask browser extension
- Polygon wallet with MATIC tokens (for mainnet deployment only)
- 4 terminal windows for full local development
git clone <repository-url>
cd tranparencymy
npm run install:allCreate .env files in the backend directory:
# backend/.env
PORT=3001
NODE_ENV=development
# Blockchain Configuration
POLYGON_RPC_URL=https://polygon-rpc.com
MUMBAI_RPC_URL=https://rpc-mumbai.maticvigil.com
# For local development, private key is optional (uses hardhat accounts)
PRIVATE_KEY=your_private_key_here
# Frontend URL
FRONTEND_URL=http://localhost:3000
# Optional: For contract verification on Polygonscan
POLYGONSCAN_API_KEY=your_polygonscan_api_key_here# Terminal 1 - Start Hardhat local blockchain
cd backend
npx hardhat nodeThis will start a local blockchain on http://127.0.0.1:8545 with 20 pre-funded accounts.
# Terminal 2 - Deploy contracts to local network
cd backend
npm run compile
npx hardhat run scripts/deploy.js --network localhostFor testnet/mainnet deployment:
npm run deploy:mumbai # For Mumbai testnet
# or
npm run deploy:polygon # For Polygon mainnet# From root directory
npm run devThis will start:
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001
Open http://localhost:3000 in your browser to see the TransparensiMY dashboard.
-
Add Localhost Network to MetaMask:
- Network Name:
Localhost 8545 - RPC URL:
http://127.0.0.1:8545 - Chain ID:
31337 - Currency Symbol:
ETH
- Network Name:
-
Import Test Account:
- Private Key:
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 - This account has admin permissions and 10,000 ETH for testing
- Private Key:
-
Test Blockchain Functionality:
cd backend node scripts/test-blockchain.js
Admin/Government Access:
- Email:
admin@malaysia.gov.my - Password:
admin123 - Permissions: Submit spending records, view admin dashboard
Citizen Access:
- Email:
citizen@example.com - Password:
citizen123 - Permissions: View projects, submit feedback, rate transparency
GET /api/transactions- List all transactions with paginationGET /api/transactions/:id- Get specific transactionGET /api/transactions/search/:query- Search transactionsGET /api/transactions/stats/summary- Get spending statisticsGET /api/transactions/stats/by-department- Department spending breakdown
GET /api/departments- List all departmentsGET /api/departments/:id/spending- Department spending detailsGET /api/departments/:id/transactions- Transactions by department
POST /api/feedback- Submit citizen feedbackGET /api/feedback/transaction/:id- Get feedback for transactionGET /api/feedback/rating/:id- Get rating summary
POST /api/admin/transaction- Create new transaction (authorized only)GET /api/admin/dashboard- Admin dashboard statistics
Main contract for recording government transactions with features:
- Transaction recording and updating
- Department management
- Spending analytics
- Access control for authorized officials
Contract for citizen feedback system with features:
- Feedback submission with ratings (1-5)
- Comment moderation
- Rating aggregation
- User management (ban/unban)
-
Terminal 1 - Blockchain Node:
cd backend npx hardhat node -
Terminal 2 - Deploy Contracts:
cd backend npx hardhat run scripts/deploy.js --network localhost -
Terminal 3 - Backend Server:
cd backend npm run dev -
Terminal 4 - Frontend Server:
cd frontend npm start
cd backend
npm run compile # Compile contracts
npm run test # Run tests
node scripts/test-blockchain.js # Test blockchain functionality
npx hardhat run scripts/deploy.js --network localhost # Deploy to local- TypeScript strict mode enabled
- Tailwind CSS for styling
- ESLint and Prettier configured
- Malaysian color scheme and design principles
Build the React app:
cd frontend
npm run buildBuild the Node.js app:
cd backend
npm run build
npm startDeploy to Polygon mainnet or Mumbai testnet:
cd backend
npx hardhat run scripts/deploy.js --network polygon- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes and commit:
git commit -m 'Add some feature' - Push to the branch:
git push origin feature-name - Submit a pull request
- Smart contracts audited for common vulnerabilities
- Input validation on all API endpoints
- Rate limiting and CORS protection
- Environment variables for sensitive data
- Multi-signature wallet support for contract administration
This project is licensed under the MIT License - see the LICENSE file for details.
- Malaysian government for transparency initiatives
- Polygon network for scalable blockchain infrastructure
- React and Node.js communities for excellent tooling
- Open source contributors and maintainers
TransparensiMY - Building trust through transparency in government spending. 🏛️✨