# javajayjuice/boxlog architecture

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

- Interactive diagram: https://gitdiagram.com/javajayjuice/boxlog
- Repository: https://github.com/javajayjuice/boxlog

## Overview

boxlog is a structured logging library layered onto Python’s standard logging API. Applications emit records, optionally add contextual fields or bracket work with timing steps, and boxlog enriches/redacts and formats records before asynchronous batch delivery to configurable storage and stdout. Request middleware adds correlation IDs and request records. The stored logs are queried through either an embedded ASGI viewer or the standalone CLI, with a browser interface for filtering and live tail. The graph follows documented capabilities and indexed source references; several subsystem links rely on README documentation because their implementation was not sampled.

Main entry points: [`src/boxlog/configure.py`](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/configure.py) (Logging Setup), [`src/boxlog/formatter.py`](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/formatter.py) (Format Records), [`src/boxlog/viewer/__init__.py`](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/viewer/__init__.py) (Viewer API), [`src/boxlog/backends/__init__.py`](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/backends/__init__.py) (Backend Factory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_logging["Record Processing"]
  node_setup["Logging Setup<br/>[configure.py]"]
  node_record["Record Helpers<br/>[_record.py]"]
  node_formatter["Format Records<br/>[formatter.py]"]
  node_redaction["Secret Redaction<br/>[redaction.py]"]
  node_shipper["Async Shipper<br/>[handler.py]"]
end

subgraph group_context["Tracing and Requests"]
  node_bind["Bound Context<br/>[context.py]"]
  node_steps["Timed Steps<br/>[timing.py]"]
  node_requestmw["Request Middleware<br/>[middleware.py]"]
end

subgraph group_storage["Storage Backends"]
  node_query["Query Model<br/>[query.py]"]
  node_backendfactory["Backend Factory<br/>[__init__.py]"]
  node_backendapi["Backend Protocol<br/>[base.py]"]
  node_memory[("Memory Store<br/>[memory.py]")]
  node_sqlite[("SQLite Store<br/>[sqlite.py]")]
  node_redis[("Redis Store<br/>[redis.py]")]
end

subgraph group_viewer["Log Viewer"]
  node_viewerapi["Viewer API<br/>[__init__.py]"]
  node_cli["Viewer CLI<br/>[cli.py]"]
  node_browser["Viewer Interface<br/>[logs.js]"]
end

node_app(("Python Application"))
node_stdlogging["Python Logging"]
node_stdout["Standard Output"]
node_vieweruser(("Log Viewer User"))

node_app -->|"emits records"| node_stdlogging
node_stdlogging -->|"routes records"| node_shipper
node_app -->|"configures logging"| node_setup
node_setup -->|"installs handler"| node_shipper
node_setup -->|"configures format"| node_formatter
node_setup -->|"configures redaction"| node_redaction
node_setup -->|"builds backend"| node_backendfactory
node_setup -->|"configures output"| node_stdout
node_app -->|"binds fields"| node_bind
node_app -->|"tracks work"| node_steps
node_app -->|"adds middleware"| node_requestmw
node_requestmw -->|"binds request ID"| node_bind
node_requestmw -->|"logs requests"| node_stdlogging
node_formatter -->|"extracts fields"| node_record
node_formatter -->|"reads context"| node_bind
node_formatter -->|"redacts values"| node_redaction
node_shipper -->|"formats records"| node_formatter
node_shipper -->|"appends batches"| node_backendapi
node_backendfactory -->|"creates backend"| node_memory
node_backendfactory -->|"creates backend"| node_sqlite
node_backendfactory -->|"creates backend"| node_redis
node_memory -->|"filters records"| node_query
node_sqlite -->|"filters records"| node_query
node_redis -->|"filters records"| node_query
node_vieweruser -->|"uses viewer"| node_browser
node_browser -->|"requests log data"| node_viewerapi
node_app -->|"mounts viewer"| node_viewerapi
node_cli -->|"serves standalone"| node_viewerapi
node_viewerapi -->|"parses filters"| node_query
node_viewerapi -->|"queries storage"| node_backendapi

click node_setup "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/configure.py"
click node_record "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/_record.py"
click node_formatter "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/formatter.py"
click node_redaction "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/redaction.py"
click node_shipper "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/handler.py"
click node_bind "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/context.py"
click node_steps "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/timing.py"
click node_requestmw "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/middleware.py"
click node_query "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/query.py"
click node_backendfactory "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/backends/__init__.py"
click node_backendapi "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/backends/base.py"
click node_memory "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/backends/memory.py"
click node_sqlite "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/backends/sqlite.py"
click node_redis "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/backends/redis.py"
click node_viewerapi "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/viewer/__init__.py"
click node_cli "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/cli.py"
click node_browser "https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/viewer/static/logs.js"

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_setup,node_record,node_formatter,node_redaction,node_shipper,node_vieweruser toneBlue
class node_bind,node_steps,node_requestmw toneAmber
class node_query,node_backendfactory,node_backendapi,node_memory,node_sqlite,node_redis toneMint
class node_viewerapi,node_cli,node_browser toneRose
class node_app,node_stdlogging,node_stdout toneIndigo
```

## Components

### Record Processing

- [Logging Setup](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/configure.py): `src/boxlog/configure.py`
- [Record Helpers](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/_record.py): `src/boxlog/_record.py`
- [Format Records](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/formatter.py): `src/boxlog/formatter.py`
- [Secret Redaction](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/redaction.py): `src/boxlog/redaction.py`
- [Async Shipper](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/handler.py): `src/boxlog/handler.py`

### Tracing and Requests

- [Bound Context](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/context.py): `src/boxlog/context.py`
- [Timed Steps](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/timing.py): `src/boxlog/timing.py`
- [Request Middleware](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/middleware.py): `src/boxlog/middleware.py`

### Storage Backends

- [Query Model](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/query.py): `src/boxlog/query.py`
- [Backend Factory](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/backends/__init__.py): `src/boxlog/backends/__init__.py`
- [Backend Protocol](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/backends/base.py): `src/boxlog/backends/base.py`
- [Memory Store](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/backends/memory.py): `src/boxlog/backends/memory.py`
- [SQLite Store](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/backends/sqlite.py): `src/boxlog/backends/sqlite.py`
- [Redis Store](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/backends/redis.py): `src/boxlog/backends/redis.py`

### Log Viewer

- [Viewer API](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/viewer/__init__.py): `src/boxlog/viewer/__init__.py`
- [Viewer CLI](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/cli.py): `src/boxlog/cli.py`
- [Viewer Interface](https://github.com/javajayjuice/boxlog/blob/master/src/boxlog/viewer/static/logs.js): `src/boxlog/viewer/static/logs.js`

### Other components

- **Python Application**
- **Python Logging**
- **Standard Output**
- **Log Viewer User**

## Connections

- Python Application → Python Logging: emits records (evidence: `README.md`)
- Python Logging → Async Shipper: routes records (evidence: `README.md`)
- Python Application → Logging Setup: configures logging (evidence: `README.md`)
- Logging Setup → Async Shipper: installs handler (evidence: `src/boxlog/configure.py`)
- Logging Setup → Format Records: configures format (evidence: `src/boxlog/configure.py`)
- Logging Setup → Secret Redaction: configures redaction (evidence: `src/boxlog/configure.py`)
- Logging Setup → Backend Factory: builds backend (evidence: `src/boxlog/configure.py`)
- Logging Setup → Standard Output: configures output (evidence: `README.md`)
- Python Application → Bound Context: binds fields (evidence: `README.md`)
- Python Application → Timed Steps: tracks work (evidence: `README.md`)
- Python Application → Request Middleware: adds middleware (evidence: `README.md`)
- Request Middleware → Bound Context: binds request ID (evidence: `src/boxlog/middleware.py`)
- Request Middleware → Python Logging: logs requests (evidence: `src/boxlog/middleware.py`)
- Format Records → Record Helpers: extracts fields (evidence: `src/boxlog/formatter.py`)
- Format Records → Bound Context: reads context (evidence: `src/boxlog/formatter.py`)
- Format Records → Secret Redaction: redacts values (evidence: `src/boxlog/formatter.py`)
- Async Shipper → Format Records: formats records (evidence: `src/boxlog/handler.py`)
- Async Shipper → Backend Protocol: appends batches (evidence: `src/boxlog/handler.py`)
- Backend Factory → Memory Store: creates backend (evidence: `src/boxlog/backends/__init__.py`)
- Backend Factory → SQLite Store: creates backend (evidence: `src/boxlog/backends/__init__.py`)
- Backend Factory → Redis Store: creates backend (evidence: `src/boxlog/backends/__init__.py`)
- Memory Store → Query Model: filters records (evidence: `src/boxlog/backends/memory.py`)
- SQLite Store → Query Model: filters records (evidence: `src/boxlog/backends/sqlite.py`)
- Redis Store → Query Model: filters records (evidence: `src/boxlog/backends/redis.py`)
- Log Viewer User → Viewer Interface: uses viewer (evidence: `README.md`)
- Viewer Interface → Viewer API: requests log data (evidence: `README.md`)
- Python Application → Viewer API: mounts viewer (evidence: `README.md`)
- Viewer CLI → Viewer API: serves standalone (evidence: `src/boxlog/cli.py`)
- Viewer API → Query Model: parses filters (evidence: `src/boxlog/viewer/__init__.py`)
- Viewer API → Backend Protocol: queries storage (evidence: `src/boxlog/viewer/__init__.py`)
