TestOllamaAPI is an exploratory, full-stack workspace designed to build and test local LLM chat applications using Ollama. It provides a unified React frontend that can interface with a choice of two fully featured backend APIs: one written in Python (FastAPI) and the other in C# (ASP.NET Core).
The primary goals of this project are to demonstrate how to:
- Seamlessly connect to a local Ollama service to generate text and handle chat streams.
- Manage conversational state and chat history.
- Expose a robust REST API for LLM interactions.
- Build a responsive web UI to chat with local AI models.
The workspace is divided into three main components: a frontend application built with React, and two different backend implementations for the API layer. This allows developers to experiment with or learn from different tech stacks side-by-side.
chat-app/: The frontend React web application.TestOllamaAPI/: The C# ASP.NET Core API implementation.ollama-api-python/: The Python FastAPI implementation.
A modern web client to interface with the Ollama chat APIs.
- Stack: React 18, Vite, TypeScript
- Setup & Run:
cd chat-app npm install npm run dev - Default URL: Usually
http://localhost:5173(Vite's default)
A lightweight, fast, and highly concurrent Python backend for managing chat conversations and interfacing with the Ollama service.
- Stack: Python 3.x, FastAPI, Uvicorn, SQLite
- Features:
- Conversation history tracking using SQLite
- Cross-Origin Resource Sharing (CORS) configured for the web frontend
- Setup & Run:
cd ollama-api-python python -m venv venv # Activate venv: # Windows: venv\Scripts\activate # Mac/Linux: source venv/bin/activate pip install -r requirements.txt python main.py
- Default URL:
http://localhost:3003 - API Documentation:
http://localhost:3003/docs(Swagger UI)
An alternative backend implementation built with the robust Microsoft .NET ecosystem.
- Stack: C#, .NET, ASP.NET Core, Scalar (for API documentation)
- Features:
- Strongly-typed services (
IOllamaService,IConversationService) - Configured CORS for frontend access
- Strongly-typed services (
- Setup & Run:
cd TestOllamaAPI dotnet build dotnet run - Default URLs:
- HTTPS:
https://localhost:7201 - HTTP:
http://localhost:5220
- HTTPS:
- API Documentation:
https://localhost:7201/scalar/v1(Scalar API Reference)
- Start a Backend: Choose either the Python backend or the ASP.NET backend and follow its setup instructions to start the API server. Ensure Ollama is running on your machine.
- Start the Frontend: Navigate to the
chat-appdirectory, install the dependencies, and start the development server. - Chat: Open your browser to the Vite dev server URL and start interacting with your local Ollama models!