Skip to content

Itzudii/CortexFS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

  • control flow diagram App Screenshot

๐Ÿ“‚ Cortex FS โ€“ Intelligent File System Manager

A multi-threaded and multi-process based File System Manager designed to handle:

  • File operations
  • CLI commands
  • Background tasks
  • Vector indexing
  • Tag generation
  • Logging
  • Frontend + API interaction
  • The system is built for scalability, modularity, and asynchronous task execution.

๐Ÿ—๏ธ Architecture Overview

The project is divided into:

  • Main Thread (Main Processor)
  • Worker Thread
  • Separate Tag Generation Process
  • Frontend + API Layer
  • Logging & OS Watcher Service

It uses:

  • Multithreading (for task execution)

  • Multiprocessing (for heavy operations like tag generation)

  • Queue-based communication

  • Persistent storage (database + vector storage)

๐Ÿ”ท High-Level Flow

OS Events โ†’ Watcher โ†’ Log Manager โ†’ Controller

โ†“

Frontend โ†’ API โ†’ Controller โ†’ Task Scheduler

โ†“

Task Handler

โ†“

FS Manager

โ†“

Storage / Index / Vector / Tag Generation Process

๐Ÿง  Core Components Explained

1๏ธโƒฃ Main Thread (Main Processor)

This is the brain of the application.

Responsibilities:

  • Initialize all services

  • Handle API requests

  • Coordinate tasks

  • Manage communication between threads and processes

2๏ธโƒฃ Startup Loader

Responsibilities:

Load File System

Load CLI

Initialize Worker Thread

Initialize Tag Generation Process

This ensures everything is ready before user interaction begins.

3๏ธโƒฃ Watcher (Background Service)

Monitors OS-level file events.

Listens For:

  • File creation

  • File deletion

  • File modification

Output:

  • Writes events to: -> active.log

  • This is later consumed by the Log Manager.

4๏ธโƒฃ Log Manager

Responsibilities:

  • Read active.log

  • Parse system events

  • Send structured events to Controller

  • This allows automatic file system updates.

5๏ธโƒฃ API Layer

it is a pywebview layer

** Acts as a bridge between: **

Frontend โ†” Controller

Handles:

  • HTTP Requests

  • Response formatting

  • Data validation

6๏ธโƒฃ Controller

The central coordinator.

Responsibilities:

  • Receive input from: API

  • Log Manager

  • Forward tasks to:

  • Task Scheduler

  • Manage process communication

  • This component ensures clean separation of concerns.

๐Ÿ” Worker Thread

  • Queue checking and db write done by worker tread

7๏ธโƒฃ Task Scheduler

Responsibilities:

  • Queue incoming tasks

  • Distribute tasks to:

  • Task Handler

  • Background Executor

Ensures:

  • Non-blocking execution

  • Organized processing

8๏ธโƒฃ Task Handler

  • Executes structured tasks by:

  • forwards work to:

  • Task Performer

  • CLI Performer

9๏ธโƒฃ Task Performer

Handles:

  • Core FS operations

  • Data updates

  • Storage updates request sends

๐Ÿ”Ÿ CLI Performer

Executes CLI-based commands separately from API-based commands.

This separation allows:

  • Dual interface support (CLI + Web)

๐Ÿ—‚๏ธ FSManager (Core Engine)

The heart of file system logic.

Responsibilities:

  • Maintain file tree

  • Coordinate indexing

  • Communicate with:

  • Vector Engine

  • Storage Layer

  • Tag Generation Process

๐Ÿ“Š Vector Engine (MRVector)

Handles:

  • Vector generation

  • Embeddings

  • Similarity search

  • Advanced search capabilities

Used for:

  • Intelligent file retrieval

  • Content-based searching

๐Ÿ’พ Indexer / Storage

Persists data in:

  • database/index.db

Stores:

  • File metadata

  • Index mappings

  • Searchable structure

Search Techniques

Prifix Search

  • root -> DB
  • subtree -> memory (tree)
  • parent -> memory (tree)

Extension Search

  • root -> dictionary
  • subtree -> dictionary + memory (tree)
  • parent -> memory (tree)

Context Search

  • root -> DB
  • subtree -> DB
  • parent -> DB

๐Ÿงฉ Separate Tag Generation Process

Runs in a completely different process (not thread).

Why separate process?

  • Tag generation is CPU-intensive

  • Avoid blocking main system

  • Better scalability

Communication:

  • Uses a Multiprocessing Queue

  • FSManager โ†’ Queue โ†’ Tag Generation Process

๐ŸŽจ Frontend

Provides:

  • HTML

  • CSS

  • JS

Communicates with backend using API request/response model.

๐Ÿ“ Data Flow Example

  • control flow diagram App Screenshot

๐Ÿ” Design Principles

  • Modular architecture

  • Separation of concerns

  • Asynchronous execution

  • Scalable processing

  • Clean layered structure

๐Ÿš€ Key Features

โœ… Real-time file monitoring

โœ… Vector-based intelligent search

โœ… Tag auto-generation

โœ… CLI + Web Interface

โœ… Multi-threaded task processing

โœ… Multi-process heavy computation

โœ… Persistent indexed storage

๐Ÿ“ฆ Project Structure (Conceptual)

FS/
โ”‚
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ css/
โ”‚   โ”‚   โ”œโ”€โ”€ app_container_and_webkit.css
โ”‚   โ”‚   โ”œโ”€โ”€ background_particle.css
โ”‚   โ”‚   โ”œโ”€โ”€ body.css
โ”‚   โ”‚   โ”œโ”€โ”€ cli.css
โ”‚   โ”‚   โ”œโ”€โ”€ context_menu.css
โ”‚   โ”‚   โ”œโ”€โ”€ details_panel.css
โ”‚   โ”‚   โ”œโ”€โ”€ global.css
โ”‚   โ”‚   โ”œโ”€โ”€ grid_and_list_view.css
โ”‚   โ”‚   โ”œโ”€โ”€ menu_bar.css
โ”‚   โ”‚   โ”œโ”€โ”€ rename-styles.css
โ”‚   โ”‚   โ”œโ”€โ”€ responsive.css
โ”‚   โ”‚   โ”œโ”€โ”€ root.css
โ”‚   โ”‚   โ”œโ”€โ”€ side_bar.css
โ”‚   โ”‚   โ”œโ”€โ”€ title_bar.css
โ”‚   โ”‚   โ””โ”€โ”€ tool_bar.css
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ font/
โ”‚   โ”‚   โ”œโ”€โ”€ font.woff2
โ”‚   โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ img/
โ”‚   โ”‚   โ”œโ”€โ”€ logo_transparent.png
โ”‚   โ”‚   โ””โ”€โ”€ logo.jpeg
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ js/
โ”‚   โ”‚   โ”œโ”€โ”€ cli.js
โ”‚   โ”‚   โ”œโ”€โ”€ rename-functionality.js
โ”‚   โ”‚   โ”œโ”€โ”€ script-main.js
โ”‚   โ”‚   โ”œโ”€โ”€ script.js
โ”‚   โ”‚   โ””โ”€โ”€ search.js
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ cli.html
โ”‚   โ”œโ”€โ”€ file-search.html
โ”‚   โ””โ”€โ”€ main-window.html
โ”‚
โ”œโ”€โ”€ .database/
โ”‚   โ””โ”€โ”€ index.db
โ”‚
โ”œโ”€โ”€ .save/
โ”‚
โ”œโ”€โ”€ logs/
โ”‚   โ”œโ”€โ”€ error.log
โ”‚   โ””โ”€โ”€ debug.log
โ”‚
โ”œโ”€โ”€ Chatbot/
โ”‚    โ”œโ”€โ”€ bot.py
โ”‚    โ””โ”€โ”€ mpc.py
โ”‚
โ”œโ”€โ”€ watcher/
โ”‚    โ”œโ”€โ”€ logs/
โ”‚    โ”‚   โ””โ”€โ”€ active.log
โ”‚    โ”œโ”€โ”€ config.py
โ”‚    โ”œโ”€โ”€ event_logger.py
โ”‚    โ”œโ”€โ”€ fs_startup_sync.py
โ”‚    โ”œโ”€โ”€ internal_tree.py
โ”‚    โ”œโ”€โ”€ watcher_service.py
โ”‚    โ””โ”€โ”€ run_watcher.bat
โ”‚
โ”œโ”€โ”€ dependencies/
โ”‚    โ”œโ”€โ”€ dict.py
โ”‚    โ”œโ”€โ”€ fileReader.py
โ”‚    โ”œโ”€โ”€ helperfuncUtils.py
โ”‚    โ”œโ”€โ”€ icon.py
โ”‚    โ”œโ”€โ”€ logmanager.py
โ”‚    โ””โ”€โ”€ log_config.py
โ”‚    โ””โ”€โ”€ stack.py
โ”‚    โ””โ”€โ”€ storage.py
โ”‚    โ””โ”€โ”€ tree.py
โ”‚    โ””โ”€โ”€ vector.py
โ”‚
โ”œโ”€โ”€ Scaffold/
โ”‚    โ”œโ”€โ”€ parser.py
โ”‚
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ requirements.txt
โ”‚
โ””โ”€โ”€ model/
    โ”‚
    โ”œโ”€โ”€ all-MiniLM-L6-v2/
    โ”‚   โ”œโ”€โ”€ 1_Pooling/
    โ”‚   โ”œโ”€โ”€ 2_Normalize/
    โ”‚   โ”œโ”€โ”€ config_sentence_transformers.json
    โ”‚   โ”œโ”€โ”€ config.json
    โ”‚   โ”œโ”€โ”€ model.safetensors
    โ”‚   โ”œโ”€โ”€ modules.json
    โ”‚   โ”œโ”€โ”€ README.md
    โ”‚   โ”œโ”€โ”€ sentence_bert_config.json
    โ”‚   โ”œโ”€โ”€ special_tokens_map.json
    โ”‚   โ”œโ”€โ”€ tokenizer_config.json
    โ”‚   โ”œโ”€โ”€ tokenizer.json
    โ”‚   โ””โ”€โ”€ vocab.txt
    โ”‚
    โ”œโ”€โ”€ llama-2-7b-chat.Q4_K_M.gguf
    โ””โ”€โ”€ qwen2.5-1.5b-instruct-q8_0.gguf
 

๐Ÿ”ฎ Future Improvements

  • Distributed processing

  • Cloud storage integration

  • Advanced AI-based tagging

  • Caching layer (Redis)

  • WebSocket real-time updates

  • Recycle bin

Note: execute watcher.py in seperate terminal work as background process

About

AI-enhanced file indexing and semantic search engine powered by local LLMs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors