Fluid Machinery By Jose Francisco Pdf Now
# ai_gateway/main.py from fastapi import FastAPI, Body import openai, os, redis
The goal is to give readers a powerful, web‑based tool that turns the static PDF into an – searchable, searchable‑by‑equation, annotated, and AI‑enhanced with summaries, quizzes, and visual explanations. 1. High‑Level Vision | What it does | Why it matters | |------------------|--------------------| | Instant full‑text search (including math & symbols) | Engineers can locate a specific equation, term, or design case in seconds. | | AI‑driven chapter & section summaries | Saves time for students/researchers who need a quick refresher. | | Equation‑aware navigation | Click a displayed equation → jump to its definition, derivation, and related examples. | | Interactive annotation layer (highlights, notes, drawings) | Enables personal study and collaborative discussion. | | Dynamic 3‑D visualisation of key machines (pumps, turbines, compressors) | Turns textbook figures into manipulable models for deeper intuition. | | Self‑assessment quizzes generated per chapter | Reinforces learning and tracks progress. | | Exportable study pack (selected notes + AI summary + quiz) | Easy hand‑off to PDFs, Word, or Markdown for offline study. | 2. Core User Stories | ID | User | Story | |--------|----------|-----------| | US‑001 | Student | I can type any keyword (including LaTeX‑style symbols) and instantly see every occurrence highlighted in the PDF. | | US‑002 | Engineer | I can click on an equation to view a pop‑up that shows the derivation steps, variable definitions, and related design tables. | | US‑003 | Instructor | I can add public or private annotations on any page, and share them with a class via a single URL. | | US‑004 | Self‑learner | I can ask the system “Summarize the operating principle of a centrifugal pump” and receive a concise, bullet‑point answer. | | US‑005 | Reviewer | I can generate a 10‑question multiple‑choice quiz for Chapter 4, with answers and explanations, and export it as a PDF. | | US‑006 | Designer | I can rotate, zoom, and explode a 3‑D turbine model extracted from the book’s figure, and download the STL file. | | US‑007 | All | I can download a “Study Pack” that bundles my notes, AI‑generated summary, and quiz for any chapter. | 3. Functional Requirements | FR | Description | |--------|-----------------| | FR‑1 | PDF Rendering – Use PDF.js to display the original PDF at native resolution, with optional “night mode”. | | FR‑2 | Search Engine – Index the PDF text and embedded LaTeX/MathML via ElasticSearch (or MeiliSearch ) with custom analyzers for symbols. | | FR‑3 | Equation Extraction – Run pdf2image + Mathpix OCR on each page to capture LaTeX strings; store them in a relational table linked to page numbers. | | FR‑4 | AI Summarizer – Call OpenAI GPT‑4o (or a locally hosted LLaMA 2 70B) with a prompt: “Summarize the following 2‑page excerpt from Fluid Machinery in ≤ 5 bullet points.” | | FR‑5 | Quiz Generator – Prompt‑template to LLM: “Create 5 multiple‑choice questions on the key concepts of Chapter X with one correct answer and a short explanation.” | | FR‑6 | Annotation Layer – Store user notes, highlights, and free‑hand drawings in a PostgreSQL table keyed by user_id , pdf_id , page_number . Use Fabric.js for drawing. | | FR‑7 | 3‑D Visualiser – Convert vector figures (SVG/AI) to glTF using svg2gltf ; render with three.js . Provide explode‑view controls. | | FR‑8 | Export Service – Assemble selected content (notes, summary, quiz) into a PDF via WeasyPrint or pdfkit ; also offer Markdown/Word export. | | FR‑9 | Authentication & Permissions – OAuth2 (Google/Institution) + role‑based access (private vs. public annotations). | | FR‑10 | Responsive UI – All features must work on desktop (≥1024 px) and tablets; mobile view hides heavy 3‑D visualisation. | 4. Non‑Functional Requirements | NFR | Target | |---------|------------| | NFR‑1 | Performance – Search results < 200 ms for a 400‑page PDF; AI calls cached for 24 h. | | NFR‑2 | Scalability – Architecture on Kubernetes ; each component (search, AI gateway, PDF server) horizontally scalable. | | NFR‑3 | Security – PDF served via signed URLs; no PDF content stored in clear text on the client. | | NFR‑4 | Compliance – Ensure the PDF is either open‑access or that the platform operates under a fair‑use agreement; provide a “download‑disabled” option for copyrighted material. | | NFR‑5 | Accessibility – WCAG 2.1 AA compliance; all UI elements keyboard‑navigable, ARIA labels, high‑contrast mode. | | NFR‑6 | Maintainability – Codebase split into three repos (frontend, backend, AI‑gateway) with CI/CD pipelines (GitHub Actions). | | NFR‑7 | Extensibility – Plugin system to add new “machine‑type” visualisers (e.g., axial flow compressors). | 5. Architecture Overview +-------------------------------------------------------+ | Front‑End (React) | | - PDF.js viewer + Fabric.js annotation layer | | - Search bar → /api/search | | - Equation pop‑ups → /api/equation/:id | | - Summary/Quiz panels → /api/ai/:task | | - 3‑D Viewer (three.js) | | - Export dialog → /api/export | +---------------------------|---------------------------+ | +-----------------+-----------------+ | | +-------------------+ +-------------------+ | API Gateway (Node/Express) | Auth Service (OAuth2) | | /search, /equation, /ai, /export | JWT issuance | +-------------------+ +-------------------+ | | +------+-------+ +---------+--------+ | | | | +------+ +----------+ +----------------+ +-----------------+ | Elastic| | PostgreSQL| | LLM Proxy (FastAPI) | | File Storage (S3) | |Search | | (notes, | | - OpenAI / Llama | | (original PDF, | | (text &| | eqn map) | | - caching layer | | 3‑D glTF) | | math) | +----------+ +--------------------+ +-----------------+ +------+ All traffic is HTTPS. The PDF is stored encrypted in S3; a short‑lived signed URL is generated per user session. 6. Detailed Component Design 6.1 PDF Rendering & Annotation | Tech | Why | |----------|----------| | React + PDF.js | Mature, client‑side rendering, page‑wise lazy loading. | | Fabric.js | Vector‑based drawing on top of canvas; supports free‑hand, shapes, text. | | IndexedDB (client) | Cache rendered pages for offline reading. | | Web Workers | Offload OCR & heavy math extraction to background threads. |
def call_llm(prompt: str, temperature=0.2): cache_key = f"llm:hash(prompt)" if cached := cache.get(cache_key): return cached.decode() response = openai.ChatCompletion.create( model="gpt-4o", messages=["role": "user", "content": prompt], temperature=temperature, ) result = response.choices[0].message.content cache.setex(cache_key, 86400, result) # 24‑h cache return result Fluid Machinery By Jose Francisco Pdf
import useEffect, useRef from "react"; import GLTFLoader from "three/examples/jsm/loaders/GLTFLoader";
@app.post("/summary") def summary(pages: dict = Body(...)): text = pages["text"] prompt = f"Summarize the following text from *Fluid Machinery* in ≤ 5 bullet points.\n\nText:\ntext" return "summary": call_llm(prompt) # ai_gateway/main
"mappings": "properties": "content": "type": "text", "analyzer": "standard" , "equation_latex": "type": "text", "analyzer": "latex_analyzer" , "page_number": "type": "integer" , "settings": "analysis": "analyzer": "latex_analyzer": "tokenizer": "standard", "filter": ["lowercase", "latex_symbols"] , "filter": "latex_symbols": "type": "pattern_replace", "pattern": "[^\\\\a-zA-Z0-9]", "replacement": " "
// src/api.ts export const search = (query: string) => axios.get('/api/search', params: q: query ); export const getEquation = (eqId: string) => axios.get(`/api/equation/$eqId`); export const summarize = (pageRange: string) => axios.post('/api/ai/summary', pages: pageRange ); export const generateQuiz = (chapter: number) => axios.post('/api/ai/quiz', chapter ); export const exportPack = (payload) => axios.post('/api/export', payload, responseType: 'blob' ); Custom Analyzer – tokenizes on whitespace and on LaTeX delimiters ( $ , \ , , ). Fields – content , equation_latex , page_number . | | AI‑driven chapter & section summaries |
export const MachineViewer = ( modelUrl : modelUrl: string ) => { const container = useRef<HTML
@app.post("/quiz") def quiz(chapter: int = Body(...)): prompt = f"Create 5 multiple‑choice questions about the key concepts in Chapter chapter of *Fluid Machinery*. Provide four options, indicate the correct one, and write a brief explanation." return "quiz": call_llm(prompt) Source : Figures in the PDF that are vector (SVG) are exported by the publisher as EPS/AI. Conversion : svg2gltf → glb → served via CDN.
app = FastAPI() cache = redis.from_url(os.getenv("REDIS_URL"))