We have built a simple version control systems using the first principle and optimization concepts in Data Structures and Algorithms. The system is built with cpp as core code
The VCS framework has three core components:
-
Branch Management:
- this file tracks individual branches, each with its own set of commits.
-
Commit Management:
- this file records changes and their descriptions as commits associated with a branch.
-
Linked List Storage:
- this uses a linked list to store and manage branches.
This file defines how a branch works and how commits are stored and managed.
Key Elements:
- Commit: A small structure to hold a commit's message and its associated data.
- Branch: A class to manage:
- Branch name
- List of commits
- Actions like making a commit, viewing commit logs, and reverting commits
This file implements a simple linked list to hold all branches.
Key Elements:
- Node: A single unit in the linked list holding a branch and a pointer to the next node.
- LinkedList: A class to manage:
- Inserting nodes at the front or end
- Traversing and managing branch nodes
This is the core file where all the logic comes together. It handles:
- Command-line inputs
- Core functionality like initializing the VCS, creating/switching branches, making/reverting commits, and displaying commit logs
- Acts as the interface between the user and the underlying system
project/
├── Branch.h # Contains the Branch class and Commit struct.
├── LinkedList.h # Defines a generic LinkedList template class.
├── main.cpp # Entry point for the program and user interface logic.
├── README.md # Documentation for the project.- A C++ compiler (e.g., g++, clang++)
- Familiarity with running terminal commands
-
Clone the repository:
git clone <repository-url> cd project
-
Compile the project:
g++-std=c++11 -o vcs main.cpp
-
Run the executable:
./vcs
-
Use the on-screen prompts to explore commands and features.
> vcsInit
VCS initialized with default branch: master.
> makeCommit
Enter commit message: Initial commit
Enter file data: Added README and project setup.
Commit added.
> createBranch featureX
Branch created: featureX.
> switchBranch featureX
Switched to branch: featureX.
> viewCommits
Commit log for branch 'featureX':
1. Initial commit: Added README and project setup.
> revertCommit 1
Commit 1 reverted.
- Task: Adding commands to push and pull changes using a database and server setup.
- Failed Attempt: Tried deploying the server with Cloudflare, but issues like synchronization and latency prevented stable operations.
- Task: Converting the project into an npm package for wider adoption by users.
- Roadblocks: Compatibility issues between C++ backend logic and JavaScript.
- ToDo: Containerize the VCS system using Docker for platform independence.
- +: Enables the project to run seamlessly on any machine with Docker installed.
ToDo: we can use AI agentic framework to provide:
- Suggestions for commit messages
- Automatic detection of errors in commits
- Resolution of PR (Pull Request) conflicts
- can further optimize this to other tasks, if needed
Failed Attempt: we have implemented a reAct agentic framework architecture in C++ (with minimal Python), but debugging complexities led to delays.