How varshney-yash/credis works
Main Components
• Server / Runner Component (app/runner.cpp, app/runner.h):
This is likely the entry point that initializes the server, handles incoming connections (i.e., via telnet), and dispatches commands.
• Command Resolution / Parser (strings/resolve.cpp, strings/resolve.h):
This module is responsible for parsing and resolving the commands (GET, SET, DELETE) from incoming client requests.
• Configuration Management (conf/config.cpp, conf/config.h):
This part manages configuration settings, potentially controlling server settings, and possibly snapshotting intervals or other DB parameters.
• Data Storage & Persistence:
Although there isn’t an explicit “database” directory, the in-memory DB core is implied in the server’s operations, and the persistence mechanism involves snapshotting to a file (snapshot.txt).
• Testing Component (tests/tests.cpp):
This part of the tree is used for unit or integration testing that verifies the DB operations, command parsing, and possibly the snapshotting functionality.
Relationships and Interactions
• Clients (telnet users) connect to the Server/Runner which listens for incoming requests.
• The Server passes incoming commands to the Command Resolver, where strings are parsed and translated into DB operations.
• The in-memory data structure (not explicitly shown but implicit in the implementation) handles GET, SET, and DELETE operations.
• There is a Persistence Subsystem that periodically writes the current state of the in-memory DB to snapshot.txt (every minute, as noted in the README).
• The Configuration Module sets up initial parameters (such as port number, snapshot interval, etc.) for the server.
• Unit tests under the tests/ directory ensure that these interactions and operations work as expected.
Architectural Patterns and Design Principles
• Layered Architecture: Separate layers for networking, command processing, configuration, in-memory data store, and persistence.
• Modular Design: Each major functionality (server, configuration, command resolution, testing) is encapsulated in its own module.
• Persistence Pattern: The snapshotting mechanism for periodic persistence implies a scheduled task or background thread interaction with the in-memory store.
Relevant Technologies, Frameworks, or Libraries
• C++ Standard libraries for networking (possibly external libraries or BSD sockets for telnet connectivity).
• Multi-threading (if snapshotting is run in a separate thread).
• Build System: Makefile for building the project.
• Testing: The tests directory indicates unit tests possibly using a simple test framework.
Elements
• “Client (Telnet)” indicating the external users.
• “Server/Runner Module (app/runner)” to show the main server process.
• “Command Resolver (strings/resolve)” to represent the parsing and command dispatch.
• “Configuration Manager (conf/config)” ensuring all settings are loaded.
• “In-Memory Database Core” to represent the data handling (even if not a separate module, conceptually include it).
• “Testing Suite” as a separate component for quality assurance.
• From “Client” to “Server/Runner” (incoming requests).
• From “Server” to “Command Resolver” (command handling).
• From “Command Resolver” to “In-Memory Database Core” (executing operations).
• From “In-Memory Database Core” to “Persistence Component” (for snapshotting).