Automating LeetCode Documentation with a Local LLM + GitHub Workflow

Published: (March 1, 2026 at 05:42 AM EST)
3 min read
Source: Dev.to

Source: Dev.to

Cover image for Automating LeetCode Documentation with a Local LLM + GitHub Workflow

This is a submission for the DEV Weekend Challenge: Community

The Community

This project is built for developers who actively solve LeetCode problems and share their learning publicly. Many developers aim to stay consistent, build in public, and grow within the coding community — but the documentation process often becomes repetitive and time‑consuming.

I built this tool to reduce friction in that workflow and help developers focus more on problem‑solving rather than manual documentation tasks.

What I Built

LeetCode AutoSync is a CLI automation tool that:

  • Adds LeetCode solutions locally with structured metadata
  • Automatically updates and sorts the README by difficulty
  • Generates high‑quality structured solution write‑ups using a locally hosted LLM (via Ollama)
  • Logs token usage and performance metrics into an Excel sheet
  • Supports multiple programming languages (Python, SQL, C++, Java)
  • Uses a background worker queue to generate AI content asynchronously
  • Gracefully shuts down and manages model lifecycle

Manual steps it replaces

  • Writing the same markdown sections
  • Updating README entries
  • Formatting code blocks
  • Copying structured explanations

Demo

Video: 👉 https://www.loom.com/share/589028a173444af191f4788ff7f25a42

GitHub Repository: 👉 https://github.com/micheal000010000-hub/LEETCODE-AUTOSYNC

The tool runs locally as a CLI and integrates with:

  • Python threading + queue system
  • Ollama (local LLM inference)
  • GitHub workflow
  • Structured Markdown generation
  • Token analytics logging

Code

You can view the full source code here: 👉 https://github.com/micheal000010000-hub/LEETCODE-AUTOSYNC

Architecture Overview

  • autosync.py — CLI controller and queue manager
  • repo_manager.py — File handling and README sorting logic
  • llm_generator.py — LLM integration and token telemetry logging
  • git_manager.py — Git automation
  • config.py — Environment configuration

How I Built It

🧠 Architecture

The tool follows a producer‑consumer model:

  • The main CLI thread enqueues solution‑generation tasks.
  • A background worker processes them using a queue.
  • Thread‑safe state tracking is handled with locks.
  • Notifications are buffered to prevent console interference.
  • Graceful shutdown ensures no tasks are lost.

⚙️ Technologies Used

  • Python
  • Threading + Queue
  • Ollama (local LLM inference)
  • Mistral model
  • requests (HTTP calls)
  • openpyxl (Excel logging)
  • Git automation via subprocess
  • Structured Markdown generation

🚀 LLM Integration

A locally hosted LLM via Ollama replaces cloud APIs, allowing:

  • No API rate limits
  • Full control over resource usage
  • Capture of inference telemetry
  • Logging of prompt tokens, response tokens, and generation latency

📊 Observability

Each generation logs:

  • Prompt tokens
  • Response tokens
  • Total tokens
  • Load duration
  • Generation duration
  • Tokens per second

This creates a lightweight LLM observability layer.

What I Learned

  • Designing concurrent CLI applications
  • Avoiding blocking operations with background workers
  • Managing shared state safely with locks
  • Implementing graceful shutdown patterns
  • Managing model lifecycle
  • Collecting performance telemetry for LLM inference
  • Building tools that solve real developer workflow problems

Why This Matters

Consistency is everything in community‑driven growth. By automating documentation, formatting, and GitHub syncing, this tool removes friction from the process of sharing knowledge.

Less friction → More sharing → Stronger developer community.

Thanks for reading! 🚀

0 views
Back to Blog

Related posts

Read more »

Google Gemini Writing Challenge

What I Built - Where Gemini fit in - Used Gemini’s multimodal capabilities to let users upload screenshots of notes, diagrams, or code snippets. - Gemini gener...