Skip to main content

Local Development

Step-by-step guide for running the full Ampra stack locally for development and testing.


Prerequisites

ToolVersionPurpose
Docker Desktop24.0+Container runtime for all dependencies
.NET SDK10.0Backend API development
Node.js20+Frontend UI development
npm10+Package management

Quick Start

The run.bat script at the repository root automates the entire local setup:

.\run.bat

This script performs three steps:

Step 1 — Lint Checks

Both backend and frontend are linted before starting:

[1/2] Backend (dotnet format) — verifies C# code style
[2/2] Frontend (eslint) — verifies TypeScript/React rules

If either check fails, startup is aborted. Fix lint errors before retrying.

Step 2 — Start Backend Dependencies

Seven Docker containers are started in sequence:

OrderContainerImagePortsVolume
1ampra-dbpostgres:16-alpine5432:5432ampra-db-data
2ampra-minioquay.io/minio/minio9000:9000, 9001:9001ampra-minio-data
3ampra-mongomongo:8.027017:27017ampra-mongo-data
4ampra-redisredis:7-alpine6379:6379ampra-redis-data
5ampra-emqxemqx/emqx:5.81883:1883, 18083:18083ampra-emqx-data
6ampra-mlampra-ml:latest5050:5050
7ampra-ingestionampra-ingestion:latest

After containers start, the ASP.NET Core API runs via dotnet run at http://localhost:5001.

Step 3 — Start UI

The React UI starts in a separate terminal via Vite dev server at http://localhost:5002.


Default Credentials (Local Dev Only)

ServiceUsernamePassword
PostgreSQLampraampra123
MongoDBampraampra123
MinIOampraampra123
RedisNo auth
EMQXadminchangeme

Local Service Endpoints

ServiceURLNotes
APIhttp://localhost:5001ASP.NET Core
UIhttp://localhost:5002Vite dev server (HMR enabled)
PostgreSQLlocalhost:5432Database: ampradb
MongoDBlocalhost:27017Database: ampradb
MinIO Consolehttp://localhost:9001Web management UI
MinIO APIhttp://localhost:9000S3-compatible API
EMQX Dashboardhttp://localhost:18083MQTT broker management
EMQX MQTTlocalhost:1883MQTT protocol
Redislocalhost:6379Cache / job store
ML Servicehttp://localhost:5050Python Flask API

Configuration Files

API (src/Ampra.Web/appsettings.json)

Pre-configured for local development with default credentials. Key sections:

{
"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Port=5432;Database=ampradb;...",
"MongoDb": "mongodb://ampra:ampra123@localhost:27017/ampradb?authSource=admin",
"Redis": "localhost:6379"
},
"MinIO": {
"Endpoint": "localhost:9000",
"UseSSL": false
},
"ML": {
"ServiceUrl": "http://localhost:5050"
},
"MqttBroker": {
"Host": "localhost",
"Port": 1883
}
}

MQTT Ingestion (src/Ampra.MQTT/appsettings.json)

{
"Mqtt": {
"BrokerHost": "localhost",
"BrokerPort": 1883,
"ClientId": "ampra-ingestion-worker",
"TopicFilter": "ampra/sources/+/data"
},
"Ingestion": {
"ThrottleSeconds": 10,
"DeduplicationWindowSeconds": 30,
"MaxPayloadBytes": 65536
}
}

EMQX Broker (src/Ampra.MQTT/emqx.conf)

Configured for local development with HTTP authentication callbacks pointing to host.docker.internal:5001. The broker delegates all auth/ACL decisions to the API.

Vite (src/Ampra.UI/vite.config.ts)

Dev server on port 5002 with path alias @src/, TanStack Router plugin, and Tailwind CSS v4.


Running Individual Components

Backend Only

cd src/Ampra.Web
dotnet run

Requires Docker containers for PostgreSQL, MongoDB, Redis, MinIO to be running.

Frontend Only

cd src/Ampra.UI
npm run dev

Requires the API to be running at http://localhost:5001.

ML Service Only

cd src/Ampra.ML
docker build -t ampra-ml:latest .
docker run -p 5050:5050 \
-e MONGO_URL=mongodb://ampra:ampra123@host.docker.internal:27017/ampradb?authSource=admin \
-e REDIS_URL=redis://host.docker.internal:6379/0 \
-e MINIO_ENDPOINT=host.docker.internal:9000 \
-e MINIO_ACCESS_KEY=ampra \
-e MINIO_SECRET_KEY=ampra123 \
ampra-ml:latest

Database Migrations

Entity Framework Core manages PostgreSQL schema migrations. Migrations are automatically applied on API startup.

# Create a new migration
cd src/Ampra.Web
dotnet ef migrations add MigrationName --project ../Ampra.Infrastructure

# Apply migrations manually
dotnet ef database update --project ../Ampra.Infrastructure