Update readme's, branches and actions
Build and Push Docker Images / detect-changes (push) Successful in 9s
Build and Push Docker Images / build-auth-api (push) Successful in 1m5s
Build and Push Docker Images / build-employee-api (push) Successful in 1m1s
Build and Push Docker Images / build-transit-api (push) Successful in 57s
Build and Push Docker Images / build-error-log-api (push) Successful in 1m5s
Build and Push Docker Images / build-admin-ui (push) Successful in 1m16s
Build and Push Docker Images / build-monitoring-ui (push) Successful in 1m13s
Build and Push Docker Images / deploy-test-node (push) Successful in 5s

This commit is contained in:
Sven laptop
2026-09-21 00:15:05 +02:00
parent 635a130f0b
commit 217dfd3abc
161 changed files with 644 additions and 21618 deletions
+92 -87
View File
@@ -1,86 +1,89 @@
# Docker Setup voor Transit Project APIs
# Docker Setup for Transit Project APIs
Dit project bevat Docker-configuratie voor alle APIs, Admin Control Center en PostgreSQL database.
This project contains Docker configuration for all APIs, the Admin Control Center, the Monitoring UI, and external/local PostgreSQL databases.
## Bestanden
## Files
- **auth_api/Dockerfile** - Image voor Authentication API (port 5000)
- **employee_api/Dockerfile** - Image voor Employee API (port 4000)
- **transit_api/Dockerfile** - Image voor Transit API (port 5001)
- **admin_ui/Dockerfile** - Image voor Admin Control Center (port 5174)
- **docker-compose.yml** - Orchestratie van alle services
- **.dockerignore** - Bestanden die niet in Docker images opgenomen worden
- **.env.example** - Template voor environment variabelen
- **DEPLOYMENT.md** - Gedetailleerde deployment guide
- **auth_api/Dockerfile** - Image for Authentication API (port 5000)
- **employee_api/Dockerfile** - Image for Employee API (port 4000)
- **transit_api/Dockerfile** - Image for Transit API (port 5001)
- **admin_ui/Dockerfile** - Image for Admin Control Center (port 5174)
- **monitoring_ui/Dockerfile** - Image for Monitoring UI Dashboard (port 5175)
- **docker-compose.yml** - Orchestration for all services
- **.dockerignore** - Files excluded from Docker images
- **.env.example** - Template for environment variables
- **DEPLOYMENT.md** - Detailed deployment guide
- **scripts/deploy.sh** - Deployment helper script
- **scripts/build-and-push.sh** - Build en push script voor registry
- **scripts/build-and-push.sh** - Build and push script for container registry
## Vereisten
## Prerequisites
- Docker (>=20.10)
- Docker Compose (>=2.0)
## Installatie
## Installation & Setup
### 1. Environment variabelen configureren
### 1. Configure Environment Variables
```bash
cp .env.example .env
# Bewerk .env met je eigen waarden
# Edit .env with your specific configuration values
```
### 2. Services starten
### 2. Start Services
```bash
# Start alle services (APIs + Admin UI)
# Start all services (APIs + Admin UI + Monitoring UI)
docker-compose up -d
# Of build en start tegelijk (als je code hebt aangepast)
# Or build and start simultaneously (after code modifications)
docker-compose up -d --build
# Quick start met script
# Quick start using helper script
./scripts/deploy.sh start
```
### 3. Logs bekijken
### 3. View Logs
```bash
# Alle logs
# All service logs
docker-compose logs -f
# Logs van specifieke service
# Logs for a specific service
docker-compose logs -f auth_api
docker-compose logs -f transit_api
docker-compose logs -f admin_ui
# Via script
# Via helper script
./scripts/deploy.sh logs admin_ui
```
## Beschikbare Services
## Available Services
| Service | Port | Beschrijving |
|---------|------|--------------|
| Service | Port | Description |
|---------|------|-------------|
| admin_ui | 5174 | Admin Control Center (React + Nginx) |
| monitoring_ui | 5175 | Monitoring Dashboard & Docs Hub (React + Nginx) |
| auth_api | 5000 | Authentication endpoints |
| employee_api | 4000 | Employee management endpoints |
| transit_api | 5001 | Transit management endpoints |
| error_log_api | 5003 | Centralized error logging API |
## Commando's
## Commands
### Services beheren (Quick way)
### Manage Services (Quick Way)
```bash
# Via helper script
./scripts/deploy.sh start # Start alle services
./scripts/deploy.sh stop # Stop alle services
./scripts/deploy.sh restart # Herstart alle services
# Using helper script
./scripts/deploy.sh start # Start all services
./scripts/deploy.sh stop # Stop all services
./scripts/deploy.sh restart # Restart all services
./scripts/deploy.sh status # Show status
./scripts/deploy.sh logs # Bekijk logs admin_ui
./scripts/deploy.sh logs transit_api # Bekijk logs specifieke service
./scripts/deploy.sh logs # View admin_ui logs
./scripts/deploy.sh logs transit_api # View specific service logs
```
### Services beheren (Docker compose)
### Manage Services (Docker Compose)
```bash
# Start services
@@ -89,152 +92,154 @@ docker-compose up -d
# Stop services
docker-compose down
# Herstart services
# Restart services
docker-compose restart
# Verwijder containers en volumes
# Remove containers and volumes
docker-compose down -v
```
### Individuele services
### Individual Services
```bash
# Herstart specifieke service
# Restart a specific service
docker-compose restart auth_api
docker-compose restart admin_ui
# Build specifieke image
# Build a specific image
docker-compose build auth_api
# Logs van specifieke service
# Tail logs of a specific service
docker-compose logs -f transit_api
```
### Admin UI
```bash
# Bekijk Admin UI
# Access Admin UI in browser
http://localhost:5174
# Logs
# View logs
docker-compose logs -f admin_ui
# Shell in container
# Interactive shell in container
docker-compose exec admin_ui sh
```
## Troubleshooting
### Port al in gebruik
### Port Already in Use
```bash
# Check welke container de port gebruikt
# Check which process or container is using the port
docker ps
# or
lsof -i :5000
# Verander port in docker-compose.yml (e.g., "5000:5000" naar "5010:5000")
# Modify the host port in docker-compose.yml (e.g. change "5000:5000" to "5010:5000")
```
### Database connectie fout
### Database Connection Error
```bash
# Check database status
# Check database container status (if running local db)
docker-compose logs db
# Herstart database
# Restart database
docker-compose restart db
```
### API start probleem
### API Startup Issue
```bash
# Check logs
# Check service logs
docker-compose logs auth_api
# Controleer environment variabelen in .env
# Controleer database connection string
# Verify environment variables in .env
# Verify database connection string and network reachability
```
### Admin UI niet bereikbaar
### Admin UI Not Reachable
```bash
# Check Admin UI container
# Check Admin UI container status
docker-compose logs admin_ui
# Zorg ervoor dat poort 5174 niet in gebruik is
# Ensure port 5174 is not bound by another process
lsof -i :5174
```
## Admin Control Center
De Admin UI is een modern React + Vite applicatie die alle admin functies biedt.
The Admin UI is a modern React + Vite application that provides administrative management tools.
### Features
- **Authenticatie**: JWT-based login met dev token helper
- **Stops Management**: Create en beheer transit stops met geo-coördinaten
- **Bus Lines**: Define bus routes met start/end stops en reistijd
- **Authentication**: JWT-based login with dev token helper
- **Stop Management**: Create and manage transit stops with geo-coordinates
- **Bus Lines**: Define bus routes with start/end stops and travel duration
- **Fleet Management**: Monitor fleet vehicles
- **Stop Linking**: Assign stops aan bus lines met volgorde en ETA
- **Stop Linking**: Assign stops to bus lines with sequence ordering and ETA
### Toegang
### Access
```
URL: http://localhost:5174
```
### Deployment Configuratie
### Deployment Configuration
Environment variabelen in docker-compose.yml:
- `VITE_AUTH_API`: URL naar auth_api (standaard: http://auth_api:5000)
- `VITE_TRANSIT_API`: URL naar transit_api (standaard: http://transit_api:5001)
Environment variables in `docker-compose.yml`:
- `VITE_AUTH_API`: URL to auth_api (default: http://auth_api:5000)
- `VITE_TRANSIT_API`: URL to transit_api (default: http://transit_api:5001)
Voor externe toegang, update de URLs naar je deployment domain.
For external access, update URLs to your deployment domain.
### Build en Deployment
### Build and Deployment
```bash
# Build Admin UI image
docker-compose build admin_ui
# Push naar registry
# Push to container registry
./scripts/build-and-push.sh ghcr.io/your-org/xtransit latest
# Deploy met updated image
# Deploy with updated image
docker-compose up -d
```
## Development
### Wijzigingen doorgevoerd in code
### Applying Code Changes
```bash
# Rebuild container
docker-compose build auth_api
# Herstart service
# Restart service
docker-compose restart auth_api
```
### Code reloading (hot reload)
### Code Hot-Reloading
Voor hot reload kunt u volumes toevoegen aan docker-compose.yml:
For live reloading during development, you can mount source directories as volumes in `docker-compose.yml`:
```yaml
volumes:
- ./auth_api:/app
```
Dit kan performance beïnvloeden. Alleen gebruiken tijdens development.
Note: This may impact performance on some host platforms. Use during local development only.
## Productie Tips
## Production Tips
1. **Veiligheid**: Wijzig alle wachtwoorden en JWT_SECRET in .env
2. **Database**: Gebruik een managed database service in productie
3. **Logging**: Configureer centralized logging (ELK stack, Splunk, etc.)
4. **Backups**: Stel automatische backups in voor de database
5. **Health Checks**: Monitoreer de health endpoints van de APIs
6. **SSL/TLS**: Gebruik reverse proxy (nginx) voor HTTPS
1. **Security**: Change all default passwords and `JWT_SECRET` in `.env`.
2. **Database**: Use a managed database service or secured host in production.
3. **Logging**: Configure centralized logging via `error_log_api` or log aggregators.
4. **Backups**: Configure automated backup procedures for PostgreSQL.
5. **Health Checks**: Monitor the `/health` endpoints of all deployed APIs.
6. **SSL/TLS**: Use a reverse proxy (Nginx, Traefik) to provide HTTPS.
## Netwerking
## Networking
De services kunnen elkaar bereiken via:
Services communicate internally via:
- auth_api: `http://auth_api:5000`
- employee_api: `http://employee_api:4000`
- transit_api: `http://transit_api:5001`
- database: `db:5432`
- database: `db:5432` or external host
+29 -21
View File
@@ -1,39 +1,47 @@
# Transit Project
# Transit Project Overview
XTransit is a service-oriented transit platform consisting of Node.js APIs, React operator interfaces, and retained legacy clients.
This document provides the root overview for the Transit Project platform, maintained within the documentation hub.
## Quick Map
For the primary repository landing page, see the root [`../../README.md`](../../README.md).
For the complete documentation index, see [`README.md`](README.md).
- `auth_api/` - authentication and JWT issuance
- `employee_api/` - employee management
- `transit_api/` - schedules, routes, fleet, GPS, and transit administration
- `error_log_api/` - centralized error collection and protected log access
- `admin_ui/` - React administration console
- `monitoring_ui/` - React service monitoring dashboard
- `deprecated/` and `windows_xp_driver_ui/` - retained legacy clients
## System Architecture
Public employee API: `https://employees.xtransit.testinstance.nl`
XTransit is a service-oriented transit platform consisting of Node.js microservices, React operator interfaces, and retained legacy clients:
## Documentation
- `auth_api/` — Authentication, JWT token issuance, and admin role verification (port 5000)
- `employee_api/` — Employee management and onboarding (port 4000)
- `transit_api/` — Schedules, routes, fleet, GPS tracking, and transit administration (port 5001)
- `error_log_api/` — Centralized error collection and protected log access (port 5003)
- `admin_ui/` — React administration console (port 5174)
- `monitoring_ui/` — React service monitoring dashboard and documentation hub (port 5175 / dev 5173)
- `windows_xp_driver_ui/` — Native Win32 driver client targeting Windows XP-era systems
- `deprecated/` — Legacy Flutter bus terminal retained for reference
Start with the [documentation hub](docs/README.md).
Public employee API: `https://employees.xtransit.testinstance.nl`
Public admin panel: `https://admin.xtransit.testinstance.nl`
Public error logging: `https://error.xtransit.testinstance.nl`
Public transit API: `https://transit.xtransit.testinstance.nl`
- [Project guide](docs/PROJECT_GUIDE.md) - setup, architecture, environment, Docker, deployment, databases, and troubleshooting
- [Monitoring UI guide](docs/MONITORING_UI.md) - complete `monitoring_ui` operations and development manual
- [Domains](DOMAINS_README.md) - public domain and service mapping
- [Docker notes](DOCKER_README.md) - container workflow
- [Deployment guide](DEPLOYMENT.md) - deployment procedures
- [CI/CD and Portainer guide](CI_CD_PORTAINER_GUIDE.md) - image and stack operations
## Core Documentation
- [Project Guide](PROJECT_GUIDE.md) — Setup, architecture, environment variables, Docker, deployment, databases, and troubleshooting
- [Monitoring UI Guide](MONITORING_UI.md) — Complete `monitoring_ui` operations and development manual
- [Domains Overview](DOMAINS_README.md) — Public domain and service mapping
- [Docker Notes](DOCKER_README.md) — Container workflow and compose configurations
- [Deployment Guide](DEPLOYMENT.md) — Production deployment procedures
- [CI/CD & Portainer Guide](CI_CD_PORTAINER_GUIDE.md) — Image builds, registry, and stack operations
- [Security & Private Files](SECURITY_PRIVATE_FILES.md) — Security practices & credential safety rules
## Quick Start
For the deployed service stack:
Run the complete service stack using Docker Compose:
```bash
docker compose --env-file .env up -d
```
For the monitoring dashboard:
Run the monitoring dashboard locally:
```bash
cd monitoring_ui
+1 -1
View File
@@ -18,7 +18,7 @@ The active UI uses these transit API endpoints:
Production admin panel: `https://admin.xtransit.testinstance.nl`
For the separate service monitoring dashboard, see
[`../docs/MONITORING_UI.md`](../docs/MONITORING_UI.md). The monitoring dashboard
[`../MONITORING_UI.md`](../MONITORING_UI.md). The monitoring dashboard
is deployed independently on host port `5175` and checks this admin UI through
`GET /health`.
+2 -2
View File
@@ -4,8 +4,8 @@ This Flutter application is retained as a legacy reference implementation while
It is not part of the current monitoring or deployment path. Current service
and dashboard documentation is maintained in
[`../docs/PROJECT_GUIDE.md`](../docs/PROJECT_GUIDE.md) and
[`../docs/MONITORING_UI.md`](../docs/MONITORING_UI.md).
[`../PROJECT_GUIDE.md`](../PROJECT_GUIDE.md) and
[`../MONITORING_UI.md`](../MONITORING_UI.md).
## Status
+36 -36
View File
@@ -1,41 +1,41 @@
# Transit API
Transit API voor het beheren van busroutes, navigatie en GPS tracking voor busbestuurders.
Transit API for managing bus routes, navigation, and GPS tracking for bus drivers.
## Project Structuur
## Project Structure
```
transit_api/
├── index.js # Main API endpoints
├── middleware.js # JWT authentication middleware
├── db.js # PostgreSQL connection
├── schema.sql # Database schema setup
├── package.json # Dependencies
└── .env # Environment variables
├── db.js # PostgreSQL connection
├── schema.sql # Database schema setup
├── package.json # Dependencies
└── .env # Environment variables
```
## Setup
### 1. Dependencies installeren
### 1. Install Dependencies
```bash
npm install
```
### 2. Database Schema opzetten
### 2. Set Up Database Schema
Voer het volgende uit in PostgreSQL:
Execute the following in PostgreSQL:
```bash
# Via psql command line
psql -U your_user -d your_database -f schema.sql
```
Of kopieer-plak de SQL queries rechtstreeks in pgAdmin.
Or copy-paste the SQL queries directly into pgAdmin.
### 3. Environment variabelen (.env)
### 3. Environment Variables (.env)
```
```env
PG_HOST=localhost
PG_PORT=5432
PG_USER=your_user
@@ -47,28 +47,28 @@ PORT=5001
Note: `ADMIN_USER_CODES` has been moved to the `auth_api` service. Configure admin user codes in `auth_api/.env` as a comma-separated list.
### 4. API starten
### 4. Start API
```bash
npm start
```
API draait op `https://transit.xtransit.testinstance.nl`
The API runs at `https://transit.xtransit.testinstance.nl`
The service group also includes the Employee API at
`https://employees.xtransit.testinstance.nl` and the central monitoring
dashboard. See [`../docs/MONITORING_UI.md`](../docs/MONITORING_UI.md) for health
dashboard. See [`../MONITORING_UI.md`](../MONITORING_UI.md) for health
checks, error inspection, and the controlled request tester.
## API Endpoints
Alle endpoints vereisen een `Authorization: Bearer {token}` header.
All endpoints require an `Authorization: Bearer {token}` header.
**GET** `/health`
- Controleert of de gedeployde transit API draait en de database bereikbaar is.
- Geeft `200` met `{"status":"ok","database":"ok"}` bij succes.
- Geeft `503` als de API wel draait maar de database niet bereikbaar is.
- Checks whether the deployed transit API is running and the database is reachable.
- Returns `200` with `{"status":"ok","database":"ok"}` on success.
- Returns `503` if the API is running but the database is unreachable.
### Schedule
@@ -119,7 +119,7 @@ clients, but new clients must use the weekly schedule endpoints above.
**GET** `/schedule/daily?date=2024-05-05`
- Ophalen van dagplanning voor chauffeur
- Retrieve daily schedule for driver
- Response:
```json
@@ -147,22 +147,22 @@ clients, but new clients must use the weekly schedule endpoints above.
**GET** `/routes/:routeId`
- Details van een specifieke route
- Details of a specific route
- Response: `{ "route": {...} }`
### Public Schedule Overview
**GET** `/schedules/overview?date=2026-05-06&lineId=1`
- Haalt een datum-gebonden overzicht op van geplande diensten
- Fetches a date-based overview of scheduled services
- Weekly templates are selected by `day_of_week` and driver assignments by `shifts`
- Incidentele diensten worden alleen meegenomen op hun exacte datum
- One-off / incidental services are only included on their exact date
- Filters: `driverId`/`chauffeurId`, `stopId`/`busStopId`, `lineId`, `status`
- Response: `{ "date": "2026-05-06", "summary": {...}, "schedules": [...] }`
De legacy endpoint **GET** `/schedules` blijft beschikbaar voor bestaande clients.
The legacy endpoint **GET** `/schedules` remains available for existing clients.
Voorbeeld:
Example:
```bash
curl "https://transit.xtransit.testinstance.nl/schedules/overview?date=2026-05-06&chauffeurId=12&busStopId=3"
@@ -172,7 +172,7 @@ curl "https://transit.xtransit.testinstance.nl/schedules/overview?date=2026-05-0
**POST** `/navigation/route`
- Opslaan van berekende route van OSRM
- Save calculated route from OSRM
- Body:
```json
@@ -193,7 +193,7 @@ curl "https://transit.xtransit.testinstance.nl/schedules/overview?date=2026-05-0
**GET** `/bus-lines/:busLineId/stops`
- Alle stops van een buslijn (voor navigatie waypoints)
- All stops of a bus line (for navigation waypoints)
- Response:
```json
@@ -214,7 +214,7 @@ curl "https://transit.xtransit.testinstance.nl/schedules/overview?date=2026-05-0
**POST** `/gps/track`
- Real-time positie opslaan
- Save real-time position
- Body:
```json
@@ -230,7 +230,7 @@ curl "https://transit.xtransit.testinstance.nl/schedules/overview?date=2026-05-0
**GET** `/gps/route/:routeId`
- Alle opgeslagen positie punten van een route
- All recorded position points of a route
- Response:
```json
@@ -258,11 +258,11 @@ curl "https://transit.xtransit.testinstance.nl/schedules/overview?date=2026-05-0
### Admin
Alle admin-endpoints vereisen naast een geldig JWT-token ook dat je `userCode` voorkomt in `ADMIN_USER_CODES`.
All admin endpoints require, in addition to a valid JWT token, that your `userCode` is present in `ADMIN_USER_CODES`.
**POST** `/admin/stops`
- Maak een herbruikbare stop aan
- Create a reusable stop
- Body:
```json
@@ -275,7 +275,7 @@ Alle admin-endpoints vereisen naast een geldig JWT-token ook dat je `userCode` v
**POST** `/admin/bus-lines/:busLineId/stops`
- Koppel een bestaande stop aan een buslijn
- Link an existing stop to a bus line
- Body:
```json
@@ -320,7 +320,7 @@ Alle admin-endpoints vereisen naast een geldig JWT-token ook dat je `userCode` v
### routes
- `id` - Primary key
- `user_id` - Chauffeur (references workers.users)
- `user_id` - Driver (references workers.users)
- `bus_line_id` - Which line (references bus_lines)
- `bus_type_id` - Which bus (references bus_types)
- `start_time` - Scheduled start
@@ -330,7 +330,7 @@ Alle admin-endpoints vereisen naast een geldig JWT-token ook dat je `userCode` v
- `id` - Primary key
- `route_id` - Link to route (unique)
- `polyline_geojson` - GeoJSON LineString van de route
- `polyline_geojson` - GeoJSON LineString of the route
- `total_distance_meters` - Route distance
- `total_duration_seconds` - Estimated duration
@@ -342,7 +342,7 @@ Alle admin-endpoints vereisen naast een geldig JWT-token ook dat je `userCode` v
- `speed_kmh` - Current speed
- `recorded_at` - Timestamp
## Integration met Flutter App
## Integration with Flutter App
```dart
// In schedule_service.dart
@@ -367,7 +367,7 @@ await scheduleService.updateRouteStatus(1, 'in_progress');
## Error Handling
Alle endpoints retourneren error responses:
All endpoints return error responses:
```json
{
@@ -3,9 +3,9 @@
Native Win32 driver client targeting Windows XP-era systems.
Project-wide setup and service documentation is maintained in
[`../docs/PROJECT_GUIDE.md`](../docs/PROJECT_GUIDE.md). The operational
[`../PROJECT_GUIDE.md`](../PROJECT_GUIDE.md). The operational
monitoring dashboard is documented in
[`../docs/MONITORING_UI.md`](../docs/MONITORING_UI.md).
[`../MONITORING_UI.md`](../MONITORING_UI.md).
For Windows XP compatibility, the client temporarily uses the LAN services: