# mauriceos/residential-app architecture

> Architecture diagram of the GitHub repository mauriceos/residential-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mauriceos/residential-app
- Repository: https://github.com/mauriceos/residential-app

## Overview

#### Purpose and repository shape
This is an NCRRA member-platform repository containing two parallel deliverables: a TypeScript/Vite interactive application scaffold and an implementation-oriented platform with mobile, service, provider-adapter, contract, and operations artifacts. The implementation is organized around membership, ticketing, tenant isolation, and member-facing mobile flows.

#### TypeScript application entry and UI shell
The runnable TypeScript application enters through `ncrra-app/client/src/main.tsx` and composes its top-level UI in `ncrra-app/client/src/App.tsx`. Its Node server starts at `ncrra-app/server/index.ts`, with shared API routing in `ncrra-app/server/routers.ts`.
- The client contains Home, navigation, dashboard layout, map, and AI chat surfaces, centered on `ncrra-app/client/src/pages/Home.tsx`, `ncrra-app/client/src/components/DashboardLayout.tsx`, and `ncrra-app/client/src/components/AIChatBox.tsx`.
- Client-server interaction is mediated through tRPC client/server infrastructure: `ncrra-app/client/src/lib/trpc.ts`, `ncrra-app/server/_core/trpc.ts`, and `ncrra-app/server/_core/context.ts`.
- This stack also includes platform-provided capabilities such as OAuth, LLM, mapping, notification, storage proxy, image generation, and voice transcription under `ncrra-app/server/_core/`.

#### Mobile member application
The production-oriented member client is a Flutter app, entered at `ncrra-app/implementation/mobile/flutter/ncrra_member_app/lib/main.dart` and assembled by `ncrra-app/implementation/mobile/flutter/ncrra_member_app/lib/src/app.dart`.
- Authentication is composed around a Keycloak OIDC session: `lib/src/core/auth/authentication_composition.dart` and `lib/src/core/auth/keycloak_oidc_session.dart`.
- The network boundary is centralized in `lib/src/core/network/ncrra_api_client.dart`, separating feature UI from backend transport.
- Feature stages include onboarding, member sections, home, and ticket dashboard: `lib/src/features/onboarding/presentation/onboarding_flow.dart`, `lib/src/features/member_sections/presentation/member_section_screens.dart`, and `lib/src/features/tickets/presentation/ticket_dashboard_screen.dart`.
- Android and iOS packaging are maintained in the same Flutter project.

#### Domain services and persistence
Two independent ASP.NET services define primary backend domain boundaries:
- Membership API: `ncrra-app/implementation/backend/dotnet/Ncrra.Membership.Api/Program.cs` with EF Core persistence in `Persistence/MembershipDbContext.cs`.
- Ticketing API: `ncrra-app/implementation/backend/dotnet/Ncrra.Ticketing.Api/Program.cs` with persistence in `Persistence/TicketingDbContext.cs`.
- Each service owns migrations and a tenant database-session mechanism, e.g. `Ncrra.Membership.Api/Security/TenantSessionScope.cs` and `Ncrra.Ticketing.Api/Security/TenantSessionScope.cs`. This makes tenant context a hard boundary between request handling and PostgreSQL access, with RLS integration SQL supplied per service.

#### Provider integration and contracts
External-provider connectivity is isolated in a Go provider-adapter rather than embedded in membership or ticketing services. Its service entry point is `ncrra-app/implementation/backend/go/provider-adapter/cmd/provider-adapter/main.go`; agreement-record processing has a separate command at `cmd/agreement-record/main.go`.
- Provider implementations conform to a port/registry boundary in `internal/provider/port.go` and `internal/provider/registry.go`.
- Cross-service/API contracts are versioned independently: `implementation/contracts/openapi/ticketing.openapi.yaml` and `implementation/contracts/events/ticket-created.v1.json`.

#### Runtime infrastructure and delivery
The target platform is containerized with PostgreSQL, Keycloak, Caddy, and observability components defined by `ncrra-app/implementation/ops/compose/compose.yaml`. Supporting configs include `otel-collector.yaml`, `prometheus.yml`, and `Caddyfile`.
- Keycloak realm configuration is versioned at `implementation/ops/keycloak/realm-ncrra-dev.json`.
- Ansible bootstrap/inventory artifacts support environment provisioning: `implementation/ops/ansible/playbooks/bootstrap.yml`.
- CI includes general verification and database migration workflows: `ncrra-app/.github/workflows/verify.yml` and `ncrra-app/.github/workflows/rls-migrations.yml`.

Main entry points: [`ncrra-app/implementation/ops/compose/compose.yaml`](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/ops/compose/compose.yaml) (Container runtime), [`ncrra-app/implementation/backend/dotnet/Ncrra.Ticketing.Api/Program.cs`](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/backend/dotnet/Ncrra.Ticketing.Api/Program.cs) (Ticketing API), [`ncrra-app/implementation/mobile/flutter/ncrra_member_app/lib/src/app.dart`](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/mobile/flutter/ncrra_member_app/lib/src/app.dart) (Member flows), [`ncrra-app/implementation/backend/dotnet/Ncrra.Membership.Api/Program.cs`](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/backend/dotnet/Ncrra.Membership.Api/Program.cs) (Membership API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ts["TypeScript Scaffold"]
  node_web_client["Vite client<br/>TypeScript UI<br/>[main.tsx]"]
  node_ui_shell["Dashboard &amp; member UI<br/>UI shell<br/>[App.tsx]"]
  node_node_api["Node API<br/>Node server<br/>[index.ts]"]
  node_trpc["tRPC boundary<br/>RPC layer<br/>[trpc.ts]"]
end

subgraph group_mobile["Member Mobile App"]
  node_flutter_app["Flutter app<br/>mobile entry<br/>[main.dart]"]
  node_mobile_shell["Member flows<br/>feature UI<br/>[app.dart]"]
  node_oidc["Keycloak OIDC session<br/>authentication"]
  node_mobile_api["NCRRA API client<br/>network boundary"]
end

subgraph group_services["Domain Services"]
  node_membership_api["Membership API<br/>ASP.NET service<br/>[Program.cs]"]
  node_membership_tenant["Membership tenant session<br/>tenant boundary"]
  node_membership_db[("Membership PostgreSQL<br/>EF Core database")]
  node_ticketing_api["Ticketing API<br/>ASP.NET service<br/>[Program.cs]"]
  node_ticketing_tenant["Ticketing tenant session<br/>tenant boundary"]
  node_ticketing_db[("Ticketing PostgreSQL<br/>EF Core database")]
end

subgraph group_integration["Integration &amp; Contracts"]
  node_provider_adapter["Provider adapter<br/>Go service<br/>[main.go]"]
  node_provider_port["Provider port &amp; registry<br/>adapter boundary"]
  node_contracts["Ticketing contracts<br/>OpenAPI and event schema"]
end

subgraph group_ops["Platform Operations"]
  node_runtime{{"Container runtime<br/>compose platform<br/>[compose.yaml]"}}
  node_realm["Keycloak realm<br/>identity config"]
  node_provisioning["Environment bootstrap<br/>Ansible playbook"]
  node_delivery["Verification &amp; RLS CI<br/>GitHub Actions<br/>[rls-migrations.yml]"]
end

node_web_client -->|"renders"| node_ui_shell
node_ui_shell -->|"calls"| node_trpc
node_node_api -->|"hosts"| node_trpc
node_flutter_app -->|"assembles"| node_mobile_shell
node_mobile_shell -->|"authenticates"| node_oidc
node_mobile_shell -->|"uses"| node_mobile_api
node_oidc -.->|"OIDC realm"| node_realm
node_mobile_api -->|"member requests"| node_membership_api
node_mobile_api -->|"ticket requests"| node_ticketing_api
node_membership_api -->|"establishes"| node_membership_tenant
node_membership_tenant -->|"RLS-scoped access"| node_membership_db
node_ticketing_api -->|"establishes"| node_ticketing_tenant
node_ticketing_tenant -->|"RLS-scoped access"| node_ticketing_db
node_ticketing_api -->|"provider integration"| node_provider_adapter
node_provider_adapter -->|"implements"| node_provider_port
node_ticketing_api -.->|"implements"| node_contracts
node_runtime -.->|"runs"| node_membership_api
node_runtime -.->|"runs"| node_ticketing_api
node_runtime -.->|"runs"| node_provider_adapter
node_runtime -.->|"loads"| node_realm
node_provisioning -->|"provisions"| node_runtime
node_delivery -.->|"migrates RLS"| node_membership_db
node_delivery -.->|"migrates RLS"| node_ticketing_db

click node_web_client "https://github.com/mauriceos/residential-app/blob/main/ncrra-app/client/src/main.tsx"
click node_ui_shell "https://github.com/mauriceos/residential-app/blob/main/ncrra-app/client/src/App.tsx"
click node_node_api "https://github.com/mauriceos/residential-app/blob/main/ncrra-app/server/index.ts"
click node_trpc "https://github.com/mauriceos/residential-app/blob/main/ncrra-app/server/_core/trpc.ts"
click node_flutter_app "https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/mobile/flutter/ncrra_member_app/lib/main.dart"
click node_mobile_shell "https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/mobile/flutter/ncrra_member_app/lib/src/app.dart"
click node_membership_api "https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/backend/dotnet/Ncrra.Membership.Api/Program.cs"
click node_membership_db "https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/backend/dotnet/Ncrra.Membership.Api/Persistence/MembershipDbContext.cs"
click node_ticketing_api "https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/backend/dotnet/Ncrra.Ticketing.Api/Program.cs"
click node_ticketing_db "https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/backend/dotnet/Ncrra.Ticketing.Api/Persistence/TicketingDbContext.cs"
click node_provider_adapter "https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/backend/go/provider-adapter/cmd/provider-adapter/main.go"
click node_runtime "https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/ops/compose/compose.yaml"
click node_delivery "https://github.com/mauriceos/residential-app/blob/main/ncrra-app/.github/workflows/rls-migrations.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web_client,node_ui_shell,node_node_api,node_trpc toneBlue
class node_flutter_app,node_mobile_shell,node_oidc,node_mobile_api toneAmber
class node_membership_api,node_membership_tenant,node_membership_db,node_ticketing_api,node_ticketing_tenant,node_ticketing_db toneMint
class node_provider_adapter,node_provider_port,node_contracts toneRose
class node_runtime,node_realm,node_provisioning,node_delivery toneIndigo
```

## Components

### TypeScript Scaffold

Interactive Vite app and Node API.

- [Vite client](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/client/src/main.tsx): TypeScript UI · `ncrra-app/client/src/main.tsx`
- [Dashboard & member UI](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/client/src/App.tsx): UI shell · Home, dashboard, map, and AI chat surfaces. · `ncrra-app/client/src/App.tsx`
- [Node API](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/server/index.ts): Node server · `ncrra-app/server/index.ts`
- [tRPC boundary](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/server/_core/trpc.ts): RPC layer · Shared client, server, and request context. · `ncrra-app/server/_core/trpc.ts`

### Member Mobile App

Flutter member-facing client.

- [Flutter app](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/mobile/flutter/ncrra_member_app/lib/main.dart): mobile entry · `ncrra-app/implementation/mobile/flutter/ncrra_member_app/lib/main.dart`
- [Member flows](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/mobile/flutter/ncrra_member_app/lib/src/app.dart): feature UI · Onboarding, member sections, home, and tickets. · `ncrra-app/implementation/mobile/flutter/ncrra_member_app/lib/src/app.dart`
- **Keycloak OIDC session**: authentication
- **NCRRA API client**: network boundary

### Domain Services

Tenant-isolated membership and ticketing APIs.

- [Membership API](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/backend/dotnet/Ncrra.Membership.Api/Program.cs): ASP.NET service · `ncrra-app/implementation/backend/dotnet/Ncrra.Membership.Api/Program.cs`
- **Membership tenant session**: tenant boundary · Sets tenant context before database access.
- [Membership PostgreSQL](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/backend/dotnet/Ncrra.Membership.Api/Persistence/MembershipDbContext.cs): EF Core database · `ncrra-app/implementation/backend/dotnet/Ncrra.Membership.Api/Persistence/MembershipDbContext.cs`
- [Ticketing API](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/backend/dotnet/Ncrra.Ticketing.Api/Program.cs): ASP.NET service · `ncrra-app/implementation/backend/dotnet/Ncrra.Ticketing.Api/Program.cs`
- **Ticketing tenant session**: tenant boundary · Sets tenant context before database access.
- [Ticketing PostgreSQL](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/backend/dotnet/Ncrra.Ticketing.Api/Persistence/TicketingDbContext.cs): EF Core database · `ncrra-app/implementation/backend/dotnet/Ncrra.Ticketing.Api/Persistence/TicketingDbContext.cs`

### Integration & Contracts

Provider boundary and versioned interchange.

- [Provider adapter](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/backend/go/provider-adapter/cmd/provider-adapter/main.go): Go service · Isolates external-provider connectivity. · `ncrra-app/implementation/backend/go/provider-adapter/cmd/provider-adapter/main.go`
- **Provider port & registry**: adapter boundary
- **Ticketing contracts**: OpenAPI and event schema · Versioned API and ticket-created event contracts.

### Platform Operations

Runtime, identity, provisioning, and delivery.

- [Container runtime](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/implementation/ops/compose/compose.yaml): compose platform · PostgreSQL, Keycloak, Caddy, and observability. · `ncrra-app/implementation/ops/compose/compose.yaml`
- **Keycloak realm**: identity config
- **Environment bootstrap**: Ansible playbook
- [Verification & RLS CI](https://github.com/mauriceos/residential-app/blob/main/ncrra-app/.github/workflows/rls-migrations.yml): GitHub Actions · Verification and database migration workflows. · `ncrra-app/.github/workflows/rls-migrations.yml`

## Connections

- Vite client → Dashboard & member UI: renders
- Dashboard & member UI → tRPC boundary: calls
- Node API → tRPC boundary: hosts
- Flutter app → Member flows: assembles
- Member flows → Keycloak OIDC session: authenticates
- Member flows → NCRRA API client: uses
- Keycloak OIDC session → Keycloak realm: OIDC realm
- NCRRA API client → Membership API: member requests
- NCRRA API client → Ticketing API: ticket requests
- Membership API → Membership tenant session: establishes
- Membership tenant session → Membership PostgreSQL: RLS-scoped access
- Ticketing API → Ticketing tenant session: establishes
- Ticketing tenant session → Ticketing PostgreSQL: RLS-scoped access
- Ticketing API → Provider adapter: provider integration
- Provider adapter → Provider port & registry: implements
- Ticketing API → Ticketing contracts: implements
- Container runtime → Membership API: runs
- Container runtime → Ticketing API: runs
- Container runtime → Provider adapter: runs
- Container runtime → Keycloak realm: loads
- Environment bootstrap → Container runtime: provisions
- Verification & RLS CI → Membership PostgreSQL: migrates RLS
- Verification & RLS CI → Ticketing PostgreSQL: migrates RLS
