DEV Community

Veditha
Veditha

Posted on

RepurposeAI- a local content repurposer built on Ollama

Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Submission 💸

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle.

RepurposeAI: Repurpose Content with Local AI Models

What I Built

RepurposeAI converts a blog post or video transcript into platform-specific content for Twitter/X, LinkedIn, newsletters, Instagram, and Reddit.

Paste your source content, choose a format, and watch the output stream directly to the page, token by token, from a model running on your local machine.

The intended user is someone who publishes regularly across multiple platforms and has to manually rewrite the same content several times a week. It's a repetitive task, and many content tools offer AI-powered alternatives through paid subscriptions.

RepurposeAI takes a different approach: it uses a local model through Ollama instead of a paid AI API. The trade-off is that users must install Ollama and download a model themselves. Once the model is available locally, there are no per-generation API charges, and the content sent to the model stays on the user's machine.

Demo

Run Locally

Prerequisites: Node.js and Ollama.

Pull a model and start Ollama:

ollama pull llama3.2
ollama serve
Enter fullscreen mode Exit fullscreen mode

In a separate terminal, clone and run the project:

git clone https://github.com/Veditha08/repurpose-ai
cd repurpose-ai
npm install
npm run dev
Enter fullscreen mode Exit fullscreen mode

Open http://localhost:5173 in your browser.

Code and Architecture

The project uses a small React frontend with a dedicated module for communicating with Ollama.

src/
├── App.jsx       # UI and application state
├── ollama.js     # Ollama client and prompt templates
├── index.css     # Styles
└── main.jsx      # Application entry point
Enter fullscreen mode Exit fullscreen mode

Streaming Responses from Ollama

The core of the Ollama integration is an asynchronous generator that reads the streaming NDJSON response from the API.

export async function* streamGenerate(model, prompt, signal) {
  const res = await fetch('http://localhost:11434/api/generate', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ model, prompt, stream: true }),
    signal,
  });

  const reader = res.body.getReader();
  const decoder = new TextDecoder();

  while (true) {
    const { value, done } = await reader.read();
    if (done) break;

    const lines = decoder
      .decode(value, { stream: true })
      .split('\n')
      .filter(Boolean);

    for (const line of lines) {
      try {
        const obj = JSON.parse(line);

        if (obj.response) yield obj.response;
        if (obj.done) return;
      } catch {
        // Ignore malformed or incomplete lines.
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

The React application consumes the generator using for await...of and appends incoming text to the output state as it arrives. This makes the generation process visible instead of keeping the user waiting for the entire response.

There is no application backend. The browser communicates directly with Ollama running on the same machine.

Each output format has its own prompt template. For example, the newsletter template requests a subject line, an introductory paragraph, three bullet points, and a call-to-action paragraph. The prompts also incorporate the selected niche, tone, and output language to tailor the result to the intended audience.

How It Works

  • Ollama: Runs local language models and exposes a REST API for generation and model discovery.
  • Open-weight models: Users can select from models installed in Ollama, such as Llama 3.2, Qwen 2.5, or Mistral, provided the selected model is compatible with the requested generation.
  • React + Vite: Powers the frontend and development server. The application does not require its own backend, database, or authentication layer.
  • localStorage: Stores generation history in the browser, with up to 30 entries.

The architecture is intentionally simple:

React frontend
     |
     | POST /api/generate
     v
Ollama running locally
     |
     | Streaming response
     v
React state → UI updates
Enter fullscreen mode Exit fullscreen mode

Why Does Open Innovation Matter?

Building this project with open-weight models made three things possible.

1. Cost Structure

Hosted AI APIs can charge per token or request. For someone who frequently repurposes content, those costs can accumulate.

With local inference, there are no per-generation API charges. The trade-off is that users need suitable hardware, and running models still consumes electricity and other computing resources.

2. Data Control

Content being repurposed may belong to clients, contain unreleased material, or be subject to confidentiality requirements.

Because RepurposeAI sends generation requests to Ollama running locally rather than to a hosted AI inference provider, the source content does not need to be sent to a third-party AI API. This reduces external data exposure, although the privacy of the overall setup also depends on the user's environment and configuration.

3. Model Flexibility

Different models can produce different results depending on the content, niche, and task.

With Ollama, users can switch between compatible installed models without integrating a new hosted AI API or managing separate API credentials. The application discovers available models and lets users choose which one to use.

Limitations and Trade-offs

The main limitation is setup complexity.

Ollama is relatively straightforward to install, but asking a non-technical user to download a model, start the local service, and configure their environment introduces friction. Model performance and generation speed also depend on the chosen model and available hardware.

A hosted-API version could be easier to access, but it would introduce different costs and data-handling considerations.

For this project, I chose local inference to explore how open-weight models can make content-generation tools more accessible to people who prefer to run AI on their own machines.

Top comments (0)