> For the complete documentation index, see [llms.txt](https://docs.k9.io/key9-identity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.k9.io/key9-identity/highvolt/highvolt-server/highvolt-server.md).

# Overview

`highvolt-server` is the central analysis engine. It exposes a REST API over HTTP or HTTPS, accepts file submissions from clients, queues them for asynchronous LLM analysis, and stores results in OpenSearch.

## Source layout

```
cmd/highvolt-server/
├── main.go          — startup, HTTP routing, TLS, shutdown
├── submit.go        — POST /submit handler
├── query.go         — POST /query handler
├── jwt.go           — authentication token issuance and middleware
├── ratelimit.go     — per-IP rate limiting for /auth/token
├── haproxy.go       — optional HAProxy TCP health agent
├── reload.go        — config/debug reload monitor
├── signal.go        — OS signal handler
├── log.go           — HTTP request logger middleware
├── auth/
│   └── jwt_pat.go   — PAT → JWT exchange for JSONAir
├── config/
│   ├── config.go    — config fetch, parse, and hot-reload
│   └── env.go       — environment variable loading
├── db/
│   └── opensearch.go — OpenSearch index and search
├── debug/
│   └── debug.go     — debug flag management
├── helpers/
│   ├── helpers.go   — MIME type classification
│   └── sanity.go    — JSON payload validation
├── llm/
│   └── llm.go       — LLM submission (OpenAI-compatible)
├── models/
│   ├── config.go    — config structs
│   └── env.go       — environment structs
├── processors/
│   ├── submit_data.go — dispatch to per-type processor
│   ├── pdf.go         — PDF → PNG → LLM
│   ├── office.go      — Office → PDF → PNG → LLM
│   └── archive.go     — archive extraction and per-file analysis
└── queue/
    ├── queue.go     — in-memory bounded channel queue
    ├── worker.go    — goroutine worker pool
    └── dowork.go    — per-item work dispatch
```

## Startup sequence

1. Logger initialized to `local` syslog.
2. Environment variables loaded (needed to reach JSONAir).
3. PAT exchanged for a JSONAir JWT; configuration blob fetched.
4. Background goroutines started: config monitor, signal handler.
5. Logger reconfigured to user-specified syslog target.
6. Debug level fetched from JSONAir.
7. OpenSearch client initialized.
8. Worker pool started.
9. HAProxy TCP agent started (if enabled).
10. HTTP server bound (drops Unix privileges after bind).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.k9.io/key9-identity/highvolt/highvolt-server/highvolt-server.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
