Don't forget to run git config core.hooksPath git_hooks, if you are a maintainer!
(For the most functioning version, you may see the stable branch.)
"Meritocracy" (in full: "AI Internet-Meritocracy", or AIIM) is an app that gathers crypto donations and distributes them among scientists, free software developers, and science marketers/popularizers whose salaries are based on their impact in promoting science (especially under-represented areas and discoveries).
See the site for more information.
The app decides how much to pay each employee (registered user) simply by asking an AI (not by, for example, quadratic voting of users).
Actually, this "meritocracy" is quite capitalistic, as it hinted to me (the author of the app) that I am probably worth ~$1B/year.
It is a full-stack application built with Node.js, React, and Prisma ORM.
- Node.js with Express.js - Fast, unopinionated web framework
- Prisma ORM - Modern database toolkit with type safety
- Database Support: MySQL, PostgreSQL, SQLite
- CORS enabled for cross-origin requests
- Helmet for security headers
- Morgan for HTTP request logging
- React 18 - Modern React with hooks
- Vite - Lightning fast build tool
- React Router - Declarative routing
- Axios - Promise-based HTTP client
- Modern CSS with dark/light theme support
The automated distribution service currently supports native gas tokens on:
- Ethereum family networks (Mainnet, Polygon, Arbitrum, Optimism, Base, Celo, Sepolia, Localhost)
- Solana (SOL)
- Bitcoin (BTC)
- Polkadot (DOT)
- Cosmos Hub (ATOM)
- Stellar (XLM)
- Internet Computer (ICP)
It also supports ICP ICRC-1 assets with fixed transfer fees that behave operationally like gas-token distributions:
- ckBTC
- ckETH
- ckUSDT
- ckUSDC
- ckEURC
meritocracy/
βββ backend/ # Node.js API server
β βββ src/
β β βββ index.js # Express server setup
β β βββ routes/ # API route handlers
β βββ prisma/
β β βββ schema.prisma # Database schema
β β βββ seed.js # Database seeding
β βββ package.json
β βββ env.example # Environment variables template
βββ frontend/ # React application
β βββ src/
β β βββ components/ # React components
β β βββ pages/ # Page components
β β βββ services/ # API service layer
β β βββ main.jsx # React entry point
β βββ package.json
β βββ env.example # Environment variables template
βββ package.json # Root package.json with scripts
- Node.js (v16 or higher)
- npm or yarn
- Git
git clone https://github.com/vporton/meritocracy.git
cd meritocracy# Set NPM version
nvm use v22.1.0
# Install base dependencies
npm run installcd backend
cp env.example .envEdit .env file and configure your database:
SQLite (Default - recommended for development):
DATABASE_URL="file:./dev.db"
PORT=3001
NODE_ENV=development
FRONTEND_URL=http://localhost:5173PostgreSQL:
DATABASE_URL="postgresql://username:password@localhost:5432/meritocracy?schema=public"
PORT=3001
NODE_ENV=development
FRONTEND_URL=http://localhost:5173MySQL:
DATABASE_URL="mysql://username:password@localhost:3306/meritocracy"
PORT=3001
NODE_ENV=development
FRONTEND_URL=http://localhost:5173cd frontend
cp env.example .envEdit .env file:
VITE_API_URL=http://localhost:3001# Setup database and seed with sample data
npm run db:setupThis command will:
- Generate Prisma client
- Create/update database schema
- Seed the database with sample users and posts
# Start both backend and frontend concurrently
npm run dev
# Or start separately:
npm run dev-backend # Backend on http://localhost:3001
npm run dev-frontend # Frontend on http://localhost:5173-
Update Prisma Schema (
backend/prisma/schema.prisma):datasource db { provider = "sqlite" // Change to "postgresql" or "mysql" url = env("DATABASE_URL") }
-
Update Environment Variables (
.env):- Update
DATABASE_URLwith your database connection string
- Update
-
Regenerate Prisma Client:
cd backend npx prisma generate npx prisma db push
# Reset database (caution: deletes all data)
npm run db:reset
# Open Prisma Studio (database GUI)
cd backend && npx prisma studio
# Generate Prisma client only
cd backend && npx prisma generate
# Apply schema changes
cd backend && npx prisma db push
# Create and apply migration
cd backend && npx prisma migrate devGET /api/users- Get all usersGET /api/users/:id- Get user by IDPOST /api/users- Create new userPUT /api/users/:id- Update userDELETE /api/users/:id- Delete user
// Create a new user
POST /api/users
{
"name": "John Doe",
"email": "john@example.com"
}
## π¨ Features
### Backend Features
- RESTful API design
- Database-agnostic ORM (Prisma)
- Input validation and error handling
- CORS configuration
- Security headers (Helmet)
- Request logging (Morgan)
- Environment-based configuration
### Frontend Features
- Modern React with hooks
- Responsive design with dark/light theme
- Client-side routing (React Router)
- API integration with error handling
- Real-time UI updates
- Form validation
- Loading states and user feedback
## π§ Development
### Available Scripts
**Root level:**
- `npm run install-all` - Install all dependencies
- `npm run dev` - Start both servers in development mode
- `npm run build` - Build both applications for production
- `npm run start` - Start both applications in production mode
**Backend:**
- `npm run dev` - Start development server with nodemon
- `npm run start` - Start production server
- `npm run db:generate` - Generate Prisma client
- `npm run db:push` - Push schema changes to database
- `npm run db:migrate` - Create and apply migration
- `npm run db:studio` - Open Prisma Studio
- `npm run db:seed` - Seed database with sample data
**Frontend:**
- `npm run dev` - Start Vite development server
- `npm run build` - Build for production
- `npm run preview` - Preview production build
- `npm run lint` - Run ESLint
### Code Structure Guidelines
**Backend:**
- Place route handlers in `src/routes/`
- Use Prisma client for database operations
- Follow RESTful API conventions
- Include proper error handling
**Frontend:**
- Components in `src/components/`
- Pages in `src/pages/`
- API calls in `src/services/`
- Follow React best practices and hooks
## π¦ Production Deployment
### Backend Deployment
1. Set environment variables for production
2. Ensure database is accessible
3. Run `npx prisma generate && npx prisma db push`
4. Start with `npm start`
### Frontend Deployment
1. Build the application: `npm run build`
2. Deploy the `dist/` folder to your hosting service
3. Configure environment variables for production API URL
### Environment Variables for Production
- Update `DATABASE_URL` with production database
- Set `NODE_ENV=production`
- Update `FRONTEND_URL` with production frontend URL
- Update `VITE_API_URL` with production API URL
## π€ Contributing
1. Fork the repository
2. Create a feature branch: `git checkout -b feature-name`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin feature-name`
5. Submit a pull request
## π License
This project is licensed under the MIT License - see the LICENSE file for details.
## π Troubleshooting
### Common Issues
**Database Connection Issues:**
- Verify `DATABASE_URL` in `.env` file
- Ensure database server is running (for PostgreSQL/MySQL)
- Check network connectivity and credentials
**Port Conflicts:**
- Backend default port: 3001
- Frontend default port: 5173
- Change ports in environment variables if needed
**Prisma Issues:**
- Run `npx prisma generate` after schema changes
- Delete `node_modules` and reinstall if client issues persist
- Check Prisma documentation for database-specific configurations
**Build Issues:**
- Clear node_modules and package-lock.json, then reinstall
- Check for version compatibility issues
- Ensure all environment variables are set correctly
For more help, check the documentation of the individual technologies or create an issue in the repository.