Git Product home page Git Product logo

1brc-electron's Introduction

1 Billion Row Challenge with Electron, DuckDB, Prompts, Cursor and Aider

Progressing our Agentic engineering abilities by building a 1 billion row challenge app with Electron, DuckDB, Prompts, Cursor and Aider

1brc

Checkout the video where we built this

Setup

  • brew install duckdb (mac see docs for other platforms)
  • yarn install
  • cp .env.sample .env - Update the .env file with your openai key
  • yarn run generate <number of rows> - Generate the data (optional)
    • 'The git committed data/measurements.txt contains 1 million rows you can use without running this command'
    • 'I recommend generating 1mil rows'
    • 'I wrote the generation script (scripts/createMeasurements.ts) based off the original implementation, to be memory efficient for node, but it still takes a while to generate the data since node is (relatively) hella slow.'
    • 'My M2 64gb ram 1 billion rows took ~8 minutes to generate'. Adjust accordingly.
  • yarn run agent - Run turbo4 agent to generate the knowledge base and create the data/agentOutput/* files (optional)
    • The git commited data/agentOutput/* contains the knowledge base you can use without running this command
  • duckdb ./data/db.duckdb < ./data/agentOutput/generate-table.sql - Create the tables based on data/measurements.txt
  • yarn run dev - Start the app

Important Files

  • src/main/turbo4.ts - OpenAI Assistant Wrapper with Knowledge Base Build/Consume support
  • src/main/main.ts - Electron Main Process
  • src/renderer/App.vue - Renderer Process (Vue App)
  • scripts/createMeasurements.ts - Generate the measurements data
  • data/agentOutput/* - Contains files generated by the agents
  • data/agentOutputBackup/* - Contains files generated by original 1brc electron app in youtube AI Devlog
    • If you want overwrite data/agentOutput/* and want to use the original data, copy the contents of this folder to data/agentOutput/

Resources

Primary DuckDB Generation Commands

  • Prove our agents did their jobs
    • duckdb ./data/db.duckdb < ./data/agentOutput/generate-table.sql
    • duckdb ./data/db.duckdb .tables
    • duckdb ./data/db.duckdb "from measurements limit 5"
    • duckdb ./data/db.duckdb "from brc limit 5"

DuckDB Commands

  • duckdb - Start DuckDB Shell
  • In the shell
    • .open <database> - Open a database
    • .tables - List all tables
    • .schema <table> - Show schema of a table
    • .quit - Quit the shell
    • .help - Show help
  • duckdb <path/to/database.duckdb> - Start Shell with database
  • duckdb <path/to/database.duckdb> <sql statement> - Run SQL statement on database
  • duckdb <path/to/database.duckdb> <duckdb command> - Run DuckDb statement on database

Arch Diagrams

Tier 1 Detail

flowchart LR

    subgraph database

    end

    subgraph electron:main

    end

    subgraph electron:renderer

    end

     database <--> electron:main <--> electron:renderer 
Loading

Tier 2 Detail

flowchart LR

    subgraph database
    subgraph duckdb tables
        d_a["brc: {station, min, max, mean}"]
        d_b["measurements: {station, measurement}"]
    end
        
    end

    subgraph electron:main
        em_a[src/main/turbo4.ts]
        em_b[scripts/createMeasurements.ts]
        em_c[src/main/main.ts]
    end

    subgraph electron:renderer
        er_a[src/renderer/App.vue]
    end

     database <--CRUD--> electron:main <--Communication vs Preload.ts--> electron:renderer 
Loading

Tier 3 Knowledgeable

flowchart LR

    subgraph database
    subgraph duckdb tables
        d_a["brc: {station, min, max, mean}"]
        d_b["measurements: {station, measurement}"]
    end
        
    end

    subgraph electron:main
        em_a[src/main/turbo4.ts]
        em_b[scripts/createMeasurements.ts]
        em_c[src/main/main.ts]
    end

    subgraph electron:renderer
        er_a[src/renderer/App.vue]
    end

    subgraph knowledge_base
        kb_a[1brc OG Gunnar post]
        kb_b[1brc DuckDB post]
        kb_c[DuckDB Documentation]
    end

     database <--CRUD--> electron:main <--Communication Via Preload.ts--> electron:renderer 
     em_a <--build kb --> knowledge_base
Loading

1brc-electron's People

Contributors

deluze avatar disler avatar zhanglongqi avatar bmelectro avatar immafrady avatar f1dsy avatar ramto avatar tiagosilvapereira avatar onequid avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.