Skip to content

Repository files navigation

Business Knowledge AI

A source-grounded business research workspace built around the OpenStax Introduction to Business textbook.

Live application Frontend Backend Workflow License

Business Knowledge AI answers business questions using retrieved passages from Introduction to Business. It presents generated responses as research notes with chapter, page, and source evidence, rather than treating the model output as an ungrounded answer.

Why this project

The project is designed to make the provenance of an AI answer visible. Each response is produced through a fixed, non-agentic workflow that retains source metadata from retrieval through the final interface.

Question
  → query processing
  → BM25 retrieval over OpenStax chunks
  → deterministic LangGraph orchestration
  → grounded prompt construction
  → local Qwen2.5 7B generation through Ollama
  → answer with textbook citations and retrieved passages
Area Implementation
User experience React 19, Tailwind CSS 4, an editorial research-desk interface, responsive source review
Application host Express 4 with a supervised FastAPI process and POST /api/chat proxy
RAG orchestration A forward-only LangGraph workflow: process → retrieve → rerank stage → prompt → generate → format
Retrieval currently available BM25 over provenance-preserving textbook chunks
Generation Local qwen2.5:7b through user-run Ollama.
Evidence OpenStax source title, chapter, page, source URL, passage rank, and retrieved text
Validation Vitest contracts for chat behavior and backend artifacts, plus TypeScript validation

Product experience

The current Research Ledger interface is a light editorial workspace built around three complementary views:

View Purpose
Research Index Starts a new inquiry, preserves local conversation history, and keeps core textbook chapters in view.
Research Note Presents a question and its grounded response in a readable, article-like format.
Evidence Register Displays the retrieved OpenStax citations, chapter/page metadata, and supporting passages returned by the API.

The interface intentionally does not expose autonomous-agent controls. It emphasizes readable answers, traceable evidence, and explicit application states when a source or generation result is unavailable.

Architecture

flowchart LR
    UI[React research workspace] -->|POST /api/chat| HOST[Express host]
    HOST --> API[FastAPI service]
    API --> GRAPH[Deterministic LangGraph]
    GRAPH --> RETRIEVE[BM25 retrieval]
    RETRIEVE --> PROMPT[Grounded prompt]
    PROMPT --> OLLAMA[qwen2.5:7b via local Ollama]
    OLLAMA --> RESPONSE[Answer + citations + passages]
    RESPONSE --> UI
Loading

The graph is intentionally deterministic. It has no autonomous agent, tool-calling loop, retrieval loop, self-correction loop, or model-directed routing.

Repository structure

business-knowledge-ai/
├── backend/                 # FastAPI RAG service and deterministic graph
├── client/                  # React + Tailwind research workspace
├── server/                  # Express host, proxy, lifecycle supervision, and tests
├── notebooks/               # Notebook-first source, ingestion, retrieval, and graph study
├── data/
│   ├── raw/                 # Local source metadata; the large PDF is intentionally ignored
│   └── processed/           # Auditable page, chunk, retrieval, and status artifacts
├── drizzle/                 # Application schema and migrations
├── .github/                 # Issue and pull-request templates
└── README.md

Local development

Prerequisites

Use a current Node.js release with Corepack / pnpm, Python 3.10 or later, and a local Ollama installation with the required Qwen model. The Windows setup below uses an isolated .venv so the RAG dependencies do not need to be installed globally.

cd "C:\Users\AbdElhalk\OneDrive\Desktop\RAG & LLMS Projects\Business Knowledge AI"
corepack pnpm install --frozen-lockfile
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install --upgrade pip
.\.venv\Scripts\python.exe -m pip install -r backend/requirements.txt

Open http://localhost:3000 after completing the local-generation commands below. The Express host starts and supervises the FastAPI service for the chat route.

Required server-side configuration

Variable Purpose
OLLAMA_MODEL Local model. Defaults to qwen2.5:7b.
OLLAMA_BASE_URL Local Ollama endpoint. Defaults to http://127.0.0.1:11434; no API key is required.
OPENSTAX_GENERATIVE_AI_PERMISSION_CONFIRMED Explicit authorization gate for enabling generative processing of the source material.

Do not commit .env files, provider credentials, or the locally acquired textbook PDF.

Required local generation with Ollama

The application uses the free Qwen2.5 7B model through Ollama. First install Ollama and download the model:

ollama pull qwen2.5:7b

If a PowerShell window opened before Ollama was installed does not resolve ollama, either open a new PowerShell window or use the installed executable explicitly:

& "$env:LOCALAPPDATA\Programs\Ollama\ollama.exe" pull qwen2.5:7b

Then open a PowerShell window in the project directory and start the application with the local model configured:

$env:OLLAMA_BASE_URL = "http://127.0.0.1:11434"
$env:OLLAMA_MODEL = "qwen2.5:7b"
$env:OPENSTAX_GENERATIVE_AI_PERMISSION_CONFIRMED = "true"
$env:PYTHON_BINARY = "$PWD\.venv\Scripts\python.exe"
corepack pnpm dev

Ollama must remain running while the local application answers questions. PYTHON_BINARY is required on Windows when the python3 command is not available; it tells the Express host which interpreter should start the FastAPI child service. The application sends the existing system instructions, grounded OpenStax context, and user question to the local /api/chat endpoint; BM25 retrieval, deterministic LangGraph orchestration, citations, and the frontend evidence register do not change. See the Ollama model page and Ollama's Windows guide for installation details.

Important: Open http://localhost:3000 (or the verified local port) to use the Windows-local model. A hosted cloud deployment cannot reach http://127.0.0.1:11434 on your Windows computer, so it can retrieve sources but will correctly report generation as unavailable unless Ollama is co-located with that deployment.

Quality checks

pnpm test
pnpm check

The test suite covers the chat interface, API contracts, artifact integrity, and deterministic pipeline expectations. A successful local run should be accompanied by an actual /api/chat request when validating model access.

Source material and responsible use

This project uses the official OpenStax Introduction to Business textbook as its source corpus. The textbook is openly accessible under CC BY 4.0, subject to the attribution and other conditions documented by OpenStax. The local PDF is deliberately excluded from Git because of its size and must be reacquired only from the official source.

OpenStax also states that the book may not be used to train or otherwise ingest into large language models or generative-AI offerings without OpenStax’s permission. This project keeps an explicit server-side authorization gate for generative use.

Source record Location
Official book page OpenStax — Introduction to Business
Local source metadata data/raw/SOURCE.md
Expected local PDF path data/raw/introduction-to-business-openstax.pdf
Code license MIT

The code in this repository is MIT licensed. The OpenStax textbook and its associated licensing or permission conditions remain governed by their own terms and are not relicensed by this repository.

Current limitations

The published system provides real BM25 retrieval and model-backed answer generation. Dense BGE-M3 retrieval, Qdrant-backed hybrid fusion, and BGE reranking are deliberately reported as unavailable unless their corresponding real artifacts have been produced. The application does not fabricate missing vectors, scores, passages, or citations.

Contributing

Contributions are welcome. Please read CONTRIBUTING.md before opening an issue or pull request. Changes that affect retrieval, grounding, citations, source-data handling, or model generation must preserve the project’s provenance-first design.

License

The application code is available under the MIT License.


Built as a portfolio-ready, source-grounded AI application focused on transparent business research.

About

A source-grounded business research workspace built around OpenStax Introduction to Business.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages