How guille-ux/tinrux works
Project type and purpose
• Tinrux is a lightweight, Redis-inspired database written in pure Python.
• It runs as a standalone service with a server–client architecture and exposes a CLI and Python client interface.
• Purpose: simple key–value persistence in JSON, small-scale apps, auto-saving, cookie-based session management.
File structure
• Top-level: packaging files (pyproject.toml, README.md, LICENSE.txt), distribution artifacts (dist/), a sample data file (tdb.json), and tests/.
• src/tinrux: four main modules plus metadata:
• cli.py – command-line interface entry point
• tinruxClient.py – manages socket connection from client side
• tinruxServer.py – core server engine: networking listener, command dispatch, in-memory store
• tinrux_cookies.py – cookie/session management logic
• __init__.py & __about__.py – package initialization and version info
• tests/ holds unit tests covering server and client functionality.
Extract additional insights from the README
• Server listens on host:port, supports commands (SET, GET, DEL, EXPIRE, SAVE, HELP).
• Auto-persistence: a timer triggers JSON dumps (tdb.json).
• Zero external dependencies: uses standard library (socket, threading, json).
• Modes: interactive client (CLI), programmatic client, standalone server.
Main components and their relationships
a. Client layer
• CLI driver (cli.py)
• Programmatic client API (tinruxClient.py)
→ Establishes TCP socket to the server
b. Server layer
• Network listener & request dispatcher (tinruxServer.py)
• Command interpreter & in-memory key-value store
• Cookie manager (tinrux_cookies.py) for sessions and auth
• Autosave scheduler (background thread)
→ Writes and reads JSON persistence file (tdb.json)
c. Persistence
• JSON file store (tdb.json)
– Handled via Python’s json module
d. Support
• Packaging and distribution (pyproject.toml, dist/)
• Testing framework (tests/)
Architectural patterns and design principles
• Client–server over TCP sockets
• Command pattern: each text command maps to a handler method
• Separation of concerns: network I/O vs. in-memory storage vs. persistence vs. session management
• Single-threaded request handling with background thread for auto-saving
• Extensible command set via modular handlers in tinruxServer.py