How soraiabarroso/my_redis_client works
Main Components
• CLI Front-End: This handles the two modes of operation – REPL (interactive) and Shell mode (single command execution). This is the user interface layer.
• Command Parser: Located in files like command_parser.hpp, this component interprets user input to build valid Redis commands.
• Redis Command Builder/Client: The client component (client.hpp and client.cpp) is responsible for establishing the TCP socket connection, sending the serialized commands to the Redis server, and handling the results.
• Redis Parser: With redis_parser.hpp and redis_parser.cpp, this part processes the responses from the Redis server, converting the raw RESP responses into a format that can be easily used or displayed.
• Configuration (if applicable): Look at the config_client.hpp to see if it sets up connection parameters or custom configurations needed to initialize the client correctly.
• Build & Configuration Support: Represent that the Makefile and project structure serve as the build and integration mechanism. Although not a runtime component, they provide context on how everything is assembled.
Relationships and Interactions
• The CLI front-end collects user input and passes it to the Command Parser.
• The Command Parser validates and transforms the command input into the appropriate protocol message.
• The Client component then uses this command to create and manage a TCP socket connection to the Redis server.
• After sending out the command, the response received by the Client is handed over to the Redis Parser to decode the RESP-serialized data.
• Processed responses are then sent back to the CLI front-end for display.
• Optionally, configuration settings (from the config component) influence how the client behaves (such as connecting to a specific Redis instance).
Architectural Patterns and Design Principles
• Separation of Concerns: Each component (CLI interface, command parsing, network communication, and response parsing) is separated into its own module.
• Layered Structure: Although it’s a simple application, visually separate the user interface layer from the network communication layer.
• Synchronous Request/Response Cycle: The system maintains a direct cycle from command input to command execution and response display.
Technologies and Libraries
• C++ Standard Libraries – for input/output operations, networking, and basic processing.
• Custom Parsing Implementations – as indicated by the command_parser and redis_parser files.
• TCP Socket programming – fundamental communication with the Redis server.