# omkarlande/my-own-git architecture

> Architecture diagram of the GitHub repository omkarlande/my-own-git, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/omkarlande/my-own-git
- Repository: https://github.com/omkarlande/my-own-git

## Overview

Key Components to Include:

##### Command Layer
- Main entry point (cmd/mygit/main.go)
- Shell script interface (mygit.sh)

##### Core Operations
- Repository Initialization
- Blob Writing
- Blob Reading
- Tree Writing
- Tree Reading
- Commit Creation
- Repository Cloning

##### Storage Layer
- Object storage system
- .git directory structure that gets created
- Demonstrate blob storage mechanism

##### Use a top-down approach with these levels
**┌─────────────────────────┐**
- Command Interface    │ → mygit.sh and main.go
- ┬──────────────┘
- ↓
**┌─────────────────────────┐**
- Command Handlers     │ → init, hash-object, cat-file
- ┬──────────────┘
- ↓
**┌─────────────────────────┐**
- Core Operations     │ → Blob operations, future tree/commit ops
- ┬──────────────┘
- ↓
**┌─────────────────────────┐**
- Storage Layer        │ → .git directory and object storage
- ┘

##### Data Flow Representation
- How data moves from file input through blob creation
- Demonstrate the hash generation process
- Object storage and retrieval paths

##### Specific Elements
- Command parsing flow
- Object hashing mechanism
- Storage directory structure
- Content addressing system
- Future extension points

##### Technical Details
- Golang implementation notation
- SHA-1 hash usage
- File system interactions
- Content compression (if implemented)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef implemented fill:#90EE90,stroke:#333,stroke-width:2px
    classDef planned fill:#FFE4B5,stroke:#333,stroke-width:2px
    classDef storage fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef interface fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Command Interface Layer
    subgraph CommandInterface
        Shell["Shell Script Interface"]
        Main["Main Entry Point"]
        Config["Project Configuration"]
    end

    %% Command Handlers Layer
    subgraph CommandHandlers
        Init["Init Command"]:::implemented
        HashObject["Hash-Object Command"]:::implemented
        CatFile["Cat-File Command"]:::implemented
    end

    %% Core Operations Layer
    subgraph CoreOps
        RepoInit["Repository Initialization"]:::implemented
        BlobWrite["Blob Writing"]:::implemented
        BlobRead["Blob Reading"]:::implemented
        TreeWrite["Tree Writing"]:::planned
        TreeRead["Tree Reading"]:::planned
        CommitCreate["Commit Creation"]:::planned
        RepoClone["Repository Cloning"]:::planned
    end

    %% Storage Layer
    subgraph Storage
        GitDir[".git Directory"]:::storage
        ObjectStore["Object Storage"]:::storage
    end

    %% Connections
    Shell --> Main
    Main --> Init & HashObject & CatFile
    Init --> RepoInit
    HashObject --> BlobWrite
    CatFile --> BlobRead
    RepoInit --> GitDir
    BlobWrite & BlobRead --> ObjectStore
    TreeWrite & TreeRead --> ObjectStore
    CommitCreate --> ObjectStore
    GitDir --> ObjectStore

    %% Click events
    click Main "https://github.com/OmkarLande/my-own-git/blob/main/cmd/mygit/main.go"
    click Shell "https://github.com/OmkarLande/my-own-git/blob/main/mygit.sh"
    click Config "https://github.com/OmkarLande/my-own-git/blob/main/go.mod"

    %% Legend
    subgraph Legend
        L1["Implemented Feature"]:::implemented
        L2["Planned Feature"]:::planned
        L3["Storage Component"]:::storage
        L4["Interface Component"]:::interface
    end
```
