Avvio stack in localhost
Questa guida descrive il percorso canonico per eseguire l'intero stack locale del workspace cs-repository.
Il bootstrap parte sempre da platform-local-stack. I singoli repository possono essere avviati da soli solo per debug puntuale, non come entrypoint principale.
Nei comandi sotto, sostituisci <workspace-root> con la directory locale che contiene i repository sibling del workspace.
Prerequisiti
- Node.js
>= 22 - npm
>= 10 - Docker Desktop attivo
Verifica rapida:
bash
node -v
npm -v
docker infoSetup una tantum
Installa le dipendenze in tutti i repository eseguibili del workspace:
bash
cd <workspace-root>/platform-auth-service && npm install
cd <workspace-root>/platform-ai-service && npm install
cd <workspace-root>/platform-connectors-service && npm install
cd <workspace-root>/platform-mcp-service && npm install
cd <workspace-root>/platform-agent-service && npm install
cd <workspace-root>/platform-local-stack && npm install
cd <workspace-root>/platform-status-service && npm install
cd <workspace-root>/platform-wiki && npm install
cd <workspace-root>/cs-portal && npm install
cd <workspace-root>/cs-chat && npm install
cd <workspace-root>/cs-transacion-manage && npm install
cd <workspace-root>/sfdc-external && npm install
cd <workspace-root>/funnel-ia-engine && npm installPreparazione environment
funnel-ia-engine
Prepara i file .env del repo e dei workspace:
bash
cd <workspace-root>/funnel-ia-engine
cp .env.example .env
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.envNote operative:
- in
frontend/.envlasciaVITE_API_BASE_URLvuota per usare lo stesso origin browser con prefisso/api - in
backend/.envPLATFORM_AI_SERVICE_URLpunta di default ahttp://localhost:3300 - il backend Funnel bootstrapa di default le credenziali locali
admin@local.test/ChangeMe123!dentroplatform-auth-service
platform-ai-service
Prepara il file .env del servizio:
bash
cd <workspace-root>/platform-ai-service
cp .env.example .envValori locali gia allineati nel template:
PORT=3300PLATFORM_INTERNAL_TOKEN=platform-local-stack-internal-tokenAI_DATABASE_URL
La configurazione dei provider AI viene letta dallo state store PostgreSQL. Per test locali senza provider esterni usa il provider template tramite le route admin/backoffice o un seed gia presente nel database locale.
platform-mcp-service
Per il bootstrap canonico via platform-local-stack non serve copiare env manualmente. Se lo avvii standalone, allinea almeno:
PORT=3500PLATFORM_INTERNAL_TOKEN=platform-local-stack-internal-tokenPLATFORM_AUTH_SERVICE_URL=http://127.0.0.1:3100PLATFORM_AI_SERVICE_URL=http://127.0.0.1:3300PLATFORM_CONNECTORS_SERVICE_URL=http://127.0.0.1:3200PLATFORM_STATUS_SERVICE_URL=http://127.0.0.1:3400
platform-agent-service
Per il bootstrap canonico via platform-local-stack, il launcher passa DATABASE_URL, REDIS_URL, PLATFORM_MCP_SERVICE_URL e PLATFORM_INTERNAL_TOKEN. Se lo avvii standalone, usa il database agent-postgres e Redis del local stack.
cs-portal
Prepara gli env se devi avviare il repo fuori dal local stack:
bash
cd <workspace-root>/cs-portal
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.envVerifica almeno:
SESSION_COOKIE_*PLATFORM_CONNECTORS_SERVICE_URLPLATFORM_INTERNAL_TOKENDEFAULT_DATA_SOURCE_IDVITE_API_BASE_URL=/api
cs-chat
Prepara gli env se devi avviare il repo fuori dal local stack:
bash
cd <workspace-root>/cs-chat
cp .env.example .envVerifica almeno:
DATABASE_URLPLATFORM_AUTH_SERVICE_URLPLATFORM_AI_SERVICE_URLPLATFORM_AGENT_SERVICE_URLPLATFORM_MCP_SERVICE_URLPLATFORM_INTERNAL_TOKENCS_CHAT_AGENT_CALLBACK_BASE_URLCS_CHAT_PRODUCT_CODE=cs-chat
cs-transacion-manage
Prepara gli env se devi avviare il repo fuori dal local stack:
bash
cd <workspace-root>/cs-transacion-manage
cp apps/api/.env.example apps/api/.envVerifica almeno:
DATABASE_URLPLATFORM_AUTH_SERVICE_URLPLATFORM_PAYMENTS_SERVICE_URLPLATFORM_INTERNAL_TOKENCS_TRANSACTION_PRODUCT_CODE=cs-transacion-managePORT
sfdc-external
Per sfdc-external non c'è oggi un passaggio canonico cp ... .env già documentato al livello root del repo.
Usa backend/.env.example come sorgente di riferimento per allineare le variabili richieste dal tuo ambiente locale:
bash
cd <workspace-root>/sfdc-external
sed -n '1,220p' backend/.env.example
sed -n '1,120p' frontend/.env.exampleIn particolare verifica almeno:
DATABASE_URLSHADOW_DATABASE_URLFRONTEND_ORIGINS- eventuali variabili auth o Salesforce richieste dal tuo scenario locale
Per il frontend, il default locale resta VITE_API_BASE_URL=/api.
Servizi senza setup .env dedicato
Per il bootstrap canonico via platform-local-stack, platform-auth-service, platform-connectors-service, platform-mcp-service, platform-agent-service, platform-status-service e platform-wiki non richiedono copie manuali di file .env: lo stack launcher passa le variabili runtime necessarie, inclusa STATUS_DATABASE_URL per il catalogo prodotti status.
Allineamento database locali
sfdc-external
Genera il client Prisma ed esegui le migrazioni:
bash
cd <workspace-root>/sfdc-external
npm exec --workspace backend prisma -- generate --schema prisma/schema.prisma
npm exec --workspace backend prisma -- migrate dev --schema prisma/schema.prismafunnel-ia-engine
Allinea Prisma nel backend:
bash
cd <workspace-root>/funnel-ia-engine/backend
npm run prisma:generate
npm run prisma:migrate:deployplatform-auth-service
Non richiede migrazioni manuali. All'avvio inizializza la propria tabella di stato nel database auth-postgres.
platform-agent-service
Se avvii il servizio fuori dal local stack, genera Prisma e applica le migrazioni con DATABASE_URL puntato al database agent-postgres:
bash
cd <workspace-root>/platform-agent-service
npm run prisma:generate
npm run prisma:migrate:deployplatform-status-service
Se avvii il servizio fuori dal local stack, genera Prisma e applica le migrazioni con STATUS_DATABASE_URL puntato al database status scelto:
bash
cd <workspace-root>/platform-status-service
npm run prisma:generate --workspace backend
npm run prisma:migrate:deploy --workspace backendcs-chat
Genera il client Prisma ed esegui le migrazioni:
bash
cd <workspace-root>/cs-chat
npm run prisma:generate
npm run prisma:migrate:devcs-transacion-manage
Se avvii il repo fuori dal local stack, genera il client Prisma ed esegui le migrazioni:
bash
cd <workspace-root>/cs-transacion-manage
npm run db:migrateAvvio canonico dell'intero stack
L'unico entrypoint locale canonico è platform-local-stack:
bash
cd <workspace-root>/platform-local-stack
npm run check-paths
npm run profiles
npm run start:devnpm run check-paths risolve i repository sibling dal basename del remote origin, con fallback ai nomi directory storici definiti in platform-local-stack/config/stack-paths.json. Se il workspace root non coincide con la parent directory di platform-local-stack, esporta STACK_WORKSPACE_ROOT prima di lanciare i comandi.
I backend Nest vengono avviati dal local stack tramite lo script start:local-stack, che è l'entrypoint watch esplicito per il bootstrap locale (nest start --watch). Per avvii standalone usa i normali script start o start:prod del repo. Ogni backend Nest deve mantenere compilerOptions.deleteOutDir: true in nest-cli.json e disabilitare l'incremental cache in tsconfig.build.json, così dist viene pulita prima di emettere output build/watch e non rimangono layout o metadati generati obsoleti.
npm run start:dev usa il profilo YAML full come default e avvia:
- PostgreSQL per
platform-auth-service - PostgreSQL per
platform-agent-service - PostgreSQL per
platform-payments-service - PostgreSQL per
sfdc-external - PostgreSQL e Redis per
funnel-ia-engine - PostgreSQL per
cs-chat - PostgreSQL per
cs-transacion-manage - pgAdmin
- Loki, Grafana e Promtail
platform-auth-serviceplatform-ai-serviceplatform-mcp-serviceplatform-agent-serviceplatform-connectors-serviceplatform-status-service/backendsfdc-external/backendfunnel-ia-engine/backendcs-portal/backendcs-chat/apps/apics-transacion-manage/packages/sharedcs-transacion-manage/apps/apiplatform-status-service/frontendsfdc-external/frontendfunnel-ia-engine/frontendcs-portal/frontendcs-chat/apps/webcs-transacion-manage/apps/webfunnel-ia-engine/backendworkerplatform-wiki- reverse proxy locale su porta
8080
I profili disponibili sono definiti in platform-local-stack/config/profiles e possono essere ispezionati con:
bash
cd <workspace-root>/platform-local-stack
npm run profilesURL locali
Host canonici via proxy
http://auth.cs.lvh.me:8080http://ai.cs.lvh.me:8080http://agent.cs.lvh.me:8080http://mcp.cs.lvh.me:8080/mcphttp://wiki.cs.lvh.me:8080http://status.cs.lvh.me:8080http://status.cs.lvh.me:8080/api/status/overviewhttp://pgadmin.cs.lvh.me:8080http://grafana.cs.lvh.me:8080http://loki.cs.lvh.me:8080http://promtail.cs.lvh.me:8080http://sfdc.cs.lvh.me:8080http://funnel.cs.lvh.me:8080http://portal.cs.lvh.me:8080http://chat.cs.lvh.me:8080http://transactions.cs.lvh.me:8080
Endpoint diretti utili
http://127.0.0.1:3100/healthperplatform-auth-servicehttp://127.0.0.1:3200/healthperplatform-connectors-servicehttp://127.0.0.1:3300/healthperplatform-ai-servicehttp://127.0.0.1:3400/healthperplatform-status-service/backendhttp://127.0.0.1:3400/api/status/overviewper il payload aggregato diplatform-status-servicehttp://127.0.0.1:3500/healthperplatform-mcp-servicehttp://127.0.0.1:3600/healthperplatform-agent-servicehttp://127.0.0.1:3003/api/healthpercs-portal/backendhttp://127.0.0.1:3004/api/healthpercs-chat/apps/apihttp://127.0.0.1:3005/api/healthpercs-transacion-manage/apps/apihttp://127.0.0.1:5176perplatform-status-service/frontendhttp://127.0.0.1:5177percs-portal/frontendhttp://127.0.0.1:5178percs-chat/apps/webhttp://127.0.0.1:5179percs-transacion-manage/apps/webhttp://127.0.0.1:5050per pgAdminhttp://127.0.0.1:3002per Grafanahttp://127.0.0.1:3101per Lokihttp://127.0.0.1:9080per Promtail
Per status.cs.lvh.me, sfdc.cs.lvh.me, funnel.cs.lvh.me, portal.cs.lvh.me, chat.cs.lvh.me e transactions.cs.lvh.me il proxy serve il frontend sull'host root e inoltra il backend solo sui path /api/* (piu /socket.io per Funnel).
lvh.me punta già a 127.0.0.1, quindi non serve modificare /etc/hosts.
Verifiche rapide post-avvio
Verifica UI e routing
Apri questi URL e controlla che rispondano correttamente:
http://wiki.cs.lvh.me:8080http://status.cs.lvh.me:8080http://funnel.cs.lvh.me:8080http://sfdc.cs.lvh.me:8080http://portal.cs.lvh.me:8080http://chat.cs.lvh.me:8080http://transactions.cs.lvh.me:8080http://auth.cs.lvh.me:8080http://ai.cs.lvh.me:8080http://mcp.cs.lvh.me:8080/mcp
Verifica servizi tecnici
- pgAdmin:
http://pgadmin.cs.lvh.me:8080credenziali:pgadmin@example.com/pgadmin - Grafana:
http://grafana.cs.lvh.me:8080credenziali:admin/adminsu volume nuovo; se il volume esiste già mantiene la password inizializzata in precedenza
pgAdmin pre-registra i database locali:
Auth PostgresAgent PostgresPayments PostgresSFDC PostgresFunnel PostgresCS Chat PostgresTransaction Manage Postgres
Password locali alla prima connessione:
Auth Postgres:platform_auth/platform_authAgent Postgres:platform_agent/platform_agentPayments Postgres:platform_payments/platform_paymentsSFDC Postgres:app_rw/app_rwFunnel Postgres:funnelia/funneliaCS Chat Postgres:cs_chat/cs_chatTransaction Manage Postgres:postgres/postgres
Verifica status dashboard
- UI:
http://status.cs.lvh.me:8080 - sessione/setup:
http://status.cs.lvh.me:8080/api/status-auth/session - overview aggregata:
http://status.cs.lvh.me:8080/api/status/overview - health backend diretto:
http://127.0.0.1:3400/health
platform-status-service è l'aggregatore canonico dello stato runtime dei microservizi. Il catalogo /products persiste prodotti, health target e link via Prisma nelle tabelle status_* sul database locale condiviso auth-postgres. La prima apertura della UI mostra il setup se non esiste una membership cs-status con ruolo SUPER_ADMIN.
Verifica health endpoints
Esempi di check rapidi:
bash
curl http://auth.cs.lvh.me:8080/health
curl http://ai.cs.lvh.me:8080/health
curl http://127.0.0.1:3200/health
curl http://127.0.0.1:3500/health
curl http://127.0.0.1:3600/health
curl http://127.0.0.1:3000/api/health
curl http://127.0.0.1:3001/api/health
curl http://127.0.0.1:3003/api/health
curl http://127.0.0.1:3005/api/health
curl http://127.0.0.1:3400/health
curl http://status.cs.lvh.me:8080/api/status/overviewVerifica auth condivisa
Per verificare la sessione condivisa tra prodotti:
- Apri
http://funnel.cs.lvh.me:8080/#/login - Esegui login con
admin@local.test/ChangeMe123! - Verifica
GET http://funnel.cs.lvh.me:8080/api/auth/session - Apri
http://sfdc.cs.lvh.me:8080senza rifare login
Check API rapido:
bash
curl -X POST http://funnel.cs.lvh.me:8080/api/auth/login/password \
-H "Content-Type: application/json" \
-d '{"email":"admin@local.test","password":"ChangeMe123!"}'Se stai verificando platform-auth-service in isolamento, ricorda che quelle credenziali non esistono finche un backend di prodotto non le sincronizza oppure finche non fai bootstrap via /internal/identities/upsert.
Comandi utili
Stato servizi
bash
cd <workspace-root>/platform-local-stack
npm run statusStop completo
bash
cd <workspace-root>/platform-local-stack
npm run stop:devAvvio di un sottoinsieme esplicito
Per un setup minimo con servizi CORE e status dashboard:
bash
cd <workspace-root>/platform-local-stack
npm run start:dev -- auth ai connectors mcp statusBackend statusFrontend proxyAvvio tramite profilo
bash
cd <workspace-root>/platform-local-stack
npm run start:dev -- --profile sfdcSolo status dashboard, incluso auth per setup/login:
bash
cd <workspace-root>/platform-local-stack
npm run start:dev -- --profile statusSolo MCP e dipendenze core:
bash
cd <workspace-root>/platform-local-stack
npm run start:dev -- --profile mcpSolo CS Chat e dipendenze core, incluso Agent per le risposte MCP reali:
bash
cd <workspace-root>/platform-local-stack
npm run start:dev -- --profile chatSolo CS Transaction Manage, incluso Payments per il tier subscription usato dall'ACL prodotto:
bash
cd <workspace-root>/platform-local-stack
npm run start:dev -- --profile transactionsSolo CS Portal:
bash
cd <workspace-root>/platform-local-stack
npm run start:dev -- --profile portalComposizione di più profili
bash
cd <workspace-root>/platform-local-stack
npm run start:dev -- --profile core --profile wikiDry run della risoluzione
bash
cd <workspace-root>/platform-local-stack
npm run start:dev -- --profile funnel --dry-runLog runtime
I log runtime locali finiscono in:
<workspace-root>/platform-local-stack/.runtime/logs
Promtail raccoglie questi file e li invia a Loki, oltre ai log dei container Docker del local stack e dei processi host-managed come auth, ai, agent, connectors, mcp, sfdcBackend, funnelBackend, portalBackend, chatBackend, transactionShared, transactionBackend, statusBackend, sfdcFrontend, funnelFrontend, portalFrontend, chatFrontend, transactionFrontend, statusFrontend, wiki e proxy.
Troubleshooting minimo
Porte occupate
Se una porta è già occupata il bootstrap può fallire. Le porte usate dal local stack sono:
8080310031013200330034003500360030003001300230033004300550505173517451755176517751785179543254335434543554365437543863799080
lvh.me
lvh.me risolve già verso 127.0.0.1. Se i domini *.cs.lvh.me non rispondono, il problema è quasi sempre nel bootstrap locale o nel reverse proxy, non nella risoluzione DNS.
Bootstrap canonico unico
- usa
platform-local-stackcome entrypoint locale principale - usa i comandi repo-locali solo per debug puntuale
- se
npm run check-pathsfallisce, correggi prima i path del workspace e poi rilancia lo stack