# keith-cullen/freecoap architecture

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

- Interactive diagram: https://gitdiagram.com/keith-cullen/freecoap
- Repository: https://github.com/keith-cullen/freecoap

## Overview

FreeCoAP provides CoAP message, client, and server libraries plus an HTTP/CoAP proxy. The principal proxy path accepts an HTTP connection, parses and translates the request, exchanges it with a CoAP server, and returns an HTTP response. The graph preserves the protocol libraries and proxy support layers. Several implementation files are represented only by the source index; their internal behavior and some runtime links therefore remain unverified.

Main entry points: [`proxy/http_coap/src/connection.c`](https://github.com/keith-cullen/freecoap/blob/master/proxy/http_coap/src/connection.c) (HTTP connection), [`lib/src/coap_client.c`](https://github.com/keith-cullen/freecoap/blob/master/lib/src/coap_client.c) (CoAP client), [`lib/src/coap_server.c`](https://github.com/keith-cullen/freecoap/blob/master/lib/src/coap_server.c) (CoAP server), [`proxy/http_coap/src/listener.c`](https://github.com/keith-cullen/freecoap/blob/master/proxy/http_coap/src/listener.c) (TLS listener)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_coap["CoAP protocol"]
  node_client["CoAP client<br/>[coap_client.c]"]
  node_server["CoAP server<br/>[coap_server.c]"]
  node_message["Message codec<br/>[coap_msg.c]"]
  node_memory["Memory pools<br/>[coap_mem.c]"]
  node_logging["Logging<br/>[coap_log.c]"]
end

subgraph group_proxy["HTTP CoAP proxy"]
  node_listener["TLS listener<br/>[listener.c]"]
  node_connection["HTTP connection<br/>[connection.c]"]
  node_parameters["Proxy parameters<br/>[param.c]"]
  node_proxy_entry["Proxy application<br/>[proxy.c]"]
end

subgraph group_common["Proxy support"]
  node_http_codec["HTTP codec<br/>[http_msg.c]"]
  node_translation["Protocol translation<br/>[cross.c]"]
  node_uri["URI handling<br/>[uri.c]"]
  node_tls["TLS services<br/>[tls.c]"]
  node_tls_socket["TLS sockets<br/>[tls_sock.c]"]
  node_socket["Socket transport<br/>[sock.c]"]
  node_configuration["Configuration<br/>[config.c]"]
end

node_http_client(("HTTP client"))
node_coap_server_actor(("CoAP server peer"))

node_connection -->|"creates client"| node_client
node_connection -->|"translates request"| node_translation
node_connection -->|"uses parser"| node_http_codec
node_connection -->|"uses URI"| node_uri
node_http_client -.->|"opens connection"| node_listener
node_listener -->|"accepts connection"| node_connection
node_connection -.->|"sends CoAP request"| node_coap_server_actor
node_proxy_entry -->|"starts listener"| node_listener
node_proxy_entry -->|"loads settings"| node_parameters
node_proxy_entry -->|"initializes TLS"| node_tls
node_listener -->|"accepts TLS sockets"| node_tls_socket
node_tls_socket -->|"uses TLS"| node_tls
node_tls_socket -->|"uses sockets"| node_socket
node_client -->|"uses messages"| node_message
node_server -->|"uses messages"| node_message
node_message -->|"allocates buffers"| node_memory
node_client -->|"uses allocator"| node_memory
node_server -->|"uses allocator"| node_memory
node_client -->|"logs events"| node_logging
node_server -->|"logs events"| node_logging
node_translation -->|"uses URI"| node_uri
node_http_codec -.-> node_configuration
node_coap_server_actor -.->|"serves requests"| node_server

click node_client "https://github.com/keith-cullen/freecoap/blob/master/lib/src/coap_client.c"
click node_server "https://github.com/keith-cullen/freecoap/blob/master/lib/src/coap_server.c"
click node_message "https://github.com/keith-cullen/freecoap/blob/master/lib/src/coap_msg.c"
click node_memory "https://github.com/keith-cullen/freecoap/blob/master/lib/src/coap_mem.c"
click node_logging "https://github.com/keith-cullen/freecoap/blob/master/lib/src/coap_log.c"
click node_listener "https://github.com/keith-cullen/freecoap/blob/master/proxy/http_coap/src/listener.c"
click node_connection "https://github.com/keith-cullen/freecoap/blob/master/proxy/http_coap/src/connection.c"
click node_parameters "https://github.com/keith-cullen/freecoap/blob/master/proxy/http_coap/src/param.c"
click node_proxy_entry "https://github.com/keith-cullen/freecoap/blob/master/proxy/http_coap/src/proxy.c"
click node_http_codec "https://github.com/keith-cullen/freecoap/blob/master/proxy/common/src/http_msg.c"
click node_translation "https://github.com/keith-cullen/freecoap/blob/master/proxy/common/src/cross.c"
click node_uri "https://github.com/keith-cullen/freecoap/blob/master/proxy/common/src/uri.c"
click node_tls "https://github.com/keith-cullen/freecoap/blob/master/proxy/common/src/tls.c"
click node_tls_socket "https://github.com/keith-cullen/freecoap/blob/master/proxy/common/src/tls_sock.c"
click node_socket "https://github.com/keith-cullen/freecoap/blob/master/proxy/common/src/sock.c"
click node_configuration "https://github.com/keith-cullen/freecoap/blob/master/proxy/common/src/config.c"

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_client,node_server,node_message,node_memory,node_logging,node_http_client toneBlue
class node_listener,node_connection,node_parameters,node_proxy_entry toneAmber
class node_http_codec,node_translation,node_uri,node_tls,node_tls_socket,node_socket,node_configuration,node_coap_server_actor toneMint
```

## Components

### CoAP protocol

- [CoAP client](https://github.com/keith-cullen/freecoap/blob/master/lib/src/coap_client.c): `lib/src/coap_client.c`
- [CoAP server](https://github.com/keith-cullen/freecoap/blob/master/lib/src/coap_server.c): `lib/src/coap_server.c`
- [Message codec](https://github.com/keith-cullen/freecoap/blob/master/lib/src/coap_msg.c): `lib/src/coap_msg.c`
- [Memory pools](https://github.com/keith-cullen/freecoap/blob/master/lib/src/coap_mem.c): `lib/src/coap_mem.c`
- [Logging](https://github.com/keith-cullen/freecoap/blob/master/lib/src/coap_log.c): `lib/src/coap_log.c`

### HTTP CoAP proxy

- [TLS listener](https://github.com/keith-cullen/freecoap/blob/master/proxy/http_coap/src/listener.c): `proxy/http_coap/src/listener.c`
- [HTTP connection](https://github.com/keith-cullen/freecoap/blob/master/proxy/http_coap/src/connection.c): `proxy/http_coap/src/connection.c`
- [Proxy parameters](https://github.com/keith-cullen/freecoap/blob/master/proxy/http_coap/src/param.c): `proxy/http_coap/src/param.c`
- [Proxy application](https://github.com/keith-cullen/freecoap/blob/master/proxy/http_coap/src/proxy.c): `proxy/http_coap/src/proxy.c`

### Proxy support

- [HTTP codec](https://github.com/keith-cullen/freecoap/blob/master/proxy/common/src/http_msg.c): `proxy/common/src/http_msg.c`
- [Protocol translation](https://github.com/keith-cullen/freecoap/blob/master/proxy/common/src/cross.c): `proxy/common/src/cross.c`
- [URI handling](https://github.com/keith-cullen/freecoap/blob/master/proxy/common/src/uri.c): `proxy/common/src/uri.c`
- [TLS services](https://github.com/keith-cullen/freecoap/blob/master/proxy/common/src/tls.c): `proxy/common/src/tls.c`
- [TLS sockets](https://github.com/keith-cullen/freecoap/blob/master/proxy/common/src/tls_sock.c): `proxy/common/src/tls_sock.c`
- [Socket transport](https://github.com/keith-cullen/freecoap/blob/master/proxy/common/src/sock.c): `proxy/common/src/sock.c`
- [Configuration](https://github.com/keith-cullen/freecoap/blob/master/proxy/common/src/config.c): `proxy/common/src/config.c`

### Other components

- **HTTP client**
- **CoAP server peer**

## Connections

- HTTP connection → CoAP client: creates client (evidence: `proxy/http_coap/src/connection.c`)
- HTTP connection → Protocol translation: translates request (evidence: `proxy/http_coap/src/connection.c`)
- HTTP connection → HTTP codec: uses parser (evidence: `proxy/http_coap/src/connection.c`)
- HTTP connection → URI handling: uses URI (evidence: `proxy/http_coap/src/connection.c`)
- HTTP client → TLS listener: opens connection
- TLS listener → HTTP connection: accepts connection (evidence: `proxy/http_coap/src/listener.c`)
- HTTP connection → CoAP server peer: sends CoAP request
- Proxy application → TLS listener: starts listener (evidence: `proxy/http_coap/src/proxy.c`)
- Proxy application → Proxy parameters: loads settings (evidence: `proxy/http_coap/src/proxy.c`)
- Proxy application → TLS services: initializes TLS (evidence: `proxy/http_coap/src/proxy.c`)
- TLS listener → TLS sockets: accepts TLS sockets (evidence: `proxy/http_coap/src/listener.c`)
- TLS sockets → TLS services: uses TLS
- TLS sockets → Socket transport: uses sockets
- CoAP client → Message codec: uses messages
- CoAP server → Message codec: uses messages
- Message codec → Memory pools: allocates buffers (evidence: `lib/src/coap_msg.c`)
- CoAP client → Memory pools: uses allocator (evidence: `lib/src/coap_client.c`)
- CoAP server → Memory pools: uses allocator (evidence: `lib/src/coap_server.c`)
- CoAP client → Logging: logs events (evidence: `lib/src/coap_client.c`)
- CoAP server → Logging: logs events (evidence: `lib/src/coap_server.c`)
- Protocol translation → URI handling: uses URI (evidence: `proxy/common/src/cross.c`)
- HTTP codec → Configuration
- CoAP server peer → CoAP server: serves requests
