Follow these steps to get EVFlow running on your local machine.
Make sure you have:
- ✅ Node.js 18+ installed (
node --version) - ✅ PostgreSQL 14+ installed and running
- ✅ npm installed (
npm --version)
Windows:
- Download PostgreSQL from https://www.postgresql.org/download/windows/
- During installation, make sure to install the PostGIS extension via Stack Builder
- Remember your postgres password!
Verify Installation:
psql --versionOption 1 - Using the setup script (recommended):
cd backend
npm run db:setupOption 2 - Manual setup:
# Connect to PostgreSQL
psql -U postgres
# Create database
CREATE DATABASE evflow;
# Connect to evflow database
\c evflow
# Enable PostGIS
CREATE EXTENSION IF NOT EXISTS postgis;
# Exit psql
\q
# Run schema
psql -U postgres -d evflow -f database/schema.sqlCreate a .env file in the root directory:
# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=evflow
DB_USER=postgres
DB_PASSWORD=your_postgres_password_here
# JWT Secret (change this!)
JWT_SECRET=change-this-to-a-random-secret-key
# Server Configuration
PORT=5000
NODE_ENV=development
FRONTEND_URL=http://localhost:3000
# Mapbox Token (REQUIRED for maps)
# Get your free token from: https://account.mapbox.com/access-tokens/
NEXT_PUBLIC_MAPBOX_TOKEN=pk.your_mapbox_token_here
# OpenChargeMap API (Optional)
# Get API key from: https://openchargemap.org/site/loginprovider/register
OPENCHARGE_API_KEY=your_opencharge_api_key_here
OPENCHARGE_API_URL=https://api.openchargemap.io/v3
# Frontend API URL
NEXT_PUBLIC_API_URL=http://localhost:5000- Go to https://account.mapbox.com/
- Sign up for a free account
- Go to "Access tokens" section
- Copy your default public token
- Paste it in
.envasNEXT_PUBLIC_MAPBOX_TOKEN
cd backend
npm run db:seedThis will add:
- 15 popular EV models (Tesla, Nissan, Hyundai, etc.)
- Sample charging station data will be synced from OpenChargeMap when you use the app
Terminal 1 - Backend:
cd backend
npm run devYou should see:
🚀 EVFlow API server running on port 5000
✅ Database connected successfully
Terminal 2 - Frontend:
npm run devYou should see:
▲ Next.js 14.x.x
- Local: http://localhost:3000
Open your browser and go to:
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000/health
- Click "Get Started" or "Register"
- Fill in your details
- You'll be redirected to the dashboard
- Allow location access when prompted (or it will use a default location)
The app will automatically attempt to load nearby stations based on your location using the OpenChargeMap API.
If you want to manually sync stations for a specific location, you can use the API:
curl -X POST http://localhost:5000/api/stations/sync \
-H "Content-Type: application/json" \
-d '{
"latitude": 37.7749,
"longitude": -122.4194,
"radius": 10
}'Error: "password authentication failed"
- Check your
DB_PASSWORDin.envmatches your PostgreSQL password - Make sure PostgreSQL is running:
pg_ctl status
Error: "database evflow does not exist"
- Run
npm run db:setupin the backend directory
Blank map or "Error loading map"
- Check that
NEXT_PUBLIC_MAPBOX_TOKENis set correctly in.env - Verify your Mapbox token is valid at https://account.mapbox.com/
- Restart the frontend server after adding the token
Empty station list
- Make sure you've allowed location access in your browser
- Check browser console for errors
- Try manually syncing stations using the curl command above
- Verify your internet connection (needs to reach OpenChargeMap API)
Error: "Port 3000 is already in use"
# Windows
netstat -ano | findstr :3000
taskkill /PID <PID> /F
# Then restart the serverError: "Port 5000 is already in use"
# Windows
netstat -ano | findstr :5000
taskkill /PID <PID> /F
# Then restart the server# Frontend
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
# Backend
npm run dev # Start with nodemon (auto-reload)
npm start # Start normally
npm run db:setup # Create database and schema
npm run db:seed # Seed with sample data# Connect to database
psql -U postgres -d evflow
# View all tables
\dt
# View table structure
\d users
\d charging_stations
# Query examples
SELECT COUNT(*) FROM charging_stations;
SELECT * FROM ev_models;
# Exit
\qUse tools like Postman, Insomnia, or curl:
# Health check
curl http://localhost:5000/health
# Get nearby stations
curl "http://localhost:5000/api/stations/nearby?latitude=37.7749&longitude=-122.4194&radius=10"
# Register user
curl -X POST http://localhost:5000/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"name": "Test User",
"email": "test@example.com",
"password": "password123"
}'- Customize Your Profile: Add your EV model in the profile section
- Explore Stations: Browse nearby charging stations on the map
- Track Battery: Update your battery level for smart recommendations
- Log Sessions: Start tracking your charging history
- Get Insights: View your charging patterns and preferences
For production deployment, you'll need to:
- Set up a production PostgreSQL database (AWS RDS, Heroku Postgres, etc.)
- Deploy backend to a service like Heroku, Railway, or AWS
- Deploy frontend to Vercel, Netlify, or similar
- Update environment variables for production URLs
- Set up proper CORS and security headers
- Enable HTTPS
- Set up monitoring and logging
- Configure rate limiting
- Set up automated backups
Need help? Check the README.md for more detailed documentation!