$ npm installStart the backend and open http://localhost:3000/api/docs.
npm run cli create-user admin admin --roles admin,user
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:covThe project ships with a multi-stage Dockerfile and three Compose files:
| File | Purpose |
|---|---|
docker-compose.mongodb.yml |
Shared MongoDB instance (start this first when using the setup below) |
docker-compose.yml |
Production — app container, connects to shared MongoDB |
docker-compose.standalone.yml |
Production — self-contained, includes its own MongoDB |
docker-compose.dev.yml |
Development — dedicated MongoDB + backend hot-reload + Vite HMR |
Use docker-compose.yml + docker-compose.mongodb.yml when running multiple app instances that share one database. Use docker-compose.standalone.yml for a single self-contained deployment.
Create a .env file in the project root (never commit it) and add at minimum:
MONGO_PASSWORD=your-secure-passwordThen start MongoDB:
docker compose -f docker-compose.mongodb.yml up -dMongoDB is now reachable at localhost:27017 and on the diakem-network Docker network under the hostname mongodb.
No .env required — credentials are hardcoded for local use. Just run:
docker compose -f docker-compose.dev.yml up --build| Service | URL |
|---|---|
| Frontend (Vite HMR) | http://localhost:5173 |
| Backend (hot-reload) | http://localhost:3015 |
| MongoDB | localhost:27017 |
Editing files under backend/src/ or frontend/src/ triggers hot-reload automatically via bind mounts. node_modules stays inside the containers so native modules are compiled for the correct platform.
Create a .env file in the project root (never commit it):
MONGO_PASSWORD=your-secure-password
API_KEY=your-api-key
JWT_SECRET=your-jwt-secret
# Optional — defaults shown
JWT_EXPIRATION_IN_DAYS=2
APP_PORT=3015Then build and start:
docker compose up -d --buildTo create the first admin user:
docker compose exec app node dist/cli/main.js create-user admin admin --roles admin,userEach instance needs its own port, database name, and Compose project name (the -p flag namespaces container names so they don't collide). Create one .env file per instance:
.env.instance-a
INSTANCE_NAME=instance-a
MONGO_PASSWORD=your-secure-password
API_KEY=key-a
JWT_SECRET=secret-a
APP_PORT=3015.env.instance-b
INSTANCE_NAME=instance-b
MONGO_PASSWORD=your-secure-password
API_KEY=key-b
JWT_SECRET=secret-b
APP_PORT=3016Start each instance:
docker compose --env-file .env.instance-a up -d --build
docker compose --env-file .env.instance-b up -d --buildTo create the first admin user for a specific instance:
docker compose --env-file .env.instance-a exec app node dist/cli/main.js create-user admin admin --roles admin,userSame .env variables as production. No need to start MongoDB separately:
docker compose -f docker-compose.standalone.yml up -d --buildTo create the first admin user:
docker compose -f docker-compose.standalone.yml exec app node dist/cli/main.js create-user admin admin --roles admin,userThis guide explains how to obtain the credentials required for each service and add them to your .env file.
Copy .env.example to .env before you start:
cp .env.example .envNIGHTSCOUT_URL=https://your-nightscout-instance.example.com
NIGHTSCOUT_API_KEY=your_api_secret_here
- Open your Nightscout instance in a browser.
- Go to Admin Tools → note the URL in your address bar — this is your
NIGHTSCOUT_URL(e.g.https://mysite.fly.dev). - Your
NIGHTSCOUT_API_KEYis the API Secret you chose when setting up Nightscout.- You can find or change it under Admin Tools → Profile Editor or in your hosting provider's environment variables (
API_SECRET).
- You can find or change it under Admin Tools → Profile Editor or in your hosting provider's environment variables (
- Enter the plain-text value — the application hashes it automatically before sending it to the API.
npm run test:check-nightscout-apiPUSHOVER_APP_TOKEN=your_pushover_app_token_here
PUSHOVER_USER_KEY=your_pushover_user_key_here
- Log in at pushover.net.
- Your User Key is displayed on the dashboard under your name.
Copy it into
PUSHOVER_USER_KEY.
- Scroll down to Your Applications on the dashboard and click Create an Application/API Token.
- Fill in a name (e.g.
diakem-notify) and accept the terms. - Copy the generated API Token/Key into
PUSHOVER_APP_TOKEN.
Install the Pushover app on your Android device and log in with the same account. The app must be installed for notifications to be delivered.
npm run test:check-pushover-apiTELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
TELEGRAM_CHAT_ID=your_telegram_chat_id_here
- Open Telegram and search for @BotFather.
- Send
/newbotand follow the prompts to choose a name and username. - BotFather will reply with a token in the format
123456789:ABCdef.... Copy it intoTELEGRAM_BOT_TOKEN.
You need the numeric ID of the chat (private chat, group, or channel) where the bot should send messages.
For a private chat:
- Start a conversation with your bot by searching for its username and pressing Start.
- Send any message to the bot.
- Open the following URL in your browser (replace
<TOKEN>with your bot token):https://api.telegram.org/bot<TOKEN>/getUpdates - Find the
"chat"object in the response — the"id"field is yourTELEGRAM_CHAT_ID.
For a group or channel:
- Add the bot to the group or channel as an administrator.
- Send a message in the group/channel by mentioning the bot directly via
/test @<BOT_USERNAME>. - Call
getUpdatesas above and look for the"chat"."id"field. Group/channel IDs are negative numbers (e.g.-1001234567890).
npm run test:check-telegram-apiThe connection check sends a test message to the configured chat — you should see it arrive on your device.
The CLI is a simple command-line interface that allows you to run specific jobs. Usage:
npm run cli -- run:all npm run cli -- run pump-age
npm run cli:prod -- run:all npm run cli:prod -- run pump-age
The CliModule is intentionally separate from AppModule — it doesn't load the HTTP server, guards, or any web-related modules. It only boots what's needed to resolve job types and persist executions.
Check if the battery is low and send a notification:
Make threshold configurable: 51% Each 15 Minutes Below: 30% Each 5 Minutes Below: 15 Each 1 Minute
One time static at 20:00
Low insulin threshold: 80IE Each 5 hours Below: 50IE Each 1 hour Below: 25 Each 30 minutes
One time static at 20:00
Notify if pump is older than 4 days. All 5 hours. One time static at 20:00. Older than 4.5 days: All 2 hours. Older than 5 days: All 1 hour. Older than 6 days: All 30 minutes.
Older than 7 days: All 3 hours Older than 8 days: All 2 hours Older than 8.75 days: All 1 hour Older than 10 days:
Nest is MIT licensed.