# geniusdai/cppev architecture

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

- Interactive diagram: https://gitdiagram.com/geniusdai/cppev
- Repository: https://github.com/geniusdai/cppev

## Overview

Cppev is a C++ asynchronous I/O and concurrency library. Its principal server workflow configures and starts a TCP server, accepts connections, registers sockets with event loops, and invokes user callbacks as I/O events occur. The README also documents standalone disk/pipe/socket I/O, UDP, synchronization, IPC, subprocess, and runtime dynamic-library loading. Source excerpts clarify parts of the I/O and TCP reactor; other subsystem links reflect documented capabilities and file-tree paths, not inspected call paths.

Main entry points: [`src/lib/event_loop_common.cc`](https://github.com/geniusdai/cppev/blob/dev/src/lib/event_loop_common.cc) (Event loop), [`src/lib/tcp.cc`](https://github.com/geniusdai/cppev/blob/dev/src/lib/tcp.cc) (Socket event handler), [`src/lib/io.cc`](https://github.com/geniusdai/cppev/blob/dev/src/lib/io.cc) (File and socket I/O), [`src/lib/event_loop_epoll.cc`](https://github.com/geniusdai/cppev/blob/dev/src/lib/event_loop_epoll.cc) (OS event pollers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_io["I/O and reactor"]
  node_tcp["TCP server/client<br/>[tcp.cc]"]
  node_acceptor["Connection acceptor<br/>[tcp.cc]"]
  node_iohandler["Socket event handler<br/>[tcp.cc]"]
  node_eventloop["Event loop"]
  node_pollers["OS event pollers"]
  node_ioapi["File and socket I/O<br/>[io.cc]"]
  node_buffer["I/O buffers<br/>[buffer.h]"]
end

subgraph group_concurrency["Concurrency and synchronization"]
  node_threads["Thread pool<br/>[thread_pool.cc]"]
  node_runnable["Runnable threads<br/>[runnable.cc]"]
  node_scheduler["Scheduler"]
  node_locks["Synchronization primitives<br/>[lock.cc]"]
  node_ipc["Shared memory and semaphores<br/>[ipc.cc]"]
end

subgraph group_process["Processes and loading"]
  node_subprocess["Subprocess execution<br/>[subprocess.cc]"]
  node_loader["Dynamic loader<br/>[dynamic_loader.cc]"]
end

subgraph group_support["Library support"]
  node_logger["Logging<br/>[logger.cc]"]
  node_utils["Common utilities<br/>[utils.cc]"]
end

node_user(("Library user"))
node_os(("Operating system"))

node_user -->|"configures and starts"| node_tcp
node_tcp -->|"starts acceptors"| node_acceptor
node_tcp -->|"runs I/O workers"| node_threads
node_acceptor -->|"monitors listeners"| node_eventloop
node_acceptor -->|"registers connections"| node_iohandler
node_iohandler -->|"registers sockets"| node_eventloop
node_eventloop -->|"waits for events"| node_pollers
node_pollers -->|"returns ready events"| node_eventloop
node_eventloop -->|"dispatches callbacks"| node_iohandler
node_iohandler -->|"reads and writes"| node_ioapi
node_ioapi -->|"uses buffers"| node_buffer
node_user -->|"uses I/O"| node_ioapi
node_user -->|"schedules work"| node_scheduler
node_user -->|"runs threads"| node_runnable
node_user -->|"synchronizes"| node_locks
node_user -->|"uses IPC"| node_ipc
node_user -->|"launches processes"| node_subprocess
node_user -->|"loads libraries"| node_loader
node_ioapi -->|"performs system I/O"| node_os
node_locks -->|"uses pthread primitives"| node_os
node_ipc -->|"uses IPC facilities"| node_os
node_subprocess -->|"creates processes"| node_os
node_loader -->|"loads binaries"| node_os

click node_tcp "https://github.com/geniusdai/cppev/blob/dev/src/lib/tcp.cc"
click node_acceptor "https://github.com/geniusdai/cppev/blob/dev/src/lib/tcp.cc"
click node_iohandler "https://github.com/geniusdai/cppev/blob/dev/src/lib/tcp.cc"
click node_eventloop "https://github.com/geniusdai/cppev/blob/dev/src/lib/event_loop_common.cc"
click node_pollers "https://github.com/geniusdai/cppev/blob/dev/src/lib/event_loop_epoll.cc"
click node_ioapi "https://github.com/geniusdai/cppev/blob/dev/src/lib/io.cc"
click node_buffer "https://github.com/geniusdai/cppev/blob/dev/src/include/cppev/buffer.h"
click node_threads "https://github.com/geniusdai/cppev/blob/dev/src/lib/thread_pool.cc"
click node_runnable "https://github.com/geniusdai/cppev/blob/dev/src/lib/runnable.cc"
click node_locks "https://github.com/geniusdai/cppev/blob/dev/src/lib/lock.cc"
click node_ipc "https://github.com/geniusdai/cppev/blob/dev/src/lib/ipc.cc"
click node_subprocess "https://github.com/geniusdai/cppev/blob/dev/src/lib/subprocess.cc"
click node_loader "https://github.com/geniusdai/cppev/blob/dev/src/lib/dynamic_loader.cc"
click node_logger "https://github.com/geniusdai/cppev/blob/dev/src/lib/logger.cc"
click node_utils "https://github.com/geniusdai/cppev/blob/dev/src/lib/utils.cc"

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_tcp,node_acceptor,node_iohandler,node_eventloop,node_pollers,node_ioapi,node_buffer,node_user toneBlue
class node_threads,node_runnable,node_scheduler,node_locks,node_ipc toneAmber
class node_subprocess,node_loader toneMint
class node_logger,node_utils toneRose
class node_os toneIndigo
```

## Components

### I/O and reactor

- [TCP server/client](https://github.com/geniusdai/cppev/blob/dev/src/lib/tcp.cc): `src/lib/tcp.cc`
- [Connection acceptor](https://github.com/geniusdai/cppev/blob/dev/src/lib/tcp.cc): `src/lib/tcp.cc`
- [Socket event handler](https://github.com/geniusdai/cppev/blob/dev/src/lib/tcp.cc): `src/lib/tcp.cc`
- [Event loop](https://github.com/geniusdai/cppev/blob/dev/src/lib/event_loop_common.cc): `src/lib/event_loop_common.cc`
- [OS event pollers](https://github.com/geniusdai/cppev/blob/dev/src/lib/event_loop_epoll.cc): `src/lib/event_loop_epoll.cc`
- [File and socket I/O](https://github.com/geniusdai/cppev/blob/dev/src/lib/io.cc): `src/lib/io.cc`
- [I/O buffers](https://github.com/geniusdai/cppev/blob/dev/src/include/cppev/buffer.h): `src/include/cppev/buffer.h`

### Concurrency and synchronization

- [Thread pool](https://github.com/geniusdai/cppev/blob/dev/src/lib/thread_pool.cc): `src/lib/thread_pool.cc`
- [Runnable threads](https://github.com/geniusdai/cppev/blob/dev/src/lib/runnable.cc): `src/lib/runnable.cc`
- **Scheduler**
- [Synchronization primitives](https://github.com/geniusdai/cppev/blob/dev/src/lib/lock.cc): `src/lib/lock.cc`
- [Shared memory and semaphores](https://github.com/geniusdai/cppev/blob/dev/src/lib/ipc.cc): `src/lib/ipc.cc`

### Processes and loading

- [Subprocess execution](https://github.com/geniusdai/cppev/blob/dev/src/lib/subprocess.cc): `src/lib/subprocess.cc`
- [Dynamic loader](https://github.com/geniusdai/cppev/blob/dev/src/lib/dynamic_loader.cc): `src/lib/dynamic_loader.cc`

### Library support

- [Logging](https://github.com/geniusdai/cppev/blob/dev/src/lib/logger.cc): `src/lib/logger.cc`
- [Common utilities](https://github.com/geniusdai/cppev/blob/dev/src/lib/utils.cc): `src/lib/utils.cc`

### Other components

- **Library user**
- **Operating system**

## Connections

- Library user → TCP server/client: configures and starts
- TCP server/client → Connection acceptor: starts acceptors
- TCP server/client → Thread pool: runs I/O workers
- Connection acceptor → Event loop: monitors listeners
- Connection acceptor → Socket event handler: registers connections
- Socket event handler → Event loop: registers sockets
- Event loop → OS event pollers: waits for events
- OS event pollers → Event loop: returns ready events
- Event loop → Socket event handler: dispatches callbacks
- Socket event handler → File and socket I/O: reads and writes
- File and socket I/O → I/O buffers: uses buffers
- Library user → File and socket I/O: uses I/O
- Library user → Scheduler: schedules work
- Library user → Runnable threads: runs threads
- Library user → Synchronization primitives: synchronizes
- Library user → Shared memory and semaphores: uses IPC
- Library user → Subprocess execution: launches processes
- Library user → Dynamic loader: loads libraries
- File and socket I/O → Operating system: performs system I/O
- Synchronization primitives → Operating system: uses pthread primitives
- Shared memory and semaphores → Operating system: uses IPC facilities
- Subprocess execution → Operating system: creates processes
- Dynamic loader → Operating system: loads binaries
