Prerequisites
Before you begin, ensure you have the following installed:Node.js
Version 18.x or higher recommended
PostgreSQL
Version 12+ with PostGIS extension
MongoDB
Version 4.4+ for authentication and dispatch data
npm
Comes bundled with Node.js
Installation
Install dependencies
Install all required npm packages:This will install key dependencies including:
@nestjs/coreand@nestjs/common- NestJS framework@nestjs/typeormandtypeorm- PostgreSQL ORM@nestjs/mongooseandmongoose- MongoDB ODM@nestjs/jwtandpassport-jwt- Authentication@nestjs/schedule- Cron job schedulingpg- PostgreSQL driver
Configure environment variables
Create a
.env file in the project root with the following configuration:.env
The environment variable names are read from constants defined in
src/common/constants/database.constant.ts and src/common/constants/settings.contant.ts.Set up PostgreSQL database
Create the PostgreSQL database and enable PostGIS:
The partitioned
points table will be created automatically when you start the application. See src/main.ts:13 and src/app/database/constants/points.sql.ts for the table schema.Set up MongoDB databases
Ensure MongoDB is running and the required databases are accessible:The application will automatically create two MongoDB connections:
deltaDispatch- For dispatch-related dataauthSoftware- For user authentication
Initialize database partitions
The application automatically creates the partitioned parent table and initial partitions on startup:This creates:
- The partitioned parent table
pointswith RANGE partitioning ontimestamp - Today’s partition (e.g.,
points_20260303) - Tomorrow’s partition (e.g.,
points_20260304) - Indexes for timestamp, IMEI, trip ID, and geospatial location
A cron job automatically creates tomorrow’s partition every day at 23:50 to ensure uninterrupted data collection.
Running the Application
- Development Mode
- Production Mode
- Debug Mode
Start the application in development mode with auto-reload:This uses the NestJS CLI command
nest start --watch from package.json:12 to automatically restart the server when you make code changes.The application will start on http://localhost:3700 (or the port specified in your .env file).Verify Installation
Check the console output to confirm successful startup:Using the Service Layer
Walle provides a complete backend infrastructure with services, models, and partition management. The HTTP API layer (controllers with endpoints) is not yet implemented, but you can use the services directly in your NestJS application.Inject and use PointsService
The
PointsService provides access to the partitioned Point repository. Here’s how to use it in your own controller or service:The
PointsService is defined in src/app/points/points.service.ts and provides the TypeORM repository for the Point entity. You’ll need to add your own business logic methods.Work with the Point model
The Point entity includes 50+ fields for complete vehicle telemetry tracking (defined in
src/app/points/model/point.model.ts):Required fields:id- UUID (auto-generated)timestamp- Unix timestamp in milliseconds (bigint)trackerDeviceImei- Device IMEI numbertrackerDeviceLatitude- GPS latitudetrackerDeviceLongitude- GPS longitude
location- PostGIS Point geometry (SRID 4326)trackerDeviceSpeedKh- Speed in km/htrackerDeviceAngle- Direction angletrackerDeviceIgnition- Engine on/off statetrackerDeviceNumberOfSatellites- GNSS satellite count
Use authentication infrastructure
Walle includes JWT authentication infrastructure using
JwtStrategy and JwtAuthguard:The
@Auth() decorator (from src/common/decorators/auth.decorator.ts) applies the JwtAuthguard, which validates JWT tokens and populates the user via JwtStrategy.validate() from src/app/auth/strategies/jwt.strategy.ts.Understanding Partition Management
Walle uses time-series partitioning to efficiently manage high-volume GPS data:Automatic Daily Partitions
Partitions are automatically created using the naming patternpoints_YYYYMMDD:
Partition Indexes
Each partition includes optimized indexes defined insrc/app/points/partition-manager.service.ts:67-84:
idx_points_YYYYMMDD_timestamp- Time-range queriesidx_points_YYYYMMDD_imei_ts- Device-specific queriesidx_points_YYYYMMDD_imei_ts_trip- Trip tracking queriesidx_points_YYYYMMDD_location- Geospatial queries (GIST index)
Scheduled Partition Creation
A cron job runs daily at 23:50 to create tomorrow’s partition:Next Steps
Architecture
Learn about Walle’s multi-database architecture and design decisions
Point Data Model
Explore all 50+ fields available in the Point entity
Partition Management
Deep dive into partition creation, maintenance, and cleanup
Authentication
Understand JWT authentication and user management