How projectsprav/dv-portal works
1. This is a Next.js App Router application with a clear split between UI routes, server-side actions, and small API endpoints. The app is built around operational workflows for a data-center/business management console rather than a generic content site.
2. The main user-facing areas are route-based feature screens under src/app: cross-connects, dc-access, energy, invoices, racks, settings, and tickets. These pages are backed by feature-specific React components in src/components, with a shared shell/layout in AppLayout, Layout, and Providers.
3. Business logic is concentrated in src/app/actions. Those server actions are organized by domain: auth, dc-access, energy, adminEnergy, freshdesk, and xero. This suggests the primary pattern is: UI triggers a server action, the action talks to persistence and/or external services, and the page refreshes from returned state.
4. PocketBase is the core backend data store and likely the system of record. Evidence includes src/lib/pocketbaseClient.ts, pb_migrations/, schema/rule inspection scripts, and many collection/user maintenance scripts. The app’s data layer is therefore anchored in PocketBase collections, record rules, and migrations rather than a separate SQL backend.
5. Authentication is a dedicated subsystem. There is a NextAuth route at src/app/api/auth/[...nextauth]/route.ts, shared auth helpers in src/auth.ts, and an AuthContext plus Auth component on the client side. The repo also includes admin/user creation and reset scripts, indicating user lifecycle management is partly operational and partly app-driven.
6. External integrations are isolated behind API routes and actions. Xero has its own auth/callback flow under src/app/api/xero/auth and src/app/api/xero/callback, plus an invoice PDF endpoint under src/app/api/xero/invoice/[id]/pdf. Freshdesk and Teams are also integrated, with a Teams webhook route at src/app/api/webhooks/teams/route.ts.
7. The invoice area has both server and client responsibilities. src/app/invoices/page.tsx and CustomerInvoicesClient.tsx imply server-rendered page entry points with a dedicated client component for interactive invoice browsing, while Xero endpoints handle the external accounting side of the same domain.
8. The data-center operational workflows appear centered on access and facility management. dc-access, racks, cross-connects, and energy likely model requests, inventory, and usage tracking, with shared forms such as AccessRequestForm and CrossConnectOrderForm feeding those flows into PocketBase-backed records.
9. The repository includes substantial schema and maintenance tooling. Files like list-schema*.mjs, list-rules.mjs, fix-schema.mjs, update-rules*.mjs, and clean-records.mjs indicate that record rules, collection definitions, and user data are actively managed outside the main app. This is an important architectural boundary: runtime app logic is separate from one-off admin/data repair scripts.
10. Deployment is containerized. The presence of Dockerfile, docker-compose.yml, and docker/nginx/nginx.conf shows the app can run behind Nginx in a containerized environment. Static assets live in public/, including images and a data-center video used by the UI.
11. From a diagram perspective, the key flow is: browser UI → Next.js page/component → server action or API route → PocketBase and/or external service (Xero, Freshdesk, Teams) → response back to the UI. The main integration boundaries are authentication, PocketBase persistence, and third-party service callbacks/webhooks.
Main entry points: AppLayout.tsx UI shell · pocketbaseClient.ts PocketBase · page.tsx Energy · auth.ts Auth actions
Components 24
App UI
Route-based screens and shared client-side shell components.
- Portal shell · Root route and shared app layout that frame the console experience.
src/app/layout.tsx - UI shell · Shared application wrappers, providers, and authenticated shell.
src/components/AppLayout.tsx - Overview · Main landing dashboard for the operational portal.
src/components/Overview.tsx - Cross-connects · Route and page component for cross-connect ordering/workflows.
src/app/cross-connects/page.tsx - DC access · Route and page component for access requests and facility entry workflows.
src/app/dc-access/page.tsx - Energy · Route and page component for energy monitoring and facility usage workflows.
src/app/energy/page.tsx - Invoices · Invoice browsing page with a dedicated client-side interaction layer.
src/app/invoices/page.tsx - Racks · Route and page component for rack inventory and management.
src/app/racks/page.tsx - Settings · Route and page component for configuration and admin settings.
src/app/settings/page.tsx - Tickets · Route and page component for support ticket workflows.
src/app/tickets/page.tsx
Server Actions
Domain actions invoked from the UI to perform writes, orchestration, and external calls.
- Auth actions · Authentication-related server actions and session helpers.
src/app/actions/auth.ts - DC access actions · Server actions for access requests and related facility workflows.
src/app/actions/dc-access.ts - Energy actions · Server actions for energy data and facility-side updates.
src/app/actions/energy.ts - Admin energy · Administrative energy actions used for higher-privilege workflows.
src/app/actions/adminEnergy.ts - Freshdesk actions · Server actions that coordinate with the support system.
src/app/actions/freshdesk.ts - Xero actions · Server actions for accounting and invoice synchronization.
src/app/actions/xero.ts
API Routes
Next.js route handlers for auth, callbacks, and webhooks.
- Auth API · NextAuth route handler for sign-in and session handling.
src/app/api/auth/[...nextauth]/route.ts - Teams webhook · Inbound webhook endpoint for Microsoft Teams notifications.
src/app/api/webhooks/teams/route.ts - Xero API · OAuth callback and invoice PDF endpoints for Xero integration.
src/app/api/xero/callback/route.ts
Data Layer
PocketBase client, migrations, and schema/rule management.
- PocketBase · Shared PocketBase client used by the app and actions.
src/lib/pocketbaseClient.ts - Migrations · PocketBase migration history for collections and record rules.
pb_migrations/1781477868_updated_dc_access_requests.js
Ops Tooling
One-off scripts for users, schema repair, and record maintenance.
- Schema tools · Scripts for listing, fixing, and updating PocketBase collections and rules.
list-schema.mjs - User ops · Scripts for creating, cloning, resetting, and repairing users.
create_users.mjs
Runtime
Container and reverse-proxy deployment assets.
- Container stack · Docker and Nginx runtime used to host the portal.
Dockerfile
Connections 28
- Portal shell → UI shell: uses · Root app is rendered through the shared shell and providers.
- UI shell → Overview: hosts · Shared shell frames the overview dashboard and feature screens.
- UI shell → Cross-connects: navigates · Shell routes users into the cross-connect workflow.
- UI shell → DC access: navigates · Shell routes users into the data-center access workflow.
- UI shell → Energy: navigates · Shell routes users into energy monitoring screens.
- UI shell → Invoices: navigates · Shell routes users into invoice browsing.
- UI shell → Racks: navigates · Shell routes users into rack management.
- UI shell → Settings: navigates · Shell routes users into settings and admin controls.
- UI shell → Tickets: navigates · Shell routes users into ticket workflows.
- Portal shell → Auth actions: auth · App authentication flows are coordinated through server actions and helpers.
- Auth actions → Auth API: session · Authentication actions rely on the NextAuth route handler.
- Cross-connects → DC access actions: mutates · Cross-connect and access style forms submit through domain actions.
- DC access → DC access actions: mutates · Access request UI is backed by dc-access server actions.
- Energy → Energy actions: mutates · Energy UI uses server actions for read/write workflows.
- Energy → Admin energy: admin · Privileged energy views and maintenance use admin actions.
- Tickets → Freshdesk actions: syncs · Ticket workflows coordinate with Freshdesk through actions.
- Invoices → Xero actions: syncs · Invoice UI aligns with Xero-backed accounting workflows.
- Xero actions → Xero API: oauth · Xero actions depend on Xero auth, callback, and PDF endpoints.
- Freshdesk actions → Teams webhook: notifies · Support workflows can emit or receive Teams notifications.
- Auth actions → PocketBase: reads/writes · Auth and user lifecycle operations persist in PocketBase.
- DC access actions → PocketBase: reads/writes · Facility workflows store records in PocketBase.
- Energy actions → PocketBase: reads/writes · Energy workflows use PocketBase as the system of record.
- Admin energy → PocketBase: reads/writes · Administrative energy flows operate on PocketBase data.
- Xero actions → PocketBase: reads/writes · Invoice/accounting state is synchronized with PocketBase records.
- PocketBase → Migrations: defined by · Runtime collections and rules evolve through migrations.
- Migrations → Schema tools: maintained by · Schema maintenance scripts inspect and repair PocketBase structure.
- User ops → PocketBase: administers · User lifecycle scripts operate on the same PocketBase-backed identity store.
- Container stack → Portal shell: runs · Container and reverse-proxy runtime hosts the Next.js app.