# navikt/pam-stillingsok architecture

> Architecture diagram of the GitHub repository navikt/pam-stillingsok, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/navikt/pam-stillingsok
- Repository: https://github.com/navikt/pam-stillingsok

## Overview

pam-stillingsok is the Next.js frontend for searching jobs on arbeidsplassen.nav.no. A visitor enters search criteria, which are normalized and sent through the search route to the search service; results support filtering and pagination. Logged-in users can also save favorites and searches, while the app provides summer-job listings, account pages, informational articles, and youth-focused content. The README documents the main external services; source-index references and excerpts establish the detailed search and authenticated-user calls. Other UI-to-API links are shown only where documented or marked unverified.

Main entry points: [`src/app/stillinger/(sok)/_utils/fetchElasticSearch.ts`](https://github.com/navikt/pam-stillingsok/blob/master/src/app/stillinger/(sok)/_utils/fetchElasticSearch.ts) (Search fetch), [`src/app/stillinger/(sok)/_utils/query.ts`](https://github.com/navikt/pam-stillingsok/blob/master/src/app/stillinger/(sok)/_utils/query.ts) (Query parsing), [`src/app/stillinger/api/search/route.ts`](https://github.com/navikt/pam-stillingsok/blob/master/src/app/stillinger/api/search/route.ts) (Search route), [`src/app/stillinger/(sok)/_utils/versioning/searchParamsVersioning.ts`](https://github.com/navikt/pam-stillingsok/blob/master/src/app/stillinger/(sok)/_utils/versioning/searchParamsVersioning.ts) (URL migration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_search["Job search"]
  node_search_ui["Search interface"]
  node_search_route["Search route<br/>[route.ts]"]
  node_search_params["Query parsing<br/>[query.ts]"]
  node_param_migration["URL migration"]
  node_search_fetch["Search fetch"]
  node_search_schema["Result validation"]
  node_summer_jobs["Summer jobs"]
end

subgraph group_accounts["Accounts"]
  node_sign_in["Sign-in and tokens<br/>[auth.server.ts]"]
  node_aduser_auth["Aduser token exchange"]
  node_account_route["User API route<br/>[route.ts]"]
  node_saved_items["Favorites and saved searches"]
  node_my_page["My page"]
end

subgraph group_content["Content and discovery"]
  node_articles["Articles and SEO"]
  node_home["Home and employer pages"]
  node_youth["Youth section<br/>[UngMainPage.tsx]"]
end

subgraph group_platform["Shared platform"]
  node_geography["Geographic data<br/>[fetchLocations.ts]"]
  node_experiments["Experiments<br/>[middlewareAb.ts]"]
  node_telemetry["Event telemetry<br/>[route.ts]"]
  node_metrics["Service metrics<br/>[metrics.ts]"]
  node_cache[("Next.js cache<br/>[cache-handler.mjs]")]
end

node_visitor(("Job seeker"))
node_search_service{{"Search API"}}
node_aduser_service{{"pam-aduser"}}
node_redis[("Redis or Valkey")]
node_wonderwall{{"Wonderwall"}}

node_visitor -->|"searches"| node_search_ui
node_search_ui -.->|"requests results"| node_search_route
node_search_route -->|"migrates parameters"| node_param_migration
node_search_route -->|"parses query"| node_search_params
node_search_route -->|"fetches results"| node_search_fetch
node_search_params -->|"reads version"| node_param_migration
node_search_fetch -->|"builds query"| node_search_params
node_search_fetch -->|"validates results"| node_search_schema
node_search_fetch -->|"queries"| node_search_service
node_param_migration -->|"normalizes parameters"| node_search_params
node_param_migration -->|"uses query names"| node_search_params
node_visitor -->|"browses"| node_summer_jobs
node_visitor -->|"saves searches"| node_saved_items
node_saved_items -->|"stores favorites and searches"| node_aduser_service
node_visitor -.->|"opens account"| node_my_page
node_wonderwall -->|"provides authentication"| node_sign_in
node_account_route -->|"exchanges token"| node_sign_in
node_sign_in -->|"gets OBO token"| node_aduser_auth
node_account_route -->|"forwards user requests"| node_aduser_service
node_visitor -->|"reads guidance"| node_articles
node_visitor -.->|"visits"| node_home
node_visitor -.->|"visits"| node_youth
node_search_ui -.->|"uses location options"| node_geography
node_experiments -->|"assigns variants"| node_visitor
node_visitor -.->|"sends events"| node_telemetry
node_search_fetch -->|"records search metrics"| node_metrics
node_cache -->|"stores cache"| node_redis

click node_search_ui "https://github.com/navikt/pam-stillingsok/tree/master/src/app/stillinger/(sok)/_components"
click node_search_route "https://github.com/navikt/pam-stillingsok/blob/master/src/app/stillinger/api/search/route.ts"
click node_search_params "https://github.com/navikt/pam-stillingsok/blob/master/src/app/stillinger/(sok)/_utils/query.ts"
click node_param_migration "https://github.com/navikt/pam-stillingsok/blob/master/src/app/stillinger/(sok)/_utils/versioning/searchParamsVersioning.ts"
click node_search_fetch "https://github.com/navikt/pam-stillingsok/blob/master/src/app/stillinger/(sok)/_utils/fetchElasticSearch.ts"
click node_search_schema "https://github.com/navikt/pam-stillingsok/blob/master/src/server/schemas/stillingSearchSchema.ts"
click node_summer_jobs "https://github.com/navikt/pam-stillingsok/tree/master/src/app/sommerjobb"
click node_sign_in "https://github.com/navikt/pam-stillingsok/blob/master/src/app/_common/auth/auth.server.ts"
click node_aduser_auth "https://github.com/navikt/pam-stillingsok/blob/master/src/app/_common/auth/aduserAuth.server.ts"
click node_account_route "https://github.com/navikt/pam-stillingsok/blob/master/src/app/api/aduser/v1/user/route.ts"
click node_saved_items "https://github.com/navikt/pam-stillingsok/tree/master/src/app/stillinger/_common/actions"
click node_my_page "https://github.com/navikt/pam-stillingsok/tree/master/src/app/min-side"
click node_articles "https://github.com/navikt/pam-stillingsok/tree/master/src/app/(artikler)"
click node_home "https://github.com/navikt/pam-stillingsok/tree/master/src/app/(forside)"
click node_youth "https://github.com/navikt/pam-stillingsok/blob/master/src/features/ung/ui/UngMainPage.tsx"
click node_geography "https://github.com/navikt/pam-stillingsok/blob/master/src/app/_common/geografi/fetchLocations.ts"
click node_experiments "https://github.com/navikt/pam-stillingsok/blob/master/src/app/_experiments/middlewareAb.ts"
click node_telemetry "https://github.com/navikt/pam-stillingsok/blob/master/src/app/api/telemetry/events/route.ts"
click node_metrics "https://github.com/navikt/pam-stillingsok/blob/master/src/metrics.ts"
click node_cache "https://github.com/navikt/pam-stillingsok/blob/master/cache-handler.mjs"

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_search_ui,node_search_route,node_search_params,node_param_migration,node_search_fetch,node_search_schema,node_summer_jobs,node_aduser_service toneBlue
class node_sign_in,node_aduser_auth,node_account_route,node_saved_items,node_my_page,node_redis toneAmber
class node_articles,node_home,node_youth,node_search_service toneMint
class node_geography,node_experiments,node_telemetry,node_metrics,node_cache toneRose
class node_visitor,node_wonderwall toneIndigo
```

## Components

### Job search

- [Search interface](https://github.com/navikt/pam-stillingsok/tree/master/src/app/stillinger/(sok)/_components): `src/app/stillinger/(sok)/_components`
- [Search route](https://github.com/navikt/pam-stillingsok/blob/master/src/app/stillinger/api/search/route.ts): `src/app/stillinger/api/search/route.ts`
- [Query parsing](https://github.com/navikt/pam-stillingsok/blob/master/src/app/stillinger/(sok)/_utils/query.ts): `src/app/stillinger/(sok)/_utils/query.ts`
- [URL migration](https://github.com/navikt/pam-stillingsok/blob/master/src/app/stillinger/(sok)/_utils/versioning/searchParamsVersioning.ts): `src/app/stillinger/(sok)/_utils/versioning/searchParamsVersioning.ts`
- [Search fetch](https://github.com/navikt/pam-stillingsok/blob/master/src/app/stillinger/(sok)/_utils/fetchElasticSearch.ts): `src/app/stillinger/(sok)/_utils/fetchElasticSearch.ts`
- [Result validation](https://github.com/navikt/pam-stillingsok/blob/master/src/server/schemas/stillingSearchSchema.ts): `src/server/schemas/stillingSearchSchema.ts`
- [Summer jobs](https://github.com/navikt/pam-stillingsok/tree/master/src/app/sommerjobb): `src/app/sommerjobb`

### Accounts

- [Sign-in and tokens](https://github.com/navikt/pam-stillingsok/blob/master/src/app/_common/auth/auth.server.ts): `src/app/_common/auth/auth.server.ts`
- [Aduser token exchange](https://github.com/navikt/pam-stillingsok/blob/master/src/app/_common/auth/aduserAuth.server.ts): `src/app/_common/auth/aduserAuth.server.ts`
- [User API route](https://github.com/navikt/pam-stillingsok/blob/master/src/app/api/aduser/v1/user/route.ts): `src/app/api/aduser/v1/user/route.ts`
- [Favorites and saved searches](https://github.com/navikt/pam-stillingsok/tree/master/src/app/stillinger/_common/actions): `src/app/stillinger/_common/actions`
- [My page](https://github.com/navikt/pam-stillingsok/tree/master/src/app/min-side): `src/app/min-side`

### Content and discovery

- [Articles and SEO](https://github.com/navikt/pam-stillingsok/tree/master/src/app/(artikler)): `src/app/(artikler)`
- [Home and employer pages](https://github.com/navikt/pam-stillingsok/tree/master/src/app/(forside)): `src/app/(forside)`
- [Youth section](https://github.com/navikt/pam-stillingsok/blob/master/src/features/ung/ui/UngMainPage.tsx): `src/features/ung/ui/UngMainPage.tsx`

### Shared platform

- [Geographic data](https://github.com/navikt/pam-stillingsok/blob/master/src/app/_common/geografi/fetchLocations.ts): `src/app/_common/geografi/fetchLocations.ts`
- [Experiments](https://github.com/navikt/pam-stillingsok/blob/master/src/app/_experiments/middlewareAb.ts): `src/app/_experiments/middlewareAb.ts`
- [Event telemetry](https://github.com/navikt/pam-stillingsok/blob/master/src/app/api/telemetry/events/route.ts): `src/app/api/telemetry/events/route.ts`
- [Service metrics](https://github.com/navikt/pam-stillingsok/blob/master/src/metrics.ts): `src/metrics.ts`
- [Next.js cache](https://github.com/navikt/pam-stillingsok/blob/master/cache-handler.mjs): `cache-handler.mjs`

### Other components

- **Job seeker**
- **Search API**
- **pam-aduser**
- **Redis or Valkey**
- **Wonderwall**

## Connections

- Job seeker → Search interface: searches
- Search interface → Search route: requests results
- Search route → URL migration: migrates parameters (evidence: `src/app/stillinger/api/search/route.ts`)
- Search route → Query parsing: parses query (evidence: `src/app/stillinger/api/search/route.ts`)
- Search route → Search fetch: fetches results (evidence: `src/app/stillinger/api/search/route.ts`)
- Query parsing → URL migration: reads version (evidence: `src/app/stillinger/(sok)/_utils/query.ts`)
- Search fetch → Query parsing: builds query (evidence: `src/app/stillinger/(sok)/_utils/fetchElasticSearch.ts`)
- Search fetch → Result validation: validates results (evidence: `src/app/stillinger/(sok)/_utils/fetchElasticSearch.ts`)
- Search fetch → Search API: queries
- URL migration → Query parsing: normalizes parameters (evidence: `src/app/stillinger/(sok)/_utils/versioning/searchParamsVersioning.ts`)
- URL migration → Query parsing: uses query names (evidence: `src/app/stillinger/(sok)/_utils/versioning/searchParamsVersioning.ts`)
- Job seeker → Summer jobs: browses
- Job seeker → Favorites and saved searches: saves searches
- Favorites and saved searches → pam-aduser: stores favorites and searches
- Job seeker → My page: opens account
- Wonderwall → Sign-in and tokens: provides authentication
- User API route → Sign-in and tokens: exchanges token (evidence: `src/app/api/aduser/v1/user/route.ts`)
- Sign-in and tokens → Aduser token exchange: gets OBO token (evidence: `src/app/_common/auth/auth.server.ts`)
- User API route → pam-aduser: forwards user requests (evidence: `src/app/api/aduser/v1/user/route.ts`)
- Job seeker → Articles and SEO: reads guidance
- Job seeker → Home and employer pages: visits
- Job seeker → Youth section: visits
- Search interface → Geographic data: uses location options
- Experiments → Job seeker: assigns variants
- Job seeker → Event telemetry: sends events
- Search fetch → Service metrics: records search metrics (evidence: `src/app/stillinger/(sok)/_utils/fetchElasticSearch.ts`)
- Next.js cache → Redis or Valkey: stores cache (evidence: `cache-handler.mjs`)
