Overview
This guide walks you through setting up Walle, an AVL (Automatic Vehicle Location) telemetry tracking API service built with NestJS. Walle uses PostgreSQL with table partitioning and PostGIS for geospatial data, along with MongoDB for additional data storage.System Requirements
Software Requirements
Software Requirements
- Node.js: v18 or higher
- npm: v9 or higher
- PostgreSQL: v14 or higher with PostGIS extension
- MongoDB: v6 or higher
- Operating System: Linux, macOS, or Windows with WSL2
Hardware Requirements
Hardware Requirements
- CPU: 2+ cores recommended
- RAM: 4GB minimum, 8GB recommended
- Storage: 20GB+ for database partitions
- Network: Stable connection for MongoDB Atlas (if using cloud)
PostgreSQL Setup
Install PostgreSQL
Enable PostGIS Extension
PostGIS is required for geospatial functionality (storing and querying GPS coordinates).Configure PostgreSQL Authentication
Editpg_hba.conf to allow password authentication:
MongoDB Setup
Install MongoDB
Create MongoDB Databases
Walle requires two MongoDB databases:Application Setup
Configure Environment Variables
Database Initialization
Walle automatically creates the partitioned table structure on first run. The parent table is defined insrc/app/database/constants/points.sql.ts:1.
Parent Table Structure
Thepoints table is partitioned by timestamp (BIGINT) using range partitioning:
Partition Creation
Partitions are created automatically byPartitionManagerService in src/app/points/partition-manager.service.ts:18:
- On startup: Creates partitions for today and tomorrow
- Daily schedule: Creates next day’s partition at 23:50
- Manual creation: Use the service methods for specific dates
Verification Steps
After setup, verify the installation using the provided verification script.Run Verification Script
Verify PostGIS
Test PostGIS functionality:Troubleshooting
PostgreSQL connection refused
PostgreSQL connection refused
Problem: Cannot connect to PostgreSQL databaseSolutions:
- Check if PostgreSQL is running:
sudo systemctl status postgresql - Verify connection settings in
.envfile - Check
pg_hba.confauthentication settings - Ensure the user has proper permissions:
PostGIS extension not found
PostGIS extension not found
Problem:
ERROR: could not open extension control fileSolutions:- Install PostGIS:
sudo apt install postgis postgresql-14-postgis-3 - Verify installation:
SELECT * FROM pg_available_extensions WHERE name = 'postgis'; - Ensure you’re connected to the correct database when creating extension
MongoDB connection timeout
MongoDB connection timeout
Problem: Cannot connect to MongoDBSolutions:
- Check if MongoDB is running:
sudo systemctl status mongod - Verify connection URI format in
.env - For MongoDB Atlas, check network access and IP whitelist
- Test connection:
mongosh <your-connection-string>
Partition creation fails
Partition creation fails
Problem: Error creating partitions on startupSolutions:
- Verify PostGIS extension is enabled
- Check that
POSTGRES_SYNCis set tofalsein.env - Ensure the user has CREATE TABLE permissions
- Manually create parent table if needed:
JWT authentication errors
JWT authentication errors
Problem:
401 Unauthorized errorsSolutions:- Verify
JWT_SECRETis set in.env - Ensure the secret matches between token generation and validation
- Check token expiration settings in
src/app/auth/auth.module.ts
Port already in use
Port already in use
Problem:
Error: listen EADDRINUSE: address already in use :::3700Solutions:- Change the
PORTin.envfile - Kill the process using the port:
Next Steps
Environment Configuration
Configure environment variables for different environments
Partition Management
Learn how to manage and monitor database partitions
API Reference
Explore the API endpoints and authentication
Points API
Start saving telemetry data points