# nikoleesg/nfield-admin architecture

> Architecture diagram of the GitHub repository nikoleesg/nfield-admin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nikoleesg/nfield-admin
- Repository: https://github.com/nikoleesg/nfield-admin

## Overview

nfield-admin is a Laravel SDK for managing Nfield surveys and related fieldwork resources. An application resolves the manager or survey service, performs survey operations, and receives typed results; fluent survey resources expose fieldwork, sample, data, quota, assignment, publishing, settings, and sampling-method capabilities. Separate services manage CAPI interviewers, sampling points, and background activity. Endpoint implementations use an authenticated HTTP client to communicate with Nfield. The README and excerpts establish the broad capability map, but many endpoint and service implementations were not sampled, so uncertain links are omitted.

Main entry points: [`src/Resources/SurveyResource.php`](https://github.com/nikoleesg/nfield-admin/blob/main/src/Resources/SurveyResource.php) (Survey resource), [`src/Services/Http/HttpClient.php`](https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/Http/HttpClient.php) (HTTP client), [`src/Services/NfieldManagerService.php`](https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/NfieldManagerService.php) (Nfield manager), [`src/Services/SurveyService.php`](https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/SurveyService.php) (Survey service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["SDK entry points"]
  node_manager["Nfield manager"]
  node_sync["Activity sync command"]
end

subgraph group_survey["Survey operations"]
  node_survey_service["Survey service<br/>[SurveyService.php]"]
  node_survey_resource["Survey resource<br/>[SurveyResource.php]"]
  node_legacy_surveys["Survey collection<br/>[SurveysService.php]"]
  node_sample["Sample service"]
  node_survey_data["Survey data service"]
  node_survey_publish["Publishing service"]
end

subgraph group_field["Fieldwork resources"]
  node_fieldwork["Fieldwork service"]
  node_survey_quota["Quota service"]
  node_sampling["Sampling point service"]
  node_interviewers["CAPI interviewer service"]
  node_background["Background activities"]
  node_activity_store[("Activity model")]
end

subgraph group_transport["API transport"]
  node_survey_api["Survey endpoints<br/>[SurveyEndpoint.php]"]
  node_sample_api["Sample endpoints"]
  node_sampling_api["Sampling point endpoints"]
  node_interviewer_api["Interviewer endpoints"]
  node_http["HTTP client<br/>[HttpClient.php]"]
end

node_app(("Laravel application"))
node_api{{"Nfield API"}}

node_app -->|"resolves"| node_manager
node_manager -->|"delegates to"| node_survey_service
node_manager -->|"delegates to"| node_interviewers
node_manager -->|"delegates to"| node_background
node_survey_service -->|"returns"| node_survey_resource
node_survey_resource -->|"calls"| node_survey_api
node_survey_resource -->|"resolves"| node_fieldwork
node_survey_resource -->|"resolves"| node_survey_data
node_survey_resource -->|"resolves"| node_survey_quota
node_survey_resource -->|"resolves"| node_sample
node_survey_resource -->|"resolves"| node_survey_publish
node_sample -->|"downloads from"| node_sample_api
node_legacy_surveys -.->|"manages surveys"| node_api
node_sampling -->|"calls"| node_sampling_api
node_interviewers -->|"calls"| node_interviewer_api
node_background -.->|"persists activity"| node_activity_store
node_sync -->|"updates details"| node_activity_store
node_http -->|"sends requests"| node_api
node_survey_api -.->|"uses client"| node_http
node_sample_api -.->|"uses client"| node_http
node_sampling_api -.->|"uses client"| node_http
node_interviewer_api -.->|"uses client"| node_http

click node_manager "https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/NfieldManagerService.php"
click node_survey_service "https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/SurveyService.php"
click node_survey_resource "https://github.com/nikoleesg/nfield-admin/blob/main/src/Resources/SurveyResource.php"
click node_legacy_surveys "https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/v1/SurveysService.php"
click node_sample "https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/SurveySampleService.php"
click node_survey_api "https://github.com/nikoleesg/nfield-admin/blob/main/src/Endpoints/v2/SurveyEndpoint.php"
click node_sample_api "https://github.com/nikoleesg/nfield-admin/blob/main/src/Endpoints/v2/SurveySampleCollectionEndpoint.php"
click node_fieldwork "https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/SurveyFieldworkService.php"
click node_survey_data "https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/SurveyDataService.php"
click node_survey_quota "https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/SurveyQuotaService.php"
click node_survey_publish "https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/SurveyPublishService.php"
click node_sampling "https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/v1/SamplingPointService.php"
click node_sampling_api "https://github.com/nikoleesg/nfield-admin/blob/main/src/Endpoints/v2/SamplingPointEndpoint.php"
click node_interviewers "https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/CapiInterviewerService.php"
click node_interviewer_api "https://github.com/nikoleesg/nfield-admin/blob/main/src/Endpoints/v2/CapiInterviewersEndpoint.php"
click node_background "https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/BackgroundActivitiesService.php"
click node_sync "https://github.com/nikoleesg/nfield-admin/blob/main/src/Commands/SyncBackgroundActivitiesDetailsCommand.php"
click node_activity_store "https://github.com/nikoleesg/nfield-admin/blob/main/src/Models/BackgroundActivity.php"
click node_http "https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/Http/HttpClient.php"

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_manager,node_sync toneBlue
class node_survey_service,node_survey_resource,node_legacy_surveys,node_sample,node_survey_data,node_survey_publish toneAmber
class node_fieldwork,node_survey_quota,node_sampling,node_interviewers,node_background,node_activity_store,node_api toneMint
class node_survey_api,node_sample_api,node_sampling_api,node_interviewer_api,node_http toneRose
class node_app toneIndigo
```

## Components

### SDK entry points

- [Nfield manager](https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/NfieldManagerService.php): `src/Services/NfieldManagerService.php`
- [Activity sync command](https://github.com/nikoleesg/nfield-admin/blob/main/src/Commands/SyncBackgroundActivitiesDetailsCommand.php): `src/Commands/SyncBackgroundActivitiesDetailsCommand.php`

### Survey operations

- [Survey service](https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/SurveyService.php): `src/Services/SurveyService.php`
- [Survey resource](https://github.com/nikoleesg/nfield-admin/blob/main/src/Resources/SurveyResource.php): `src/Resources/SurveyResource.php`
- [Survey collection](https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/v1/SurveysService.php): `src/Services/v1/SurveysService.php`
- [Sample service](https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/SurveySampleService.php): `src/Services/SurveySampleService.php`
- [Survey data service](https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/SurveyDataService.php): `src/Services/SurveyDataService.php`
- [Publishing service](https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/SurveyPublishService.php): `src/Services/SurveyPublishService.php`

### Fieldwork resources

- [Fieldwork service](https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/SurveyFieldworkService.php): `src/Services/SurveyFieldworkService.php`
- [Quota service](https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/SurveyQuotaService.php): `src/Services/SurveyQuotaService.php`
- [Sampling point service](https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/v1/SamplingPointService.php): `src/Services/v1/SamplingPointService.php`
- [CAPI interviewer service](https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/CapiInterviewerService.php): `src/Services/CapiInterviewerService.php`
- [Background activities](https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/BackgroundActivitiesService.php): `src/Services/BackgroundActivitiesService.php`
- [Activity model](https://github.com/nikoleesg/nfield-admin/blob/main/src/Models/BackgroundActivity.php): `src/Models/BackgroundActivity.php`

### API transport

- [Survey endpoints](https://github.com/nikoleesg/nfield-admin/blob/main/src/Endpoints/v2/SurveyEndpoint.php): `src/Endpoints/v2/SurveyEndpoint.php`
- [Sample endpoints](https://github.com/nikoleesg/nfield-admin/blob/main/src/Endpoints/v2/SurveySampleCollectionEndpoint.php): `src/Endpoints/v2/SurveySampleCollectionEndpoint.php`
- [Sampling point endpoints](https://github.com/nikoleesg/nfield-admin/blob/main/src/Endpoints/v2/SamplingPointEndpoint.php): `src/Endpoints/v2/SamplingPointEndpoint.php`
- [Interviewer endpoints](https://github.com/nikoleesg/nfield-admin/blob/main/src/Endpoints/v2/CapiInterviewersEndpoint.php): `src/Endpoints/v2/CapiInterviewersEndpoint.php`
- [HTTP client](https://github.com/nikoleesg/nfield-admin/blob/main/src/Services/Http/HttpClient.php): `src/Services/Http/HttpClient.php`

### Other components

- **Laravel application**
- **Nfield API**

## Connections

- Laravel application → Nfield manager: resolves (evidence: `src/Services/NfieldManagerService.php`)
- Nfield manager → Survey service: delegates to (evidence: `src/Services/NfieldManagerService.php`)
- Nfield manager → CAPI interviewer service: delegates to (evidence: `src/Services/NfieldManagerService.php`)
- Nfield manager → Background activities: delegates to (evidence: `src/Services/NfieldManagerService.php`)
- Survey service → Survey resource: returns
- Survey resource → Survey endpoints: calls (evidence: `src/Resources/SurveyResource.php`)
- Survey resource → Fieldwork service: resolves (evidence: `src/Resources/SurveyResource.php`)
- Survey resource → Survey data service: resolves (evidence: `src/Resources/SurveyResource.php`)
- Survey resource → Quota service: resolves (evidence: `src/Resources/SurveyResource.php`)
- Survey resource → Sample service: resolves (evidence: `src/Resources/SurveyResource.php`)
- Survey resource → Publishing service: resolves (evidence: `src/Resources/SurveyResource.php`)
- Sample service → Sample endpoints: downloads from (evidence: `src/Services/SurveySampleService.php`)
- Survey collection → Nfield API: manages surveys
- Sampling point service → Sampling point endpoints: calls (evidence: `src/Services/v1/SamplingPointService.php`)
- CAPI interviewer service → Interviewer endpoints: calls (evidence: `src/Services/CapiInterviewerService.php`)
- Background activities → Activity model: persists activity
- Activity sync command → Activity model: updates details (evidence: `src/Commands/SyncBackgroundActivitiesDetailsCommand.php`)
- HTTP client → Nfield API: sends requests (evidence: `src/Services/Http/HttpClient.php`)
- Survey endpoints → HTTP client: uses client
- Sample endpoints → HTTP client: uses client
- Sampling point endpoints → HTTP client: uses client
- Interviewer endpoints → HTTP client: uses client
