"In Japan they are turning footsteps into electricity."
A production-ready full-stack web app that simulates generating electricity from footsteps. Click the button → database increments → electricity counter updates in real time.
Stack: React 18 + Express + PostgreSQL + Railway
- 3-Panel Responsive Layout: Japan map, video card, live counter
- Real-time Updates: Click to generate electricity, instant DB sync
- Beautiful Dark UI: Gradient buttons, glowing cards, smooth animations
- Production Ready: Deployable to Railway in minutes
- Minimal Dependencies: No Redux, no bloat—just React + Express + PostgreSQL
Footsteps2Electricity/
├── client/ # React frontend (CRA)
│ ├── public/
│ │ └── index.html # HTML entry point
│ ├── src/
│ │ ├── App.js # Main component (3-panel layout)
│ │ ├── App.css # Dark theme styles + animations
│ │ └── index.js # React root
│ └── package.json
├── server/ # Express backend
│ ├── index.js # All routes + DB init
│ └── package.json
├── .env.example # Template for env vars
├── .gitignore # Git ignore rules
├── package.json # Root (shared scripts)
├── railway.toml # Railway deployment config
└── schema.sql # DB schema (one-time setup)
# Create local PostgreSQL database
createdb footsteps
# Run schema
psql footsteps < schema.sqlcd Footsteps2Electricity
cp .env.example .env
# Edit .env with your DB URL (use your actual Neon or Railway PostgreSQL URL)
# Example: DATABASE_URL=postgresql://user:password@host:5432/dbname
npm installnpm run devThis starts:
- Backend:
http://localhost:4000(Express server) - Frontend:
http://localhost:3000(React dev server)
The React app will proxy API calls to the backend automatically.
- Open http://localhost:3000
- Click the big blue footstep button
- Watch the electricity counter increment
Ensure your repo is pushed to GitHub. The root of your repository should have:
repo/
├── client/
├── server/
├── package.json ← Root package.json with build + start scripts
├── railway.toml
└── .env (NOT in git, set via Railway dashboard)
- Go to railway.app
- Click New Project → Deploy from GitHub
- Select your Footsteps2Electricity repository
- Railway will auto-detect and use the root directory ✓
- In Railway dashboard, click + New
- Add PostgreSQL service
- Once provisioned, copy the
DATABASE_URLconnection string
-
In your app service settings, add:
DATABASE_URL: Paste from PostgreSQL serviceNODE_ENV:production
-
Railway will auto-link the PostgreSQL plugin, but manually set it if needed.
- Railway will auto-detect your GitHub repo
- It will use the root directory (Footsteps2Electricity/) automatically
- Click Deploy
Railway will:
- Run
npm run build(builds React, installs server deps) - Run
npm start(starts Express server on PORT from Railway) - Serve React static files + handle API routes
Once live, test the endpoint:
curl https://your-railway-domain.app/electricityYou should see:
{ "electricity": 0 }| Method | Endpoint | Description | Response |
|---|---|---|---|
GET |
/electricity |
Get current counter | { electricity: number } |
POST |
/generate |
Increment by 1 | { electricity: number } |
// Get current value
fetch('/electricity')
.then(r => r.json())
.then(d => console.log(d.electricity)); // e.g., 42
// Increment
fetch('/generate', { method: 'POST' })
.then(r => r.json())
.then(d => console.log(d.electricity)); // e.g., 43npm run devRuns both React dev server and Express with auto-reload.
npm run buildBuilds React app → client/build/
npm startServes React static files + API routes on port $PORT (Railway sets this).
In server/index.js, line ~35:
'UPDATE electricity SET value = value + 1 WHERE id = 1 RETURNING value'
// Change +1 to +10, +100, etc.:root {
--blue: #3b82f6; /* Change to your color */
--green: #22c55e; /* Status dot */
/* ... */
}In client/src/App.js, search for "Click to generate electricity" and update.
- Ensure PostgreSQL is running:
brew services start postgresql - Check
DATABASE_URLin.envmatches your setup - Run
psql footsteps < schema.sqlagain
# Kill existing process
lsof -ti:3000 | xargs kill -9
lsof -ti:4000 | xargs kill -9- Ensure
npm run buildworks locally first - Check
client/package.jsonhas all dependencies - Increase Railway memory limit if needed
- Check Railway PostgreSQL is connected
- Verify
DATABASE_URLenv var is set - Check Railway logs:
railway logs
MIT
- Customize the website design
- Add real kinetic energy data from actual floor sensors
- Connect to real power grids or smart home systems
- Deploy to other platforms (Vercel, Heroku, AWS, Azure)
Made with ⚡ in Tokyo 🇯🇵