How gr1shma/notgit works
Project Type and Purpose
• This is a CLI-based version-control tool (“notgit”) implemented in Go.
• Purpose: Provide basic Git-like commands (init, add, commit, status, cat-file, config) using a local on-disk object store and index.
File Structure Analysis
Top-level:
• cmd/notgit/main.go — CLI entrypoint and argument parsing.
• internal/commands — handlers for each CLI command.
• internal/objects — domain objects (blob, tree, commit, generic object interface).
• internal/repository — repository abstraction: index management and object storage.
• internal/utils — helper routines (configuration, repo detection).
Architectural hints:
• “cmd” vs. “internal” separation: presentation layer vs. implementation.
• Domain model in internal/objects.
• Persistence layer in internal/repository.
• Utilities for cross-cutting concerns in internal/utils.
README Insights
• Minimal description: “git but worse.”
a. Main Components
1. CLI Interface (cmd/notgit)
2. Command Dispatcher & Handlers (internal/commands)
3. Domain Model (internal/objects)
4. Repository Layer (internal/repository)
– Index Manager
– Object Storage (on-disk)
5. Utilities (internal/utils)
6. File System (.notgit directory)
b. Component Relationships & Data Flows
• CLI Interface invokes → Command Dispatcher
• Command Dispatcher calls → Specific Command Handler
• Handler interacts with → Repository Layer (read/write index, store objects)
• Repository Layer uses → Domain Model to serialize/deserialize objects
• Domain Model uses → Utilities (e.g., config lookups, repo path discovery)
• Object Storage writes to → .notgit/objects; Index Manager writes to .notgit/index
c. Architectural Patterns & Principles
• Layered architecture: Presentation → Application → Domain → Infrastructure
• Separation of concerns: each command isolated in its own file/package
• Single Responsibility: blob/tree/commit types each handle their own serialization logic
• Dependency direction: higher-level packages depend on lower-level abstractions
d. Key Technologies & Frameworks
• Go modules (go.mod)
• Standard Go libraries for file I/O and CLI flag parsing
• Testing via _test.go files