🖥️

Local AI Development

Run LLMs on your own hardware

For developers who want privacy, zero API costs, and offline capability. Run open-source models locally and code with AI assistance without sending data to the cloud.

$0 (hardware costs only)

The Stack

AI Coding Assistant 0

Aider

Terminal-based pair programmer. Works with local models via Ollama. Git-aware.

Try Free →
Code Editor 0

VS Code

Free, extensible, works with any AI extension. Continue.dev for local models.

Try Free →
Database 0

PostgreSQL

Run locally, pgvector for embeddings. No cloud dependency.

Try Free →
Containerization 0

Docker

Package everything. Reproducible environments. Run AI models in containers.

Try Free →

How It Works

1

Install Ollama + pull model

2

Configure Aider with local model

3

Code in VS Code

4

Test with Docker

5

Deploy anywhere

Swap Options

Aider → Cline (VS Code extension) or Continue.dev (multi-model)

Complete Guide

1. Why This Stack?

In an era where artificial intelligence is rapidly becoming indispensable for software development, developers face a critical choice: rely on expensive, cloud-based AI services that demand constant internet access and raise privacy concerns, or build a robust local environment. This guide presents a powerful, zero-cost, and privacy-centric tool stack designed for developers who prioritize data sovereignty, offline capability, and cost efficiency. It’s for those who want to leverage the power of AI in their development workflow without sending their proprietary code or sensitive data to external servers. The problem this stack solves is multifaceted. Firstly, it eliminates the recurring costs associated with cloud-based LLM APIs (like OpenAI's GPT-4 or Anthropic's Claude), which can quickly escalate during active development. Secondly, it addresses the significant privacy implications of sending your codebase, ideas, or customer data to third-party AI providers for analysis and code generation. For many businesses and individual developers, this is a non-starter. Thirdly, it ensures that your AI development environment is entirely self-contained and functional even without an internet connection, crucial for remote work, travel, or environments with unreliable connectivity. This specific combination of tools—Ollama, Aider, VS Code, PostgreSQL, and Docker—was chosen for its synergy and adherence to the core principles of privacy, offline capability, and cost-effectiveness. Ollama provides the local LLM inference engine, Aider integrates this local AI directly into your coding workflow, VS Code serves as the familiar and powerful development environment, PostgreSQL offers a robust local data store for your applications, and Docker ties it all together by providing consistent, isolated environments for your services. Together, they form a complete, self-sufficient ecosystem for modern AI-assisted development.

2. The Tools

Ollama

  • What it does in this stack: Ollama is your local large language model (LLM) server. It allows you to download, run, and manage various open-source LLMs (like Llama 2, Mistral, Code Llama) directly on your machine. It exposes a simple API that other tools, like Aider, can connect to, making local LLM inference as straightforward as using a cloud API.
  • Why it was chosen over alternatives: Ollama stands out for its ease of use. Setting up and running LLMs locally can be complex, often involving deep learning frameworks, specific hardware configurations, and command-line compilation. Ollama abstracts much of this complexity, providing a single executable and a clean interface. Alternatives like directly using Hugging Face's `transformers` library require more manual setup and coding, while `llama.cpp` is powerful but has a less developer-friendly API for integration. Ollama hits the sweet spot for accessibility and performance.
  • Actual pricing: $0. Ollama is completely open-source and free to use.

Aider

  • What it does in this stack: Aider is an AI pair programmer that works directly from your terminal. It connects to an LLM (Ollama in this case) and allows you to interactively modify your codebase. You tell Aider what you want to change or add, and it proposes code modifications, which you can accept, reject, or refine. It's like having a coding assistant that understands your project context.
  • Why it was chosen over alternatives: Aider is specifically designed for local LLM integration and command-line interaction, making it perfect for privacy-conscious developers. Unlike cloud-based alternatives like GitHub Copilot or Cursor.sh, Aider processes your code locally using Ollama, ensuring your intellectual property never leaves your machine. It focuses on practical code modification rather than just suggestions, which is a powerful workflow for rapid development.
  • Actual pricing: $0. Aider is open-source and free to use.

VS Code

  • What it does in this stack: Visual Studio Code (VS Code) serves as your primary Integrated Development Environment (IDE). It's where you write, read, debug, and manage your code. Its integrated terminal is where you'll run Aider and interact with Docker, making it the central hub for your entire development workflow.
  • Why it was chosen over alternatives: VS Code is a free, open-source, and incredibly powerful IDE with a vast ecosystem of extensions. Its lightweight nature, excellent performance, built-in Git integration, and highly customizable interface make it an industry standard. Alternatives like JetBrains IDEs (e.g., PyCharm) offer deeper language-specific integrations but often come with a subscription cost for full features. Simpler editors like Sublime Text lack the full IDE feature set, while Vim/Emacs have a significantly steeper learning curve.
  • Actual pricing: $0. VS Code is free and open-source.

PostgreSQL

  • What it does in this stack: PostgreSQL is a robust, open-source relational database system. In this stack, it provides the persistent data storage for your AI applications. Whether you're storing user data, application settings, embeddings, or results from your LLM interactions, PostgreSQL offers a reliable and feature-rich solution that runs entirely locally.
  • Why it was chosen over alternatives: PostgreSQL is renowned for its reliability, data integrity, and advanced features (e.g., JSONB support, full-text search, extensibility with PostGIS or pgvector). It's a production-grade database that's also excellent for local development. Alternatives include MySQL (which is now owned by Oracle, a concern for some open-source advocates) or SQLite (simpler, file-based, but less suited for complex applications or concurrent access). MongoDB (NoSQL) is an alternative for specific use cases but doesn't offer the relational guarantees of PostgreSQL.
  • Actual pricing: $0. PostgreSQL is open-source and free to use.

Docker

  • What it does in this stack: Docker is a containerization platform. It allows you to package applications and their dependencies into isolated environments called containers. In this stack, Docker is primarily used to run PostgreSQL. This ensures that your database environment is consistent, easy to set up and tear down, and doesn't interfere with other software on your host machine. It also makes it trivial to run multiple versions of PostgreSQL or other services side-by-side.
  • Why it was chosen over alternatives: Docker has become the de-facto standard for containerization due to its widespread adoption, robust ecosystem, and ease of use. It solves the "it works on my machine" problem by providing reproducible environments. Alternatives like Vagrant (VM-based) are heavier, while directly installing services on your host machine can lead to dependency conflicts and messy environments. Docker Desktop is free for individual developers and small teams, making it perfect for this local development setup.
  • Actual pricing: $0 for Docker Desktop Community Edition (for individual developers, small businesses, education, and non-commercial open source projects). Docker Business offers paid tiers starting at $5 per user per month (billed annually), but these are not required for this local development stack.

3. How They Work Together

This stack forms a cohesive local development environment where each tool plays a distinct, yet interconnected, role. The workflow is designed to keep everything on your machine, maximizing privacy and offline capability.

The Workflow:

  1. Initial Development (VS Code): You begin by setting up your project in VS Code. This is where you write your application code, define your project structure, and manage your files. VS Code's integrated terminal is your command center.
  2. Database Management (Docker & PostgreSQL): Before writing code that interacts with a database, you'll start your PostgreSQL server using Docker. Docker ensures PostgreSQL runs in an isolated container, preventing conflicts and making it easy to manage. Your application code, written in VS Code, will then connect to this local PostgreSQL instance.
  3. Local LLM Inference (Ollama): Ollama runs in the background as a local server, listening for requests. You'll have downloaded one or more LLM models (e.g., Code Llama, Mistral) through Ollama, making them available for use.
  4. AI-Assisted Coding (Aider & Ollama): When you need AI assistance, you launch Aider from your VS Code terminal. Aider connects to Ollama's local API. You then describe what you want to achieve (e.g., "Add a Python function to query user data from the PostgreSQL database," or "Refactor this module to use async/await").
  5. Code Generation & Refinement (Aider & VS Code): Aider sends your prompt and relevant code snippets to Ollama. Ollama processes this locally and returns proposed code changes. Aider displays these changes in your terminal, allowing you to review, accept, reject, or modify them. Once accepted, Aider directly applies the changes to your files, which are immediately reflected in VS Code.
  6. Application Execution & Testing (VS Code & PostgreSQL): With the AI-generated or AI-assisted code, you can then run and test your application directly from VS Code. Your application will interact with the local PostgreSQL database for data storage and retrieval.

How Data Flows Between Tools:

  • Code & Prompts: Your code (from VS Code) and your instructions (prompts) flow from your terminal (via Aider) to Ollama. This data never leaves your machine.
  • AI Suggestions: Ollama processes the code and prompts locally and sends back generated code or suggestions to Aider, which then updates your files in VS Code. Again, this remains entirely local.
  • Application Data: Your application code (developed in VS Code, potentially with Aider's help) connects directly to the PostgreSQL database running in a Docker container on your machine. All application data remains local.
  • Container Management: Docker manages the PostgreSQL container, ensuring its isolation and proper functioning, but no application data flows through Docker itself in a persistent way; it's a runtime environment.

4. Setup Guide

This section provides step-by-step instructions and commands to get your local AI development stack up and running.

Prerequisites:

  • Operating System: macOS, Linux, or Windows.
  • Hardware: For running LLMs, you'll benefit significantly from a machine with at least 16GB of RAM and a dedicated GPU (NVIDIA or Apple Silicon) for faster inference. While some models can run on CPU, it will be much slower.

1. Install VS Code:

Download and install Visual Studio Code from the official website:

Follow the installation instructions for your operating system. Once installed, open it.

2. Install Docker Desktop:

Download and install Docker Desktop from the official website:

Follow the installation instructions for your OS. Make sure to start Docker Desktop after installation; you'll usually see a whale icon in your system tray/menubar indicating it's running.

3. Run PostgreSQL with Docker:

Open the integrated terminal in VS Code (Ctrl+` or Cmd+`).

# Pull the latest PostgreSQL image from Docker Hub
docker pull postgres:latest

# Run a PostgreSQL container
# --name local-pg: Assigns a memorable name to your container
# -e POSTGRES_PASSWORD=mysecretpassword: Sets the password for the default 'postgres' user
# -p 5432:5432: Maps the container's port 5432 to your host's port 5432
# -d: Runs the container in detached mode (in the background)
docker run --name local-pg -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres

# Verify the container is running
docker ps

# Optional: Connect to the PostgreSQL database inside the container
# This lets you create databases, tables, etc., directly
# To exit psql, type \q and press Enter.
docker exec -it local-pg psql -U postgres

You now have a local PostgreSQL server running on `localhost:5432` with user `postgres` and password `mysecretpassword`.

4. Install Ollama:

Download and install Ollama from the official website:

Follow the installation instructions for your OS. Ollama will typically start a background service automatically.

Once installed, download a model. We recommend `codellama` or `mistral` for coding tasks. `codellama` is specifically fine-tuned for code.

# Open a new terminal in VS Code or your system's terminal
ollama run codellama # This will download the model if you don't have it, then start an interactive chat
# Type 'hi' and press Enter to test it. Type /bye to exit.

# You can also download other models
ollama pull mistral
ollama pull llama2

Ollama will now be running in the background, serving models on `http://localhost:11434`.

5. Install Aider:

Aider is a Python package, so you'll need Python and `pip` installed. Most systems come with Python. If not, install it from python.org.

# Create a new Python virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate

# Install Aider
pip install aider-chat

Configure Aider to use Ollama:

Aider expects an OpenAI-compatible API. Ollama provides one. You need to set environment variables. You can set these in your shell or add them to a `.env` file in your project root and use a library like `python-dotenv` if running Aider programmatically.

# Set these in your terminal before running Aider
export OPENAI_API_BASE="http://localhost:11434/v1"
export OPENAI_API_KEY="ollama" # Aider expects a key, but for Ollama it's a placeholder

# Now run Aider, specifying the Ollama model
# Replace 'codellama' with 'mistral' or 'llama2' if you downloaded those instead
aider --model ollama/codellama

Aider will start, showing a prompt like `Aider: `. You can now interact with it.

6. Project Setup Example (Python + PostgreSQL):

Let's create a simple Python project that connects to PostgreSQL, and use Aider to help.

# In your VS Code terminal, navigate to your desired project directory
mkdir my_ai_app
cd my_ai_app

# Create a new virtual environment and activate it (if you didn't for Aider globally)
python -m venv .venv
source .venv/bin/activate

# Install a PostgreSQL adapter for Python
pip install psycopg2-binary

Create a file named `main.py` in your `my_ai_app` directory.

Now, run Aider from this directory:

# Ensure the environment variables are set (or set them again)
export OPENAI_API_BASE="http://localhost:11434/v1"
export OPENAI_API_KEY="ollama"

# Start Aider, adding main.py to its context
aider main.py --model ollama/codellama

In the Aider prompt, type:

/add main.py
Please write a Python function in main.py that connects to the PostgreSQL database 'local-pg' (user: postgres, password: mysecretpassword, host: localhost, port: 5432), creates a table called 'users' with columns 'id' (SERIAL PRIMARY KEY), 'name' (VARCHAR(100)), and 'email' (VARCHAR(100) UNIQUE). Also add a function to insert a new user and a function to fetch all users. Include a main block to test these functions.

Aider will propose changes to `main.py`. Review them, and type `y` to accept. You'll see `main.py` updated in VS Code. You can then `deactivate` Aider (by typing `/quit`) and run `python main.py` in your terminal to test the code.

5. Real Cost Breakdown

This stack is designed to be entirely free, leveraging open-source software and community editions. The only "cost" might be the initial investment in suitable hardware if your current machine isn't powerful enough for LLMs.
Tool Free Tier / Open Source Paid Tier (if applicable) What you actually need for this stack
Ollama Full functionality, unlimited local LLM inference. N/A (fully open-source) Free version.
Aider Full functionality, AI pair programming with local LLMs. N/A (fully open-source) Free version.
VS Code Full IDE features, extensions, Git integration. N/A (fully open-source) Free version.
PostgreSQL Full relational database system, unlimited local use. N/A (fully open-source) Free version.
Docker Docker Desktop Community Edition (free for individuals, small businesses, education, non-commercial open source). Docker Business: starts at $5/user/month (billed annually) for larger organizations. Free Docker Desktop Community Edition.
Total Estimated Cost $0 N/A for this use case $0 (excluding hardware)

6. When to Upgrade

This local AI development stack is powerful, but there are clear indicators that you might be outgrowing it and need to consider cloud-based or more robust solutions:
  • Performance Bottlenecks: Your local machine struggles to run larger LLMs efficiently. Inference becomes too slow, or you constantly run into out-of-memory (OOM) errors, even with smaller models. This is a sign you need more powerful GPUs or distributed compute.
  • Need for State-of-the-Art Models: You require the capabilities of proprietary, cutting-edge LLMs like GPT-4, Claude Opus, or Google Gemini Ultra, which are not available for local deployment or exceed the capabilities of open-source alternatives.
  • Team Collaboration & Scalability: You're working in a team environment where shared development environments, centralized data access, and scalable infrastructure become critical. Local setups are great for individuals but challenging for large teams.
  • Production Deployment: Your AI application needs to be deployed to production, requiring high availability, fault tolerance, automatic scaling, and managed services for databases, compute, and LLM APIs.
  • Advanced MLOps Needs: You require sophisticated MLOps (Machine Learning Operations) tools for experiment tracking, model versioning, continuous integration/delivery (CI/CD) for AI models, and real-time model monitoring, which are typically cloud-native.

What to Switch To (or Integrate With):

  • Cloud LLM APIs: For cutting-edge models, integrate with services like OpenAI API, Anthropic API, or Google Cloud's Vertex AI.
  • Managed Databases: For scalable and highly available data storage, migrate to managed database services like AWS RDS (PostgreSQL), Google Cloud SQL, or Azure SQL Database.
  • Cloud Compute: For running larger open-source models or fine-tuning, consider cloud virtual machines with powerful GPUs (e.g., AWS EC2, Google Cloud Compute Engine, Azure VMs).
  • Cloud-based IDEs/Workspaces: For collaborative development, explore platforms like GitHub Codespaces or Gitpod, which provide cloud-hosted development environments.
  • MLOps Platforms: For end-to-end machine learning lifecycle management, look into platforms like MLflow, Kubeflow, or cloud-specific MLOps offerings (e.g., AWS SageMaker, Google Cloud AI Platform).

7. Alternatives

While the chosen stack is excellent for its purpose, it's useful to know alternatives and their trade-offs.

Ollama Alternatives:

  • Hugging Face `transformers` library:
    • Trade-offs: Offers maximum control and flexibility, direct Python integration, access to a vast array of models. However, it requires more manual setup, deeper understanding of model loading/inference, and doesn't provide a simple API server out-of-the-box like Ollama. Steeper learning curve.
  • `llama.cpp`:
    • Trade-offs: Highly optimized C++ library for running LLMs on CPU (and increasingly GPU). Very efficient. However, it's primarily a command-line tool, and integrating it into applications requires more effort than Ollama's straightforward API.

Aider Alternatives:

  • GitHub Copilot:
    • Trade-offs: Excellent code suggestions, integrates directly into many IDEs. However, it's a cloud-based, paid service ($10/month or $100/year), and your code is sent to Microsoft servers for processing, which is a privacy concern for this stack's target audience.
  • Cursor.sh:
    • Trade-offs: A full IDE built around AI features (chat, edit, debug with AI). Offers a very integrated AI experience. However, it's a closed-source product, and its AI capabilities typically rely on cloud APIs (OpenAI, Anthropic), meaning your code leaves your machine. Free tier has limitations.

VS Code Alternatives:

  • JetBrains IDEs (e.g., PyCharm, IntelliJ IDEA):
    • Trade-offs: Offer deeper, more integrated language-specific features, superior refactoring tools, and excellent debugging. However, the full-featured Professional editions are paid (e.g., PyCharm Professional is $249/year for the first year, then less). Community editions are free but lack many advanced features.
  • Neovim / Vim:
    • Trade-offs: Extremely fast, highly customizable, and resource-efficient. Once mastered, it can be incredibly productive. However, it has a very steep learning curve and requires significant configuration to match IDE features.

PostgreSQL Alternatives:

  • SQLite:
    • Trade-offs: A file-based database, meaning zero setup, incredibly lightweight, and excellent for simple, single-user applications or embedded databases. However, it's less robust for concurrent access, complex queries, or large datasets compared to PostgreSQL.
  • MySQL:
    • Trade-offs: Another popular relational database, widely used. Similar feature set to PostgreSQL for many common tasks. However, its ownership by Oracle is a concern for some open-source enthusiasts, and its licensing model can be less clear for commercial use compared to PostgreSQL's permissive license.

Docker Alternatives:

  • Podman:
    • Trade-offs: A daemonless container engine, compatible with Docker commands. Often preferred on Linux systems for its rootless capabilities and security model. Can be a good drop-in replacement for Docker, especially on Linux, but Docker Desktop offers a more integrated experience on macOS/Windows.
  • Direct Installation:
    • Trade-offs: You can directly install PostgreSQL (or any other service) on your host operating system. This avoids the overhead of containerization. However, it can lead to dependency conflicts, makes managing multiple versions difficult, and creates a less reproducible environment, which is why Docker is usually preferred.

8. Verdict

This "Local AI Development" stack is an ideal choice for a specific segment of developers, but it's not for everyone.

Who Should Use This Stack:

  • Privacy-Conscious Developers: If keeping your code, data, and intellectual property strictly on your local machine is a top priority, this stack is built for you. No data leaves your control.
  • Budget-Minded Individuals & Hobbyists: With an estimated cost of $0, this stack is perfect for students, hobbyists, or anyone wanting to experiment with AI development without incurring cloud bills.
  • Offline Developers: For those who frequently work without an internet connection (e.g., on flights, in remote areas, or simply prefer to disconnect), this fully local setup ensures uninterrupted productivity.
  • Learners & Experimenters: If you're looking to understand how LLMs work, integrate them into applications, or build AI-powered features from the ground up, this hands-on local environment provides an excellent learning platform.
  • Developers with Sensitive Data: For projects involving highly sensitive, confidential, or regulated data, processing everything locally minimizes compliance risks and security vulnerabilities associated with cloud services.

Who Shouldn't Use This Stack:

  • Teams Requiring Enterprise-Grade Scalability: If your project demands high availability, automatic scaling for production, or centralized management for large teams, cloud-based managed services will be more suitable.
  • Developers Needing Cutting-Edge Proprietary LLMs: If your application absolutely requires the latest, largest, and most powerful models like GPT-4 Turbo or Claude Opus, which are currently only available via cloud APIs, this stack won't meet that specific need.
  • Developers Prioritizing Convenience Over Control: If you prefer the convenience of fully managed cloud services, where infrastructure and AI APIs are handled for you, and you're comfortable with the associated costs and data privacy trade-offs, then cloud-native solutions might be a better fit.
  • Those Without Adequate Local Hardware: Running LLMs locally requires decent hardware (especially RAM and potentially a GPU). If your machine is significantly underpowered, the performance might be too slow to be practical.
In summary, if you value privacy, cost control, offline capability, and a hands-on approach to AI development, this Ollama + Aider + VS Code + PostgreSQL + Docker stack offers an incredibly powerful and practical foundation for your projects.

Related Comparisons