Skip to content

BayajidAlam/askly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

🧠 Askly: Intelligent RAG & Web Search Agent

License: MIT PRs Welcome Contributions Welcome

Askly is a high-performance RAG (Retrieval-Augmented Generation) system that lets you chat with your documents and falls back to the internet when it doesn't know the answer. Built with Google Gemini, ChromaDB, and real-time streaming.

Askly Architecture

✨ Key Features

  • PDF Intelligence: Upload any PDF to index it into ChromaDB Cloud for instant local retrieval.
  • Smart Fallback: If Askly can't find the answer in your documents, it automatically triggers a Tavily Web Search.
  • Real-time Streaming: AI responses stream word-by-word via Server-Sent Events (SSE) β€” exactly like ChatGPT.
  • Markdown Rendering: Responses render rich markdown β€” including bold text, lists, and code blocks.
  • Modern UI: A premium, responsive chat interface built with React, Shadcn UI, and Lucide Icons.
  • Attachment System: Modern AI-style file attachments for seamless document indexing.
  • Real-time Logging: Backend middleware logs every interaction with timestamps.

πŸ“Έ Screenshots

🌐 Web Search in Action

Ask anything without uploading a file β€” Askly falls back to live Tavily web search and streams the answer with a 🌐 WEB SEARCH badge.

Web Search Screenshot 1

Web Search Screenshot 2


πŸ“„ PDF Upload & Document Search

Upload any PDF, then ask questions about its content β€” Askly indexes it into ChromaDB and streams answers from your own data.

PDF Search Screenshot


πŸ—οΈ Architecture & Data Flow

Askly follows a robust RAG lifecycle:

  1. Ingestion: PDFs are parsed, chunked, and vectorized using Google Gemini Embeddings (gemini-embedding-001) before being stored in ChromaDB Cloud.
  2. Retrieval: Queries are converted to vectors and compared via Cosine Similarity to find the most relevant document chunks.
  3. Synthesis: If document similarity is below threshold, Askly searches the web via Tavily.
  4. Generation: The final context is sent to Gemini 2.5 Flash which streams the answer back word-by-word through Server-Sent Events.

Streaming Architecture

User sends message
    ↓
Frontend creates empty assistant bubble
    ↓
POST /api/query/stream (SSE endpoint)
    ↓
Backend yields: { sources, isFromWeb } β†’ then { chunk: "word" } Γ— N β†’ [DONE]
    ↓
Frontend ReadableStream reader appends each chunk to the bubble in real-time

πŸš€ Getting Started

1. Prerequisites

Ensure you have Node.js v18+ installed and the following API keys:

2. Setup Environment

Create a .env file inside the server/ directory:

GEMINI_API_KEY=your_gemini_key
CHROMA_API_KEY=your_chroma_key
CHROMA_TENANT=your_tenant_id
CHROMA_DATABASE=askly
TAVILY_API_KEY=your_tavily_key

3. Installation

Install dependencies for both client and server:

# Install Server deps
cd server
npm install

# Install Client deps
cd ../client
npm install

4. Running the App

Start the development servers for both:

Backend (Server):

cd server
npm run dev

Frontend (Client):

cd client
npm run dev

The application will be available at http://localhost:5173.


πŸ› οΈ Tech Stack

Frontend

Technology Purpose
React 19 + Vite UI framework & build tool
Tailwind CSS v4 Styling
Shadcn UI + Radix Component library
react-markdown Render AI markdown responses
Lucide Icons Icon set

Backend

Technology Purpose
Node.js + Express HTTP server
TypeScript + Tsx Type safety & dev runner
Google Gemini SDK LLM generation + embeddings
ChromaDB Cloud Vector store
Tavily API Web search fallback
Multer PDF file upload handling
pdf-parse PDF text extraction
Server-Sent Events Real-time streaming

πŸ“ Project Structure

askly/
β”œβ”€β”€ client/             # React frontend
β”‚   └── src/
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ chat/   # ChatHeader, ChatMessage, ChatInput
β”‚       β”‚   └── ui/     # Shadcn components
β”‚       β”œβ”€β”€ types/      # Shared TypeScript types
β”‚       └── App.tsx     # Main app with SSE streaming logic
└── server/             # Express backend
    └── src/
        β”œβ”€β”€ lib/
        β”‚   β”œβ”€β”€ rag.ts        # RAG engine (query + queryStream)
        β”‚   β”œβ”€β”€ embedding.ts  # Gemini vector embeddings
        β”‚   β”œβ”€β”€ vectorStore.ts # ChromaDB integration
        β”‚   β”œβ”€β”€ search.ts     # Tavily web search
        β”‚   └── utils.ts      # Text chunking
        └── server.ts         # Express endpoints (+ /api/query/stream)

🎨 Design Philosophy

Askly is designed to be visually stunning and highly functional. It features:

  • Glassmorphism: Elegant card layouts with backdrop blurs.
  • Micro-animations: Smooth transitions for message bubbles and loaders.
  • Responsiveness: Fully optimized for mobile and desktop screens.
  • Streaming UX: Text types itself out word-by-word for a natural, fast-feeling experience.

Important

To use real AI responses, ensure you have a GEMINI_API_KEY set in your .env file. You can get one for free at Google AI Studio.

Note

The embedding model (gemini-embedding-001) produces 3072-dimensional vectors. ChromaDB collections must be consistent β€” run a DB reset if switching embedding models.


🀝 Contributing

Contributions are welcome! Whether it's a bug fix, new feature, or documentation improvement β€” every bit helps.


Developed with ❀️ as part of the Askly RAG Learning Series.

About

An intelligent open source RAG engine powered by Google Gemini - chat with your PDFs, stream AI answers word-by-word via SSE, and fall back to live web search automatically

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors