# minhcreator/nvim_from_scratch architecture

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

- Interactive diagram: https://gitdiagram.com/minhcreator/nvim_from_scratch
- Repository: https://github.com/minhcreator/nvim_from_scratch

## Overview

##### Project type and purpose
- This is a customized Neovim configuration repository (“dotfiles”) written in Lua.
- It leverages the Lazy plugin manager to declare and load a suite of plugins, centralizes configuration in modular files, and provides user-override hooks.

##### File structure
- Top-level:
- init.lua: the Neovim entrypoint that bootstraps the configuration
- lazy-lock.json: pins versions for Lazy plugin manager
- snippets/: JSON snippet definitions for editor completions
- lua/: contains all Lua modules
- autocmds.lua, custom-cmd.lua, keyBinding.lua, options.lua: core Neovim API glue
- chadrc.lua: “framework” initializer—sets up Lazy and default behavior
- plugins/: plugin declarations (which plugins to install, with minimal inline config)
- userConfigs/: override layers for end-user tweaks to default plugin configs

##### Main components & their relationships
a. Neovim Core
– The running application, exposes API to Lua modules.
b. Bootstrap Layer
– init.lua calls chadrc.lua.
– chadrc.lua invokes Lazy (lazy.nvim) to:
- Read plugin declarations from lua/plugins/
- Resolve dependencies, version constraints (lazy-lock.json)
c. Configuration Layer
– After plugin load, Lazy triggers config callbacks in lua/configs/
– Plugins get configured (e.g., treesitter, telescope, lualine)
d. User Override Layer
– lua/userConfigs/: loaded after defaults, allows overriding plugin settings
e. Core Glue
– autocmds.lua: autocommands for filetype, events
– custom-cmd.lua: user-defined Ex commands
– keyBinding.lua: global keymaps
– options.lua: Neovim built-in options (clipboard, line numbers, etc.)
f. Snippet Engine
– snippets/*.json: definitions consumed by completion plugin (cmp, luasnip, etc.)

##### Architectural patterns & design principles
- Modular layering: bootstrap → plugin declaration → default config → user overrides
- Inversion of control: Lazy orchestrates plugin loading and config callbacks
- Separation of concerns:
- Declaration (lua/plugins) vs configuration (lua/configs) vs overrides (lua/userConfigs)
- Core API glue (autocmds, keymaps) isolated from plugin logic

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Runtime Host
    Neovim["Neovim"]:::runtime

    %% Bootstrap Layer
    init["init.lua"]:::bootstrap
    chadrc["chadrc.lua"]:::bootstrap
    lazy["Lazy Plugin Manager"]:::bootstrap
    lock["lazy-lock.json"]:::bootstrap

    Neovim -->|"startup"| init
    init -->|"calls"| chadrc
    chadrc -->|"invokes"| lazy
    lazy -.->|"pins versions"| lock

    click init "https://github.com/minhcreator/nvim_from_scratch/blob/main/init.lua"
    click chadrc "https://github.com/minhcreator/nvim_from_scratch/blob/main/lua/chadrc.lua"
    click lock "https://github.com/minhcreator/nvim_from_scratch/blob/main/lazy-lock.json"

    %% Plugin Declaration Layer
    subgraph "Plugin Declarations" 
        direction TB
        pluginsDir["lua/plugins/*"]:::declaration
    end
    lazy -->|"reads declarations"| pluginsDir
    click pluginsDir "https://github.com/minhcreator/nvim_from_scratch/tree/main/lua/plugins/"

    %% Default Configuration Layer
    subgraph "Default Plugin Configurations"
        direction TB
        configsDir["lua/configs/*"]:::config
    end
    lazy -->|"triggers config callbacks"| configsDir
    click configsDir "https://github.com/minhcreator/nvim_from_scratch/tree/main/lua/configs/"

    %% User Override Layer
    subgraph "User Overrides"
        direction TB
        overridesDir["lua/userConfigs/*"]:::override
    end
    configsDir -->|"loaded after defaults"| overridesDir
    click overridesDir "https://github.com/minhcreator/nvim_from_scratch/tree/main/lua/userConfigs/"

    %% Core Glue Modules
    subgraph "Core Glue"
        direction TB
        options["options.lua"]:::core
        keybinds["keyBinding.lua"]:::core
        autocmds["autocmds.lua"]:::core
        customcmd["custom-cmd.lua"]:::core
    end
    init -->|"loads"| options
    init -->|"loads"| keybinds
    init -->|"loads"| autocmds
    init -->|"loads"| customcmd

    click options "https://github.com/minhcreator/nvim_from_scratch/blob/main/lua/options.lua"
    click keybinds "https://github.com/minhcreator/nvim_from_scratch/blob/main/lua/keyBinding.lua"
    click autocmds "https://github.com/minhcreator/nvim_from_scratch/blob/main/lua/autocmds.lua"
    click customcmd "https://github.com/minhcreator/nvim_from_scratch/blob/main/lua/custom-cmd.lua"

    %% Snippet Engine
    subgraph "Snippets" 
        direction TB
        snippets["snippets/*.json"]:::external
    end
    snippets -->|"consumed by completion plugin"| lazy
    click snippets "https://github.com/minhcreator/nvim_from_scratch/tree/main/snippets/"

    %% External Services
    subgraph "External Service"
        direction TB
        lsp["Language Servers"]:::external
    end
    lazy -->|"manages via mason & lspconfig"| lsp

    %% Styles
    classDef runtime fill:#f9f,stroke:#333,stroke-width:1px;
    classDef bootstrap fill:#bbf,stroke:#333,stroke-width:1px;
    classDef declaration fill:#bfb,stroke:#333,stroke-width:1px;
    classDef config fill:#ffb,stroke:#333,stroke-width:1px;
    classDef override fill:#fbf,stroke:#333,stroke-width:1px;
    classDef core fill:#ffd,stroke:#333,stroke-width:1px;
    classDef external fill:#eee,stroke-dasharray: 5 5,stroke:#333;
```
