Skip to main content

πŸš€ CivicTwin AI Getting Started Guide

"From theory to practice β€” Deploy CivicTwin AI today"


πŸ“‹ System Requirements​

Prerequisites​

  • Node.js: v16+
  • npm or yarn: v7+
  • PostgreSQL: v12+
  • PostGIS: v3.0+ (PostgreSQL extension)
  • Docker (optional, but recommended)

Environment​

  • OS: Linux, macOS, or Windows (WSL2)
  • RAM: Minimum 8GB
  • Disk: 20GB (for data and models)

πŸ”§ Quick Setup (5 minutes)​

Step 1: Clone Repository​

git clone https://github.com/asean-ai/civic-twin.git
cd civic-twin

Step 2: Install Dependencies​

npm install
# or
yarn install

Step 3: Configure Environment​

Create a .env file in the root directory:

# Database
DATABASE_URL=postgresql://user:password@localhost:5432/civic_twin
POSTGIS_ENABLED=true

# AI Core
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=your_key
AWS_SECRET_ACCESS_KEY=your_secret

# API
PORT=3000
NODE_ENV=development

# Maps
MAPBOX_TOKEN=your_mapbox_token

Step 4: Initialize Database​

npm run migrate
npm run seed # (if sample data is needed)

Step 5: Run the Application​

npm start

The application will run at http://localhost:3000


Step 1: Build Docker Image​

docker-compose build

Step 2: Start Containers​

docker-compose up -d

Step 3: Check Status​

docker-compose ps

All services will be running:


πŸ“Š Project Structure​

civic-twin/
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ services/ # Microservices
β”‚ β”‚ β”œβ”€β”€ DigitalTwin/ # Digital Twin engine
β”‚ β”‚ β”œβ”€β”€ Prediction/ # AI prediction
β”‚ β”‚ β”œβ”€β”€ Simulation/ # What-If scenario
β”‚ β”‚ └── Dashboard/ # Decision support
β”‚ β”œβ”€β”€ pages/ # Frontend pages
β”‚ β”œβ”€β”€ css/ # Styling
β”‚ └── api/ # API routes
β”œβ”€β”€ docs/ # Documentation
β”œβ”€β”€ docker-compose.yml # Docker configuration
β”œβ”€β”€ package.json
└── README.md

βœ… Verify Installation​

1. Check API​

curl http://localhost:3000/api/health
# Result: {"status": "ok", "timestamp": "2026-03-31T..."}

2. Access Frontend​

Open browser: http://localhost:5173

3. Create a Test Project​

  1. Log in with demo account
  2. Select "Create New Scenario"
  3. Draw a road on the map
  4. View prediction results

🚨 Troubleshooting​

Error: "Connection refused" (PostgreSQL)​

# Check if PostgreSQL is running
sudo service postgresql status

# Or if using Docker
docker-compose ps postgres

Error: "Port 3000 already in use"​

# Find process using port 3000
lsof -i :3000

# Or specify a different port
PORT=3001 npm start

Error: "AWS credentials not found"​

Check that the .env file contains AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Or configure AWS CLI:

aws configure

πŸ“š Next Steps​


πŸ’‘ Development Tips​

Hot Reload Frontend​

npm run dev  # Automatically reloads when code changes

Debug Backend​

DEBUG=* npm start  # View detailed logs

Reset Database​

npm run migrate:reset
npm run seed

πŸ†˜ Need Help?​


πŸ“„ License​

This project is distributed under the GNU General Public License v3.0. See the LICENSE file for details.


Β© 2025 CivicTwin AI – Developed with ❀️ by the ASEAN-AI-DZ Team