No description
  • PHP 91.6%
  • Blade 7.8%
  • Dockerfile 0.3%
  • Shell 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Shukry Shahril d437573f10 test(ppa): skip legacy-data tests when V1 schema not provisioned
Verify/Migration tests that read the V1 legacy schema (legacy.assets/daks on pgsql-pgsn) hard-failed because that data is imported from V1, not created by any migration/seeder — so it is absent in CI/local. Add a $requiresLegacyData guard in TestCase that markTestSkipped's them (via a to_regclass check) instead of failing. Team to provision legacy data in the CI test DB to re-enable.
2026-08-28 08:23:42 +08:00
app feat(zone): make org dropdowns zone/berkait-aware 2026-08-28 06:25:15 +08:00
bootstrap feat: add HandleImpersonation middleware for cross-service impersonation 2026-05-09 01:36:41 +08:00
config chore(ppa): carry over in-flight migration work from the last 48 hours 2026-08-16 11:43:19 +08:00
database fix(migration): import RoadDesignation in ImportLegacyDaksSeeder 2026-08-28 08:23:33 +08:00
docker Update entrypoint.sh 2026-06-10 15:48:11 +08:00
k8s fix(ppa): switch training queue to database driver 2026-08-26 11:05:32 +08:00
public update dropdown 2026-01-02 17:02:13 +08:00
resources Merge branch 'feature/aset-jalan-3' into master-taufiq 2026-08-25 11:51:34 +08:00
routes feat(komponen-config): add admin CRUD endpoints on PPA 2026-08-27 15:47:33 +08:00
storage Migration fix and remove csv 2026-04-09 07:55:44 +00:00
tests test(ppa): skip legacy-data tests when V1 schema not provisioned 2026-08-28 08:23:42 +08:00
.dockerignore Add .dockerignore and guard bootstrap cache 2026-06-13 23:23:13 +08:00
.editorconfig init 2025-11-25 21:12:45 +08:00
.env.example Add modul field; remove internal_api secret 2026-05-28 01:33:16 +08:00
.env.testing fix(ppa): align CI test DB to harness so pgsql host resolves 2026-07-05 23:40:12 +08:00
.gitattributes init 2025-11-25 21:12:45 +08:00
.gitignore chore(ppa): point legacy-schema errors at the renamed reimport seeder 2026-08-16 16:34:20 +08:00
.gitlab-ci.yml Merge branch 'master' into kkr-sync 2026-08-19 01:05:41 +08:00
artisan init 2025-11-25 21:12:45 +08:00
composer.json chore(komponen-xlsx): declare phpspreadsheet as a direct dependency 2026-08-26 14:11:28 +08:00
composer.lock chore(komponen-xlsx): declare phpspreadsheet as a direct dependency 2026-08-26 14:11:28 +08:00
docker-compose.yml update nanti kena check 2025-12-16 10:11:06 +08:00
Dockerfile ci: retry composer source install on rate-limit blips 2026-08-18 00:14:24 +08:00
Dockerfile.ci fix(migration) let backup working 2026-07-08 16:32:50 +08:00
Dockerfile.local fix : docker for local development issue 2025-12-09 15:29:32 +08:00
generate_migration_report.php old migration data update 2026-01-28 04:57:06 +00:00
Makefile init 2025-11-25 21:12:45 +08:00
myinfra_ppa initial refactor 2025-11-30 21:59:51 +08:00
package.json init 2025-11-25 21:12:45 +08:00
phpunit.xml test(ci): run PPA tests on Postgres instead of sqlite 2026-06-25 21:50:08 +08:00
README.md Update README.md 2026-06-29 06:39:13 +00:00
vite.config.js init 2025-11-25 21:12:45 +08:00

MyInfra PPA (Asset Management Service)

Microservice for asset management, split from the main myinfra-backend.

Architecture Overview

┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│                 │     │                 │     │                 │
│  myinfra-       │     │  myinfra-       │     │  myinfra-ppa    │
│  frontend       │────▶│  backend        │     │  (this service) │
│  (Nuxt 3)       │     │  (Laravel)      │     │  (Laravel)      │
│                 │     │                 │     │                 │
│  Port: 3000     │     │  Port: 8000     │     │  Port: 8001     │
└─────────────────┘     └─────────────────┘     └─────────────────┘
        │                       │                       │
        │                       │                       │
        │               ┌───────┴───────┐               │
        │               │               │               │
        │               ▼               ▼               │
        │       ┌───────────────────────────┐           │
        │       │      PostgreSQL           │           │
        │       │  ┌─────────┬───────────┐  │           │
        │       │  │myinfra_db│myinfra_ppa│ │◀──────────┘
        │       │  │ (core)  │ (assets)  │  │
        │       │  └─────────┴───────────┘  │
        │       └───────────────────────────┘
        │                       │
        │                       ▼
        │               ┌───────────────┐
        └──────────────▶│   Keycloak    │
                        │   Port: 8080  │
                        └───────────────┘

Service Responsibilities

myinfra-backend (Core)

  • User authentication/authorization
  • User management
  • Roles and permissions (Spatie)
  • Organizations hierarchy
  • Pegawai (staff) profiles
  • Shared reference data (Negeri, Daerah, Bandar, etc.)

myinfra-ppa (This Service)

  • Asset (Aset) management - buildings and roads
  • SubDPA management
  • DAK (Daftar Aset Khusus)
  • PTRA (Asset reception plans)
  • Asset-related reports and statistics

Database Configuration

This service uses dual database connections:

Connection Database Purpose
pgsql (default) myinfra_ppa Asset tables (Aset, SubDpa, Dak, etc.)
core myinfra_db Users, roles, permissions, organizations

Models that connect to core database have protected $connection = 'core';

Authentication

Uses Keycloak JWT authentication via custom guard. The flow:

  1. Frontend authenticates with Keycloak via myinfra-backend
  2. JWT token stored in HTTP-only cookie
  3. This service validates JWT using Keycloak's JWKS endpoint
  4. User lookup happens against core database using preferred_username

Getting Started

Prerequisites

  • myinfra-backend must be running (provides PostgreSQL, Redis, Keycloak)
  • Docker and Docker Compose

Setup

  1. Copy environment file:
cp .env.example .env
  1. Generate app key:
php artisan key:generate
  1. Start the service:
make up
  1. Run migrations (if needed):
make artisan cmd="migrate"

Available Commands

make up              # Start containers
make down            # Stop containers
make restart         # Rebuild and restart
make bash            # Shell into container
make artisan cmd="..." # Run artisan commands
make logs            # View logs

API Endpoints

All endpoints require authentication.

Variable Used By Format (no /api)
STAGING_PGSN_API_URL PPA, OPA, PPUN http://myinfra-pgsn.url
STAGING_PPA_API_URL OPA, PPUN http://myinfra-ppa.url
BACKEND_PGSN_API_URL Frontend (SSR) http://myinfra-pgsn.url
BACKEND_PPA_API_URL Frontend (SSR) http://myinfra-ppa.url
BACKEND_OPA_API_URL Frontend (SSR) http://myinfra-opa.url
BACKEND_PPUN_API_URL Frontend (SSR) http://myinfra-ppun.url

Assets

Method Endpoint Description
GET /api/aset List assets
POST /api/aset Create asset
GET /api/aset/{id} Get asset
PUT /api/aset/{id} Update asset
DELETE /api/aset/{id} Delete asset
GET /api/aset/statistik Asset statistics
POST /api/aset/dropdown-data Get dropdown options
GET /api/aset/{id}/subdpas Get asset's sub-DPAs

Health Check

Method Endpoint Description
GET /api/health Service health status

Frontend Integration

The frontend calls this service via proxy:

Browser -> /api-ppa/* -> Nuxt Server -> http://localhost:8001/api/*

Environment variables:

NUXT_API_PPA_URL_SERVER=http://localhost:8001/api
NUXT_PUBLIC_API_PPA_URL=/api-ppa

Docker Network

This service connects to the existing myinfra-backend network:

networks:
  myinfra-network:
    external: true
    name: myinfra-backend_myinfra-network

This allows access to shared services (PostgreSQL, Redis, Keycloak) running in myinfra-backend.

File Structure

myinfra-ppa/
├── app/
│   ├── Guards/
│   │   └── KeycloakGuard.php      # JWT validation
│   ├── Helpers/
│   │   └── helpers.php            # getCurrentUser(), etc.
│   ├── Http/
│   │   ├── Controllers/Api/
│   │   │   └── AsetController.php
│   │   └── Middleware/
│   │       ├── Authenticate.php
│   │       └── InjectTokenFromCookie.php
│   ├── Models/
│   │   ├── Aset.php               # Main asset model
│   │   ├── User.php               # Uses 'core' connection
│   │   └── ...
│   └── Providers/
│       └── AuthServiceProvider.php
├── config/
│   ├── auth.php                   # Keycloak guard config
│   ├── cors.php                   # CORS settings
│   └── database.php               # Dual DB connections
├── routes/
│   └── api.php                    # API routes
├── docker-compose.yml
├── Dockerfile
└── Makefile

Troubleshooting

Cannot connect to database

Ensure myinfra-backend containers are running and the network exists:

docker network ls | grep myinfra

Authentication failing

  1. Check Keycloak is accessible at configured URL
  2. Verify KEYCLOAK_REALM and KEYCLOAK_CLIENT_ID match
  3. Check cookie is being forwarded (credentials: true)

CORS errors

Ensure APP_FRONTEND_URL in .env matches the frontend origin.

...