beerohan commited on
Commit
dd4a03a
·
1 Parent(s): 5ac3946

Rebuild frontend in React, add doc/session management, fix broken deps

Browse files

Frontend rebuilt as a React + Vite + TypeScript SPA, replacing the vanilla
JS/CSS app. Adds dark mode, a document list with per-document delete,
multi-file upload, cancellable streaming, and chat history that survives a
page reload. Served by FastAPI from static/, which is now a build artifact
produced by the Node stage of a multi-stage Dockerfile.

Backend additions:
- DELETE /documents/{name} removes a single document from the Chroma index
- Chat history persisted to SQLite (app/services/history_service.py) with
GET/PATCH/DELETE /sessions routes; transcripts survive process restarts

Performance:
- /stream_query fetched citation sources by calling query() a second time,
running a full LLM generation whose text was discarded. Replaced with a
retrieval-only path, saving ~0.6s and one Groq call per message.
- Embedding model is warmed during startup so the first request no longer
pays the model-load cost.

Pre-existing breakages fixed:
- requirements.txt pinned llama-index-embeddings-fastembed>=0.4.0, which was
never published (only 0.1.2 exists), and 0.1.2 conflicts with the pinned
fastembed>=0.5.0 - the install could not resolve. Switched to
llama-index-embeddings-huggingface, same BAAI/bge-small-en-v1.5 model.
- Groq retired llama-3.3-70b-versatile; every query returned 404. Default is
now openai/gpt-oss-120b.
- Docker frontend stage used node:20-slim, below Vite 8's required Node range.
- The hf_cache volume mounted over a path the image never created, leaving it
root-owned so the non-root user could not write model downloads.

Adds tests for the delete and history endpoints (5 passing, no API key
required).

This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .dockerignore +20 -0
  2. .env.example +1 -1
  3. .gitignore +5 -0
  4. Dockerfile +15 -3
  5. README.md +64 -15
  6. app/config.py +2 -1
  7. app/main.py +89 -7
  8. app/models/schemas.py +31 -0
  9. app/services/history_service.py +136 -0
  10. app/services/rag_service.py +34 -2
  11. docker-compose.yml +3 -3
  12. frontend/.gitignore +24 -0
  13. frontend/.oxlintrc.json +8 -0
  14. frontend/README.md +32 -0
  15. frontend/index.html +14 -0
  16. frontend/package-lock.json +1337 -0
  17. frontend/package.json +28 -0
  18. frontend/public/favicon.svg +1 -0
  19. frontend/public/icons.svg +24 -0
  20. frontend/src/App.tsx +82 -0
  21. frontend/src/api/client.ts +190 -0
  22. frontend/src/api/types.ts +123 -0
  23. frontend/src/components/ChatView.tsx +212 -0
  24. frontend/src/components/Sidebar.tsx +174 -0
  25. frontend/src/components/SummarizeView.tsx +105 -0
  26. frontend/src/components/UploadView.tsx +248 -0
  27. frontend/src/components/WebImportView.tsx +84 -0
  28. frontend/src/components/chat.css +184 -0
  29. frontend/src/components/shared/Loading.tsx +7 -0
  30. frontend/src/components/shared/MarkdownRenderer.tsx +20 -0
  31. frontend/src/components/shared/Toast.tsx +63 -0
  32. frontend/src/components/shared/toast.css +38 -0
  33. frontend/src/components/sidebar.css +334 -0
  34. frontend/src/components/summary.css +81 -0
  35. frontend/src/components/upload.css +138 -0
  36. frontend/src/components/web.css +35 -0
  37. frontend/src/context/SessionContext.tsx +115 -0
  38. frontend/src/context/ThemeContext.tsx +49 -0
  39. frontend/src/index.css +1 -0
  40. frontend/src/main.tsx +19 -0
  41. frontend/src/styles/global.css +278 -0
  42. frontend/src/styles/variables.css +46 -0
  43. frontend/tsconfig.app.json +26 -0
  44. frontend/tsconfig.json +7 -0
  45. frontend/tsconfig.node.json +23 -0
  46. frontend/vite.config.ts +34 -0
  47. requirements-dev.txt +2 -0
  48. requirements.txt +1 -2
  49. static/css/style.css +0 -807
  50. static/index.html +0 -194
.dockerignore ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ .venv/
5
+ venv/
6
+
7
+ # Frontend (built inside the image by the frontend-build stage)
8
+ frontend/node_modules/
9
+ frontend/dist/
10
+
11
+ # Local data / env
12
+ .env
13
+ uploads/*
14
+ chroma_store/
15
+ .git/
16
+ .gitignore
17
+
18
+ # IDE
19
+ .vscode/
20
+ .idea/
.env.example CHANGED
@@ -2,7 +2,7 @@
2
  GROQ_API_KEY=your_groq_api_key_here
3
 
4
  # Optional
5
- GROQ_MODEL=llama-3.3-70b-versatile
6
  EMBED_MODEL=BAAI/bge-small-en-v1.5
7
  HOST=0.0.0.0
8
  PORT=7860
 
2
  GROQ_API_KEY=your_groq_api_key_here
3
 
4
  # Optional
5
+ GROQ_MODEL=openai/gpt-oss-120b
6
  EMBED_MODEL=BAAI/bge-small-en-v1.5
7
  HOST=0.0.0.0
8
  PORT=7860
.gitignore CHANGED
@@ -45,3 +45,8 @@ chroma_store/
45
  # OS
46
  .DS_Store
47
  Thumbs.db
 
 
 
 
 
 
45
  # OS
46
  .DS_Store
47
  Thumbs.db
48
+
49
+ # Frontend build artifacts (regenerated via `npm run build` in frontend/)
50
+ frontend/node_modules/
51
+ frontend/dist/
52
+ static/
Dockerfile CHANGED
@@ -1,3 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
  FROM python:3.12-slim
2
 
3
  RUN useradd -m -u 1000 user
@@ -14,8 +26,9 @@ RUN pip install --no-cache-dir --upgrade pip && \
14
  pip install --no-cache-dir -r requirements.txt
15
 
16
  COPY --chown=user:user . .
 
17
 
18
- RUN mkdir -p uploads chroma_store static/css static/js && \
19
  chown -R user:user /app
20
 
21
  USER user
@@ -24,8 +37,7 @@ ENV HOME=/home/user \
24
  PATH=/home/user/.local/bin:$PATH \
25
  PYTHONUNBUFFERED=1 \
26
  PYTHONDONTWRITEBYTECODE=1 \
27
- HF_HOME=/app/.cache/huggingface \
28
- FASTEMBED_CACHE_PATH=/app/.cache/fastembed
29
 
30
  EXPOSE 7860
31
 
 
1
+ # ---- frontend build stage ----
2
+ FROM node:22-slim AS frontend-build
3
+
4
+ WORKDIR /frontend
5
+
6
+ COPY frontend/package.json frontend/package-lock.json ./
7
+ RUN npm ci
8
+
9
+ COPY frontend/ .
10
+ RUN npm run build
11
+
12
+ # ---- python runtime stage ----
13
  FROM python:3.12-slim
14
 
15
  RUN useradd -m -u 1000 user
 
26
  pip install --no-cache-dir -r requirements.txt
27
 
28
  COPY --chown=user:user . .
29
+ COPY --from=frontend-build --chown=user:user /frontend/dist ./static
30
 
31
+ RUN mkdir -p uploads chroma_store .cache/huggingface && \
32
  chown -R user:user /app
33
 
34
  USER user
 
37
  PATH=/home/user/.local/bin:$PATH \
38
  PYTHONUNBUFFERED=1 \
39
  PYTHONDONTWRITEBYTECODE=1 \
40
+ HF_HOME=/app/.cache/huggingface
 
41
 
42
  EXPOSE 7860
43
 
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: Studyrag
3
- emoji: 🏃
4
  colorFrom: blue
5
  colorTo: green
6
  sdk: docker
@@ -9,17 +9,21 @@ pinned: false
9
 
10
  # Studyson — RAG Document QA & Summarization
11
 
12
- A full-stack Retrieval-Augmented Generation (RAG) app for document Q&A, conversational chat, and summarization. Built with FastAPI, LlamaIndex, Groq, and a persistent Chroma vector store.
13
 
14
  ## Features
15
 
16
  - **Multi-format ingestion** — PDF, DOCX, TXT, and Markdown files
 
17
  - **Web scraping** — Index any HTML page (with timeout, size cap, and content-type guard)
18
  - **Conversational chat** — Multi-turn Q&A with per-session memory
 
 
19
  - **Persistent vector store** — Chroma on disk; index survives restarts
20
  - **Smart summarization** — Length-controlled summaries across all indexed documents
21
  - **Source citations** — Verifiable snippets with similarity scores
22
- - **Real-time streaming** — Token-by-token Server-Sent Events
 
23
  - **Markdown rendering** — Chat answers render with code blocks, lists, and headings
24
 
25
  ## Tech Stack
@@ -28,25 +32,31 @@ A full-stack Retrieval-Augmented Generation (RAG) app for document Q&A, conversa
28
  |-------|---------|
29
  | Web framework | FastAPI `>=0.118` |
30
  | RAG orchestration | LlamaIndex `>=0.14` |
31
- | LLM | Groq `llama-3.3-70b-versatile` |
32
- | Embeddings | FastEmbed `BAAI/bge-small-en-v1.5` |
33
  | Vector store | Chroma `>=0.6` (persistent) |
 
34
  | Document parsing | PyMuPDF · pypdf · python-docx |
35
  | HTTP client | httpx (async, with timeouts) |
36
- | Frontend | Vanilla JS + marked + DOMPurify |
37
 
38
  ## API Endpoints
39
 
40
  | Method | Endpoint | Description |
41
  |--------|----------|-------------|
42
- | `GET` | `/` | Web UI |
43
  | `POST` | `/upload` | Upload PDF, DOCX, TXT, or MD |
44
  | `POST` | `/scrape_and_index` | Scrape and index a URL |
 
45
  | `POST` | `/stream_query` | SSE streaming Q&A (per-session chat memory) |
46
  | `POST` | `/query` | One-shot Q&A with source citations |
47
  | `POST` | `/summarize` | Summarize all indexed content |
48
- | `POST` | `/reset` | Drop the index and clear all sessions |
49
  | `GET` | `/status` | System status, indexed docs, active model |
 
 
 
 
50
 
51
  ## Configuration
52
 
@@ -55,30 +65,60 @@ Set via HF Space secrets or a `.env` file locally:
55
  | Variable | Default | Purpose |
56
  |----------|---------|---------|
57
  | `GROQ_API_KEY` | *(required)* | Groq API key |
58
- | `GROQ_MODEL` | `llama-3.3-70b-versatile` | Groq chat model |
59
  | `EMBED_MODEL` | `BAAI/bge-small-en-v1.5` | Embedding model |
60
  | `MAX_FILE_SIZE` | `20971520` (20 MB) | Upload size limit |
61
  | `MAX_SCRAPE_BYTES` | `5242880` (5 MB) | Scrape body cap |
62
  | `SIMILARITY_TOP_K` | `4` | Retrieval top-k |
 
63
 
64
  ## Local Development
65
 
 
 
 
66
  ```bash
67
  git clone <repo-url>
68
- cd studyrag
69
- python -m venv venv && source venv/bin/activate
70
- pip install -r requirements.txt
71
  cp .env.example .env # add your GROQ_API_KEY
 
 
72
  uvicorn app.main:app --reload --port 7860
 
 
 
 
 
 
 
 
 
 
73
  ```
74
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  ## Docker
76
 
77
  ```bash
78
  docker compose up --build
79
  ```
80
 
81
- Volumes persist `uploads/`, `chroma_store/`, and the FastEmbed model cache across restarts.
 
 
82
 
83
  ## Deploying on Hugging Face Spaces
84
 
@@ -88,12 +128,21 @@ Volumes persist `uploads/`, `chroma_store/`, and the FastEmbed model cache acros
88
  4. Add `GROQ_API_KEY` under **Settings → Variables and secrets**
89
  5. The Space auto-builds and serves on port 7860
90
 
91
- > **Note:** The Chroma store and uploads persist within the Space filesystem but are wiped on a factory reset.
 
 
 
 
 
 
 
 
 
92
 
93
  ## Acknowledgments
94
 
95
  - [LlamaIndex](https://www.llamaindex.ai/)
96
  - [Groq](https://groq.com/)
97
  - [Chroma](https://www.trychroma.com/)
98
- - [FastEmbed](https://github.com/qdrant/fastembed)
99
  - [FastAPI](https://fastapi.tiangolo.com/)
 
 
1
  ---
2
  title: Studyrag
3
+ emoji: 🏃
4
  colorFrom: blue
5
  colorTo: green
6
  sdk: docker
 
9
 
10
  # Studyson — RAG Document QA & Summarization
11
 
12
+ A full-stack Retrieval-Augmented Generation (RAG) app for document Q&A, conversational chat, and summarization. Built with FastAPI, LlamaIndex, Groq, and a persistent Chroma vector store, with a React + Vite frontend.
13
 
14
  ## Features
15
 
16
  - **Multi-format ingestion** — PDF, DOCX, TXT, and Markdown files
17
+ - **Multi-file upload** — Drop several files at once; each tracks its own progress
18
  - **Web scraping** — Index any HTML page (with timeout, size cap, and content-type guard)
19
  - **Conversational chat** — Multi-turn Q&A with per-session memory
20
+ - **Persistent chat history** — Transcripts stored in SQLite; survives reloads and restarts
21
+ - **Document management** — List indexed documents and delete them individually
22
  - **Persistent vector store** — Chroma on disk; index survives restarts
23
  - **Smart summarization** — Length-controlled summaries across all indexed documents
24
  - **Source citations** — Verifiable snippets with similarity scores
25
+ - **Real-time streaming** — Token-by-token Server-Sent Events, cancellable mid-answer
26
+ - **Dark mode** — Follows system preference, with a manual toggle
27
  - **Markdown rendering** — Chat answers render with code blocks, lists, and headings
28
 
29
  ## Tech Stack
 
32
  |-------|---------|
33
  | Web framework | FastAPI `>=0.118` |
34
  | RAG orchestration | LlamaIndex `>=0.14` |
35
+ | LLM | Groq `openai/gpt-oss-120b` |
36
+ | Embeddings | HuggingFace `BAAI/bge-small-en-v1.5` |
37
  | Vector store | Chroma `>=0.6` (persistent) |
38
+ | Chat history | SQLite (stdlib `sqlite3`) |
39
  | Document parsing | PyMuPDF · pypdf · python-docx |
40
  | HTTP client | httpx (async, with timeouts) |
41
+ | Frontend | React 19 + Vite + TypeScript |
42
 
43
  ## API Endpoints
44
 
45
  | Method | Endpoint | Description |
46
  |--------|----------|-------------|
47
+ | `GET` | `/` | Web UI (React SPA) |
48
  | `POST` | `/upload` | Upload PDF, DOCX, TXT, or MD |
49
  | `POST` | `/scrape_and_index` | Scrape and index a URL |
50
+ | `DELETE` | `/documents/{name}` | Remove one indexed document |
51
  | `POST` | `/stream_query` | SSE streaming Q&A (per-session chat memory) |
52
  | `POST` | `/query` | One-shot Q&A with source citations |
53
  | `POST` | `/summarize` | Summarize all indexed content |
54
+ | `POST` | `/reset` | Drop the document index (chat history is kept) |
55
  | `GET` | `/status` | System status, indexed docs, active model |
56
+ | `GET` | `/sessions` | List chat sessions, most recent first |
57
+ | `GET` | `/sessions/{id}/messages` | Full transcript for one session |
58
+ | `PATCH` | `/sessions/{id}` | Rename a session |
59
+ | `DELETE` | `/sessions/{id}` | Delete a session and its messages |
60
 
61
  ## Configuration
62
 
 
65
  | Variable | Default | Purpose |
66
  |----------|---------|---------|
67
  | `GROQ_API_KEY` | *(required)* | Groq API key |
68
+ | `GROQ_MODEL` | `openai/gpt-oss-120b` | Groq chat model |
69
  | `EMBED_MODEL` | `BAAI/bge-small-en-v1.5` | Embedding model |
70
  | `MAX_FILE_SIZE` | `20971520` (20 MB) | Upload size limit |
71
  | `MAX_SCRAPE_BYTES` | `5242880` (5 MB) | Scrape body cap |
72
  | `SIMILARITY_TOP_K` | `4` | Retrieval top-k |
73
+ | `HISTORY_DB_NAME` | `history.db` | SQLite file inside `chroma_store/` |
74
 
75
  ## Local Development
76
 
77
+ The frontend and backend run as two processes in development. Vite proxies API
78
+ calls to FastAPI, so the app uses same-origin relative paths in both dev and prod.
79
+
80
  ```bash
81
  git clone <repo-url>
82
+ cd Exam
83
+ python -m venv .venv && source .venv/Scripts/activate # Windows: .venv\Scripts\activate
84
+ pip install -r requirements-dev.txt
85
  cp .env.example .env # add your GROQ_API_KEY
86
+
87
+ # terminal 1 — backend
88
  uvicorn app.main:app --reload --port 7860
89
+
90
+ # terminal 2 — frontend (http://localhost:5173)
91
+ cd frontend && npm install && npm run dev
92
+ ```
93
+
94
+ To serve the built frontend directly from FastAPI (no Vite process), build it
95
+ into `static/` first:
96
+
97
+ ```bash
98
+ cd frontend && npm run build && cp -r dist/* ../static/
99
  ```
100
 
101
+ > `static/` is a build artifact and is gitignored — it is always regenerated
102
+ > from `frontend/`, never edited by hand.
103
+
104
+ ### Tests
105
+
106
+ ```bash
107
+ pytest tests/ -v
108
+ ```
109
+
110
+ Covers the document-delete and chat-history endpoints. These tests avoid the LLM
111
+ and embedding model entirely, so they need no network access or API key.
112
+
113
  ## Docker
114
 
115
  ```bash
116
  docker compose up --build
117
  ```
118
 
119
+ The Dockerfile is a multi-stage build: a Node stage compiles the React app, and
120
+ the Python stage copies the output into `static/`. Volumes persist `uploads/`,
121
+ `chroma_store/` (which also holds `history.db`), and the HuggingFace model cache.
122
 
123
  ## Deploying on Hugging Face Spaces
124
 
 
128
  4. Add `GROQ_API_KEY` under **Settings → Variables and secrets**
129
  5. The Space auto-builds and serves on port 7860
130
 
131
+ > **Note:** The Chroma store, chat history, and uploads persist within the Space
132
+ > filesystem but are wiped on a factory reset.
133
+
134
+ ## Performance Notes
135
+
136
+ - `/stream_query` retrieves citation sources with a **retrieval-only** call
137
+ rather than a second full LLM generation, saving roughly 0.6s and one wasted
138
+ LLM call per message.
139
+ - The embedding model is warmed at application startup (~6s), so the first user
140
+ request no longer pays the model-load cost.
141
 
142
  ## Acknowledgments
143
 
144
  - [LlamaIndex](https://www.llamaindex.ai/)
145
  - [Groq](https://groq.com/)
146
  - [Chroma](https://www.trychroma.com/)
 
147
  - [FastAPI](https://fastapi.tiangolo.com/)
148
+ - [Vite](https://vite.dev/)
app/config.py CHANGED
@@ -4,7 +4,7 @@ from pathlib import Path
4
 
5
  class Settings(BaseSettings):
6
  groq_api_key: str
7
- groq_model: str = "llama-3.3-70b-versatile"
8
  embed_model: str = "BAAI/bge-small-en-v1.5"
9
 
10
  host: str = "0.0.0.0"
@@ -12,6 +12,7 @@ class Settings(BaseSettings):
12
 
13
  upload_dir: Path = Path("uploads")
14
  chroma_dir: Path = Path("chroma_store")
 
15
 
16
  max_file_size: int = 20 * 1024 * 1024
17
  max_scrape_bytes: int = 5 * 1024 * 1024
 
4
 
5
  class Settings(BaseSettings):
6
  groq_api_key: str
7
+ groq_model: str = "openai/gpt-oss-120b"
8
  embed_model: str = "BAAI/bge-small-en-v1.5"
9
 
10
  host: str = "0.0.0.0"
 
12
 
13
  upload_dir: Path = Path("uploads")
14
  chroma_dir: Path = Path("chroma_store")
15
+ history_db_name: str = "history.db"
16
 
17
  max_file_size: int = 20 * 1024 * 1024
18
  max_scrape_bytes: int = 5 * 1024 * 1024
app/main.py CHANGED
@@ -1,7 +1,9 @@
 
1
  import json
2
  import logging
3
  import uuid
4
  from contextlib import asynccontextmanager
 
5
  from typing import AsyncGenerator
6
 
7
  from fastapi import FastAPI, File, HTTPException, UploadFile
@@ -11,13 +13,19 @@ from fastapi.staticfiles import StaticFiles
11
 
12
  from app.config import settings
13
  from app.models.schemas import (
 
 
14
  FinalResponse,
15
  QueryRequest,
 
16
  ScrapeRequest,
 
 
17
  StatusResponse,
18
  SummarizeRequest,
19
  SummaryResponse,
20
  )
 
21
  from app.services.rag_service import RAGService
22
  from app.utils.document_processor import ALLOWED_EXTENSIONS, DocumentProcessor
23
 
@@ -30,6 +38,12 @@ async def lifespan(_: FastAPI):
30
  settings.upload_dir.mkdir(parents=True, exist_ok=True)
31
  settings.chroma_dir.mkdir(parents=True, exist_ok=True)
32
  logger.info("Studyson starting | model=%s | chroma=%s", settings.groq_model, settings.chroma_dir)
 
 
 
 
 
 
33
  yield
34
 
35
 
@@ -50,13 +64,9 @@ app.add_middleware(
50
 
51
  rag_service = RAGService()
52
  doc_processor = DocumentProcessor()
 
53
 
54
- app.mount("/static", StaticFiles(directory="static"), name="static")
55
-
56
-
57
- @app.get("/")
58
- async def read_root():
59
- return FileResponse("static/index.html")
60
 
61
 
62
  @app.post("/upload", response_model=StatusResponse)
@@ -137,6 +147,26 @@ async def scrape_and_index(request: ScrapeRequest):
137
  raise HTTPException(status_code=500, detail=f"Error scraping URL: {e}")
138
 
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  def _resolve_session(session_id: str | None) -> str:
141
  return session_id or str(uuid.uuid4())
142
 
@@ -152,13 +182,18 @@ async def stream_query(request: QueryRequest):
152
  try:
153
  yield f"data: {json.dumps({'session_id': session_id})}\n\n"
154
 
 
 
 
 
 
155
  answer_parts: list[str] = []
156
  async for token in rag_service.stream_query(request.question, session_id):
157
  answer_parts.append(token)
158
  yield f"data: {json.dumps({'token': token})}\n\n"
159
 
160
  full_answer = "".join(answer_parts)
161
- _, sources = await rag_service.query(request.question)
162
 
163
  final = FinalResponse(
164
  final_answer=full_answer,
@@ -166,6 +201,18 @@ async def stream_query(request: QueryRequest):
166
  )
167
  yield "data: [DONE]\n\n"
168
  yield f"data: {json.dumps(final.model_dump())}\n\n"
 
 
 
 
 
 
 
 
 
 
 
 
169
  except Exception as e:
170
  logger.exception("Stream query failed")
171
  yield f"data: {json.dumps({'error': str(e)})}\n\n"
@@ -238,6 +285,41 @@ async def get_status():
238
  )
239
 
240
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  if __name__ == "__main__":
242
  import uvicorn
243
 
 
1
+ import asyncio
2
  import json
3
  import logging
4
  import uuid
5
  from contextlib import asynccontextmanager
6
+ from pathlib import Path
7
  from typing import AsyncGenerator
8
 
9
  from fastapi import FastAPI, File, HTTPException, UploadFile
 
13
 
14
  from app.config import settings
15
  from app.models.schemas import (
16
+ ChatMessage,
17
+ DeleteDocumentResponse,
18
  FinalResponse,
19
  QueryRequest,
20
+ RenameSessionRequest,
21
  ScrapeRequest,
22
+ SessionMessagesResponse,
23
+ SessionSummary,
24
  StatusResponse,
25
  SummarizeRequest,
26
  SummaryResponse,
27
  )
28
+ from app.services.history_service import HistoryService
29
  from app.services.rag_service import RAGService
30
  from app.utils.document_processor import ALLOWED_EXTENSIONS, DocumentProcessor
31
 
 
38
  settings.upload_dir.mkdir(parents=True, exist_ok=True)
39
  settings.chroma_dir.mkdir(parents=True, exist_ok=True)
40
  logger.info("Studyson starting | model=%s | chroma=%s", settings.groq_model, settings.chroma_dir)
41
+
42
+ # Warm the embedding model at startup so the first user request doesn't
43
+ # pay the model-load cost (several seconds on a cold container).
44
+ await asyncio.to_thread(rag_service.warm_up)
45
+ logger.info("Embedding model warm | embed_model=%s", settings.embed_model)
46
+
47
  yield
48
 
49
 
 
64
 
65
  rag_service = RAGService()
66
  doc_processor = DocumentProcessor()
67
+ history_service = HistoryService(settings.chroma_dir / settings.history_db_name)
68
 
69
+ app.mount("/assets", StaticFiles(directory="static/assets"), name="assets")
 
 
 
 
 
70
 
71
 
72
  @app.post("/upload", response_model=StatusResponse)
 
147
  raise HTTPException(status_code=500, detail=f"Error scraping URL: {e}")
148
 
149
 
150
+ @app.delete("/documents/{document_name}", response_model=DeleteDocumentResponse)
151
+ async def delete_document(document_name: str):
152
+ try:
153
+ rag_service.delete_document(document_name)
154
+ file_path = settings.upload_dir / document_name
155
+ if file_path.exists() and file_path.is_file():
156
+ file_path.unlink(missing_ok=True)
157
+ return DeleteDocumentResponse(
158
+ status="success",
159
+ message=f"Document '{document_name}' removed",
160
+ deleted=document_name,
161
+ indexed_documents=rag_service.get_indexed_documents(),
162
+ )
163
+ except ValueError as e:
164
+ raise HTTPException(status_code=404, detail=str(e))
165
+ except Exception as e:
166
+ logger.exception("Delete failed for %s", document_name)
167
+ raise HTTPException(status_code=500, detail=f"Error deleting document: {e}")
168
+
169
+
170
  def _resolve_session(session_id: str | None) -> str:
171
  return session_id or str(uuid.uuid4())
172
 
 
182
  try:
183
  yield f"data: {json.dumps({'session_id': session_id})}\n\n"
184
 
185
+ try:
186
+ await asyncio.to_thread(history_service.add_message, session_id, "user", request.question)
187
+ except Exception:
188
+ logger.exception("Failed to persist user message for session %s", session_id)
189
+
190
  answer_parts: list[str] = []
191
  async for token in rag_service.stream_query(request.question, session_id):
192
  answer_parts.append(token)
193
  yield f"data: {json.dumps({'token': token})}\n\n"
194
 
195
  full_answer = "".join(answer_parts)
196
+ sources = await rag_service.retrieve_sources(request.question)
197
 
198
  final = FinalResponse(
199
  final_answer=full_answer,
 
201
  )
202
  yield "data: [DONE]\n\n"
203
  yield f"data: {json.dumps(final.model_dump())}\n\n"
204
+
205
+ try:
206
+ await asyncio.to_thread(
207
+ history_service.add_message,
208
+ session_id,
209
+ "assistant",
210
+ full_answer,
211
+ [s.model_dump() for s in sources],
212
+ )
213
+ await asyncio.to_thread(history_service.touch_session, session_id)
214
+ except Exception:
215
+ logger.exception("Failed to persist assistant message for session %s", session_id)
216
  except Exception as e:
217
  logger.exception("Stream query failed")
218
  yield f"data: {json.dumps({'error': str(e)})}\n\n"
 
285
  )
286
 
287
 
288
+ @app.get("/sessions", response_model=list[SessionSummary])
289
+ async def list_sessions():
290
+ return await asyncio.to_thread(history_service.list_sessions)
291
+
292
+
293
+ @app.get("/sessions/{session_id}/messages", response_model=SessionMessagesResponse)
294
+ async def get_session_messages(session_id: str):
295
+ messages = await asyncio.to_thread(history_service.get_messages, session_id)
296
+ return SessionMessagesResponse(
297
+ session_id=session_id,
298
+ messages=[ChatMessage(**m) for m in messages],
299
+ )
300
+
301
+
302
+ @app.patch("/sessions/{session_id}", response_model=StatusResponse)
303
+ async def rename_session(session_id: str, request: RenameSessionRequest):
304
+ await asyncio.to_thread(history_service.rename_session, session_id, request.title)
305
+ return StatusResponse(status="success", message="Session renamed")
306
+
307
+
308
+ @app.delete("/sessions/{session_id}", response_model=StatusResponse)
309
+ async def delete_session(session_id: str):
310
+ await asyncio.to_thread(history_service.delete_session, session_id)
311
+ rag_service.reset_session(session_id)
312
+ return StatusResponse(status="success", message="Session deleted")
313
+
314
+
315
+ @app.get("/{full_path:path}")
316
+ async def spa_fallback(full_path: str):
317
+ candidate = Path("static") / full_path
318
+ if full_path and candidate.is_file():
319
+ return FileResponse(candidate)
320
+ return FileResponse("static/index.html")
321
+
322
+
323
  if __name__ == "__main__":
324
  import uvicorn
325
 
app/models/schemas.py CHANGED
@@ -39,3 +39,34 @@ class StatusResponse(BaseModel):
39
  status: str
40
  message: str
41
  details: Optional[dict] = None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  status: str
40
  message: str
41
  details: Optional[dict] = None
42
+
43
+
44
+ class DeleteDocumentResponse(BaseModel):
45
+ status: str
46
+ message: str
47
+ deleted: str
48
+ indexed_documents: List[str]
49
+
50
+
51
+ class ChatMessage(BaseModel):
52
+ role: str # "user" | "assistant"
53
+ content: str
54
+ sources: Optional[List[SourceInfo]] = None
55
+ created_at: str
56
+
57
+
58
+ class SessionSummary(BaseModel):
59
+ session_id: str
60
+ title: Optional[str] = None
61
+ created_at: str
62
+ updated_at: str
63
+ message_count: int
64
+
65
+
66
+ class SessionMessagesResponse(BaseModel):
67
+ session_id: str
68
+ messages: List[ChatMessage]
69
+
70
+
71
+ class RenameSessionRequest(BaseModel):
72
+ title: str = Field(..., min_length=1, max_length=200)
app/services/history_service.py ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import sqlite3
3
+ from datetime import datetime, timezone
4
+ from pathlib import Path
5
+ from typing import Optional
6
+
7
+ SCHEMA = """
8
+ CREATE TABLE IF NOT EXISTS sessions (
9
+ session_id TEXT PRIMARY KEY,
10
+ title TEXT,
11
+ created_at TEXT NOT NULL,
12
+ updated_at TEXT NOT NULL
13
+ );
14
+
15
+ CREATE TABLE IF NOT EXISTS messages (
16
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
17
+ session_id TEXT NOT NULL REFERENCES sessions(session_id) ON DELETE CASCADE,
18
+ role TEXT NOT NULL CHECK (role IN ('user', 'assistant')),
19
+ content TEXT NOT NULL,
20
+ sources_json TEXT,
21
+ created_at TEXT NOT NULL
22
+ );
23
+ CREATE INDEX IF NOT EXISTS idx_messages_session ON messages(session_id, id);
24
+ """
25
+
26
+
27
+ def _now() -> str:
28
+ return datetime.now(timezone.utc).isoformat()
29
+
30
+
31
+ class HistoryService:
32
+ """Persistent, SQLite-backed chat session/message history."""
33
+
34
+ def __init__(self, db_path: Path) -> None:
35
+ db_path.parent.mkdir(parents=True, exist_ok=True)
36
+ self._db_path = db_path
37
+ self._init_schema()
38
+
39
+ def _connect(self) -> sqlite3.Connection:
40
+ conn = sqlite3.connect(self._db_path)
41
+ conn.execute("PRAGMA foreign_keys = ON")
42
+ conn.row_factory = sqlite3.Row
43
+ return conn
44
+
45
+ def _init_schema(self) -> None:
46
+ with self._connect() as conn:
47
+ conn.executescript(SCHEMA)
48
+
49
+ def ensure_session(self, session_id: str) -> None:
50
+ now = _now()
51
+ with self._connect() as conn:
52
+ conn.execute(
53
+ "INSERT OR IGNORE INTO sessions (session_id, title, created_at, updated_at) "
54
+ "VALUES (?, NULL, ?, ?)",
55
+ (session_id, now, now),
56
+ )
57
+
58
+ def touch_session(self, session_id: str) -> None:
59
+ with self._connect() as conn:
60
+ conn.execute(
61
+ "UPDATE sessions SET updated_at = ? WHERE session_id = ?",
62
+ (_now(), session_id),
63
+ )
64
+
65
+ def add_message(
66
+ self,
67
+ session_id: str,
68
+ role: str,
69
+ content: str,
70
+ sources: Optional[list[dict]] = None,
71
+ ) -> None:
72
+ self.ensure_session(session_id)
73
+ with self._connect() as conn:
74
+ conn.execute(
75
+ "INSERT INTO messages (session_id, role, content, sources_json, created_at) "
76
+ "VALUES (?, ?, ?, ?, ?)",
77
+ (
78
+ session_id,
79
+ role,
80
+ content,
81
+ json.dumps(sources) if sources else None,
82
+ _now(),
83
+ ),
84
+ )
85
+
86
+ def get_messages(self, session_id: str) -> list[dict]:
87
+ with self._connect() as conn:
88
+ rows = conn.execute(
89
+ "SELECT role, content, sources_json, created_at FROM messages "
90
+ "WHERE session_id = ? ORDER BY id ASC",
91
+ (session_id,),
92
+ ).fetchall()
93
+ return [
94
+ {
95
+ "role": row["role"],
96
+ "content": row["content"],
97
+ "sources": json.loads(row["sources_json"]) if row["sources_json"] else None,
98
+ "created_at": row["created_at"],
99
+ }
100
+ for row in rows
101
+ ]
102
+
103
+ def list_sessions(self) -> list[dict]:
104
+ with self._connect() as conn:
105
+ rows = conn.execute(
106
+ """
107
+ SELECT s.session_id, s.title, s.created_at, s.updated_at,
108
+ COUNT(m.id) AS message_count
109
+ FROM sessions s
110
+ LEFT JOIN messages m ON m.session_id = s.session_id
111
+ GROUP BY s.session_id
112
+ ORDER BY s.updated_at DESC
113
+ """
114
+ ).fetchall()
115
+ return [
116
+ {
117
+ "session_id": row["session_id"],
118
+ "title": row["title"],
119
+ "created_at": row["created_at"],
120
+ "updated_at": row["updated_at"],
121
+ "message_count": row["message_count"],
122
+ }
123
+ for row in rows
124
+ ]
125
+
126
+ def rename_session(self, session_id: str, title: str) -> None:
127
+ self.ensure_session(session_id)
128
+ with self._connect() as conn:
129
+ conn.execute(
130
+ "UPDATE sessions SET title = ?, updated_at = ? WHERE session_id = ?",
131
+ (title, _now(), session_id),
132
+ )
133
+
134
+ def delete_session(self, session_id: str) -> None:
135
+ with self._connect() as conn:
136
+ conn.execute("DELETE FROM sessions WHERE session_id = ?", (session_id,))
app/services/rag_service.py CHANGED
@@ -5,7 +5,7 @@ from threading import Lock
5
  import chromadb
6
  from llama_index.core import Document, Settings, StorageContext, VectorStoreIndex
7
  from llama_index.core.chat_engine.types import BaseChatEngine
8
- from llama_index.embeddings.fastembed import FastEmbedEmbedding
9
  from llama_index.llms.groq import Groq
10
  from llama_index.vector_stores.chroma import ChromaVectorStore
11
 
@@ -24,7 +24,7 @@ def _ensure_llm() -> None:
24
  return
25
  os.environ["GROQ_API_KEY"] = settings.groq_api_key
26
  Settings.llm = Groq(model=settings.groq_model, api_key=settings.groq_api_key)
27
- Settings.embed_model = FastEmbedEmbedding(model_name=settings.embed_model)
28
  _llm_initialized = True
29
 
30
 
@@ -66,6 +66,18 @@ class RAGService:
66
  self._indexed_documents.append(source_name)
67
  self._chat_engines.clear()
68
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  def _get_chat_engine(self, session_id: str) -> BaseChatEngine:
70
  engine = self._chat_engines.get(session_id)
71
  if engine is None:
@@ -88,6 +100,26 @@ class RAGService:
88
  async for token in response.async_response_gen():
89
  yield token
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  async def query(self, question: str) -> tuple[str, List[SourceInfo]]:
92
  if not self.has_documents():
93
  raise ValueError("No documents indexed.")
 
5
  import chromadb
6
  from llama_index.core import Document, Settings, StorageContext, VectorStoreIndex
7
  from llama_index.core.chat_engine.types import BaseChatEngine
8
+ from llama_index.embeddings.huggingface import HuggingFaceEmbedding
9
  from llama_index.llms.groq import Groq
10
  from llama_index.vector_stores.chroma import ChromaVectorStore
11
 
 
24
  return
25
  os.environ["GROQ_API_KEY"] = settings.groq_api_key
26
  Settings.llm = Groq(model=settings.groq_model, api_key=settings.groq_api_key)
27
+ Settings.embed_model = HuggingFaceEmbedding(model_name=settings.embed_model)
28
  _llm_initialized = True
29
 
30
 
 
66
  self._indexed_documents.append(source_name)
67
  self._chat_engines.clear()
68
 
69
+ def warm_up(self) -> None:
70
+ """Initialize the LLM/embedding models ahead of the first request."""
71
+ _ensure_llm()
72
+
73
+ def delete_document(self, source_name: str) -> None:
74
+ if source_name not in self._indexed_documents:
75
+ raise ValueError(f"Document '{source_name}' is not indexed.")
76
+ self._collection.delete(where={"source": source_name})
77
+ self._indexed_documents = [d for d in self._indexed_documents if d != source_name]
78
+ self._chat_engines.clear()
79
+ self._index = None
80
+
81
  def _get_chat_engine(self, session_id: str) -> BaseChatEngine:
82
  engine = self._chat_engines.get(session_id)
83
  if engine is None:
 
100
  async for token in response.async_response_gen():
101
  yield token
102
 
103
+ async def retrieve_sources(self, question: str) -> List[SourceInfo]:
104
+ """Fetch citation sources without running a second LLM generation.
105
+
106
+ Used by /stream_query, where the answer text already came from the
107
+ streaming chat engine and only the source nodes are still needed.
108
+ """
109
+ if not self.has_documents():
110
+ raise ValueError("No documents indexed.")
111
+ index = self._ensure_index()
112
+ retriever = index.as_retriever(similarity_top_k=settings.similarity_top_k)
113
+ nodes = await retriever.aretrieve(question)
114
+ return [
115
+ SourceInfo(
116
+ file_name=node.metadata.get("source", "Unknown"),
117
+ text=node.text[:300],
118
+ score=getattr(node, "score", None),
119
+ )
120
+ for node in nodes
121
+ ]
122
+
123
  async def query(self, question: str) -> tuple[str, List[SourceInfo]]:
124
  if not self.has_documents():
125
  raise ValueError("No documents indexed.")
docker-compose.yml CHANGED
@@ -5,13 +5,13 @@ services:
5
  - "7860:7860"
6
  environment:
7
  - GROQ_API_KEY=${GROQ_API_KEY}
8
- - GROQ_MODEL=${GROQ_MODEL:-llama-3.3-70b-versatile}
9
  - HOST=0.0.0.0
10
  - PORT=7860
11
  volumes:
12
  - ./uploads:/app/uploads
13
  - ./chroma_store:/app/chroma_store
14
- - fastembed_cache:/app/.cache/fastembed
15
  restart: unless-stopped
16
  healthcheck:
17
  test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:7860/status', timeout=3)"]
@@ -21,4 +21,4 @@ services:
21
  start_period: 30s
22
 
23
  volumes:
24
- fastembed_cache:
 
5
  - "7860:7860"
6
  environment:
7
  - GROQ_API_KEY=${GROQ_API_KEY}
8
+ - GROQ_MODEL=${GROQ_MODEL:-openai/gpt-oss-120b}
9
  - HOST=0.0.0.0
10
  - PORT=7860
11
  volumes:
12
  - ./uploads:/app/uploads
13
  - ./chroma_store:/app/chroma_store
14
+ - hf_cache:/app/.cache/huggingface
15
  restart: unless-stopped
16
  healthcheck:
17
  test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:7860/status', timeout=3)"]
 
21
  start_period: 30s
22
 
23
  volumes:
24
+ hf_cache:
frontend/.gitignore ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ dist
12
+ dist-ssr
13
+ *.local
14
+
15
+ # Editor directories and files
16
+ .vscode/*
17
+ !.vscode/extensions.json
18
+ .idea
19
+ .DS_Store
20
+ *.suo
21
+ *.ntvs*
22
+ *.njsproj
23
+ *.sln
24
+ *.sw?
frontend/.oxlintrc.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "$schema": "./node_modules/oxlint/configuration_schema.json",
3
+ "plugins": ["react", "typescript", "oxc"],
4
+ "rules": {
5
+ "react/rules-of-hooks": "error",
6
+ "react/only-export-components": ["warn", { "allowConstantExport": true }]
7
+ }
8
+ }
frontend/README.md ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # React + TypeScript + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some Oxlint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
9
+
10
+ ## React Compiler
11
+
12
+ The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13
+
14
+ ## Expanding the Oxlint configuration
15
+
16
+ If you are developing a production application, we recommend enabling type-aware lint rules by installing `oxlint-tsgolint` and editing `.oxlintrc.json`:
17
+
18
+ ```json
19
+ {
20
+ "$schema": "./node_modules/oxlint/configuration_schema.json",
21
+ "plugins": ["react", "typescript", "oxc"],
22
+ "options": {
23
+ "typeAware": true
24
+ },
25
+ "rules": {
26
+ "react/rules-of-hooks": "error",
27
+ "react/only-export-components": ["warn", { "allowConstantExport": true }]
28
+ }
29
+ }
30
+ ```
31
+
32
+ See the [Oxlint rules documentation](https://oxc.rs/docs/guide/usage/linter/rules) for the full list of rules and categories.
frontend/index.html ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Studyson - Smart Document Assistant</title>
8
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
9
+ </head>
10
+ <body>
11
+ <div id="root"></div>
12
+ <script type="module" src="/src/main.tsx"></script>
13
+ </body>
14
+ </html>
frontend/package-lock.json ADDED
@@ -0,0 +1,1337 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "frontend",
3
+ "version": "0.0.0",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "frontend",
9
+ "version": "0.0.0",
10
+ "dependencies": {
11
+ "dompurify": "^3.4.14",
12
+ "marked": "^18.0.10",
13
+ "react": "^19.2.8",
14
+ "react-dom": "^19.2.8"
15
+ },
16
+ "devDependencies": {
17
+ "@types/dompurify": "^3.0.5",
18
+ "@types/node": "^24.13.3",
19
+ "@types/react": "^19.2.17",
20
+ "@types/react-dom": "^19.2.3",
21
+ "@vitejs/plugin-react": "^6.0.4",
22
+ "oxlint": "^1.75.0",
23
+ "typescript": "~6.0.2",
24
+ "vite": "^8.2.0"
25
+ }
26
+ },
27
+ "node_modules/@oxc-project/types": {
28
+ "version": "0.146.0",
29
+ "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.146.0.tgz",
30
+ "integrity": "sha512-XC0QsnnhVe7sLIWmYmdPw7x5P0h4W8vUU3Nv1ySgWXtvCz8NizoAEpGXA0sOYoJQV2Rl13LgURAHQ5cI5ILCSA==",
31
+ "dev": true,
32
+ "license": "MIT",
33
+ "funding": {
34
+ "url": "https://github.com/sponsors/Boshen"
35
+ }
36
+ },
37
+ "node_modules/@oxlint/binding-android-arm-eabi": {
38
+ "version": "1.79.0",
39
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-android-arm-eabi/-/binding-android-arm-eabi-1.79.0.tgz",
40
+ "integrity": "sha512-TebFaaMklO/RXzTv7PucaCq9l3X6D1gA+C8H6K4njtjFOV+zWE9MKLpulcJZN9bzytbUbQIY0mZuz12nQ5Kv4Q==",
41
+ "cpu": [
42
+ "arm"
43
+ ],
44
+ "dev": true,
45
+ "license": "MIT",
46
+ "optional": true,
47
+ "os": [
48
+ "android"
49
+ ],
50
+ "engines": {
51
+ "node": "^20.19.0 || >=22.12.0"
52
+ }
53
+ },
54
+ "node_modules/@oxlint/binding-android-arm64": {
55
+ "version": "1.79.0",
56
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-android-arm64/-/binding-android-arm64-1.79.0.tgz",
57
+ "integrity": "sha512-KqqnOtAVgNsPPF0YSodkFZA1O80jcKoCZCTu3bgsszxA+MrMP9TLzfXitKjEj1FmrPprKDMdRDMmY3weESO9sg==",
58
+ "cpu": [
59
+ "arm64"
60
+ ],
61
+ "dev": true,
62
+ "license": "MIT",
63
+ "optional": true,
64
+ "os": [
65
+ "android"
66
+ ],
67
+ "engines": {
68
+ "node": "^20.19.0 || >=22.12.0"
69
+ }
70
+ },
71
+ "node_modules/@oxlint/binding-darwin-arm64": {
72
+ "version": "1.79.0",
73
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-darwin-arm64/-/binding-darwin-arm64-1.79.0.tgz",
74
+ "integrity": "sha512-BVC2nsMzqQzRDPc5RhixkZ+m1p7iH4bxRRvqkbwDXX0PlQKm1BPy8J8cRjnAFafOq2QzI+BfO3vE8w2GZ3CBag==",
75
+ "cpu": [
76
+ "arm64"
77
+ ],
78
+ "dev": true,
79
+ "license": "MIT",
80
+ "optional": true,
81
+ "os": [
82
+ "darwin"
83
+ ],
84
+ "engines": {
85
+ "node": "^20.19.0 || >=22.12.0"
86
+ }
87
+ },
88
+ "node_modules/@oxlint/binding-darwin-x64": {
89
+ "version": "1.79.0",
90
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-darwin-x64/-/binding-darwin-x64-1.79.0.tgz",
91
+ "integrity": "sha512-p6Lm+snmhGuLKL1+CpCV8L6ijkE/qJzK2H2jG9+eKJT0n31RbY4FLsdhexekgP3bLpw4Kgde+9DZuDZQ4yIInA==",
92
+ "cpu": [
93
+ "x64"
94
+ ],
95
+ "dev": true,
96
+ "license": "MIT",
97
+ "optional": true,
98
+ "os": [
99
+ "darwin"
100
+ ],
101
+ "engines": {
102
+ "node": "^20.19.0 || >=22.12.0"
103
+ }
104
+ },
105
+ "node_modules/@oxlint/binding-freebsd-x64": {
106
+ "version": "1.79.0",
107
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-freebsd-x64/-/binding-freebsd-x64-1.79.0.tgz",
108
+ "integrity": "sha512-qDMm0dXZnoHyRqSL4N4xUq82T4sqK5cbKSjvd/dF/YbMUXc2R1wEPf+vmA5S0qUmi0nwXfNbjXBtZaIqzQLIMg==",
109
+ "cpu": [
110
+ "x64"
111
+ ],
112
+ "dev": true,
113
+ "license": "MIT",
114
+ "optional": true,
115
+ "os": [
116
+ "freebsd"
117
+ ],
118
+ "engines": {
119
+ "node": "^20.19.0 || >=22.12.0"
120
+ }
121
+ },
122
+ "node_modules/@oxlint/binding-linux-arm-gnueabihf": {
123
+ "version": "1.79.0",
124
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.79.0.tgz",
125
+ "integrity": "sha512-2od7s0nuKPzqyUZAWk9KkCyGg7eI9dwFPZg+20lB15fKFkVZ0c9ZFxqPfiBAyDTlTkh9stPI0t+JlPCqMbItVA==",
126
+ "cpu": [
127
+ "arm"
128
+ ],
129
+ "dev": true,
130
+ "license": "MIT",
131
+ "optional": true,
132
+ "os": [
133
+ "linux"
134
+ ],
135
+ "engines": {
136
+ "node": "^20.19.0 || >=22.12.0"
137
+ }
138
+ },
139
+ "node_modules/@oxlint/binding-linux-arm-musleabihf": {
140
+ "version": "1.79.0",
141
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-1.79.0.tgz",
142
+ "integrity": "sha512-ZOQUjkzDnvlhSE3+tWC3YXx94MMl+sYMlwH+u1+YGApGHOJP/YAc8ZBRFOXZ6eOBmxtXAWuS/fBcdZr8qqNO1A==",
143
+ "cpu": [
144
+ "arm"
145
+ ],
146
+ "dev": true,
147
+ "license": "MIT",
148
+ "optional": true,
149
+ "os": [
150
+ "linux"
151
+ ],
152
+ "engines": {
153
+ "node": "^20.19.0 || >=22.12.0"
154
+ }
155
+ },
156
+ "node_modules/@oxlint/binding-linux-arm64-gnu": {
157
+ "version": "1.79.0",
158
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.79.0.tgz",
159
+ "integrity": "sha512-lu158FR4nGqGeRS3BQvtG85wRgU/Fy4MD5Cxp1hzJXizGiLo6u2742wJSCDKh8cFcZntvX7fcxlq4mMmfryH1g==",
160
+ "cpu": [
161
+ "arm64"
162
+ ],
163
+ "dev": true,
164
+ "license": "MIT",
165
+ "optional": true,
166
+ "os": [
167
+ "linux"
168
+ ],
169
+ "engines": {
170
+ "node": "^20.19.0 || >=22.12.0"
171
+ }
172
+ },
173
+ "node_modules/@oxlint/binding-linux-arm64-musl": {
174
+ "version": "1.79.0",
175
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.79.0.tgz",
176
+ "integrity": "sha512-mbpKQeE2aflTjddaHK7MP8KP/OFbUM++lt5M635ENM8IyIdK0jm2t9pb+2v9mVVIvhF6TqA4l7F79Pll1mi+uw==",
177
+ "cpu": [
178
+ "arm64"
179
+ ],
180
+ "dev": true,
181
+ "license": "MIT",
182
+ "optional": true,
183
+ "os": [
184
+ "linux"
185
+ ],
186
+ "engines": {
187
+ "node": "^20.19.0 || >=22.12.0"
188
+ }
189
+ },
190
+ "node_modules/@oxlint/binding-linux-ppc64-gnu": {
191
+ "version": "1.79.0",
192
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.79.0.tgz",
193
+ "integrity": "sha512-WpGNua7gaxaHnpSDeog2ji8IDHn/QLPl9LPzwkR/FvVv58vT5BcXjRXnU+wbu3N75cpeha8CdC7ho/U2OIsB4g==",
194
+ "cpu": [
195
+ "ppc64"
196
+ ],
197
+ "dev": true,
198
+ "license": "MIT",
199
+ "optional": true,
200
+ "os": [
201
+ "linux"
202
+ ],
203
+ "engines": {
204
+ "node": "^20.19.0 || >=22.12.0"
205
+ }
206
+ },
207
+ "node_modules/@oxlint/binding-linux-riscv64-gnu": {
208
+ "version": "1.79.0",
209
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-1.79.0.tgz",
210
+ "integrity": "sha512-tK1E93A5LVzISg4ngpKJnfTs7EqtIUceGI7MQ4GyDjJiLi8wPCkEyKlj2xkyKWZ1yzkDJyLHTBJ5/iFWRdnJvg==",
211
+ "cpu": [
212
+ "riscv64"
213
+ ],
214
+ "dev": true,
215
+ "license": "MIT",
216
+ "optional": true,
217
+ "os": [
218
+ "linux"
219
+ ],
220
+ "engines": {
221
+ "node": "^20.19.0 || >=22.12.0"
222
+ }
223
+ },
224
+ "node_modules/@oxlint/binding-linux-riscv64-musl": {
225
+ "version": "1.79.0",
226
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-1.79.0.tgz",
227
+ "integrity": "sha512-qhQvUIrngXivA2A9pQ+xPCychztn/5qUv7yS3gDwXv3w7Rag+eTeeXWmRyx+t7XsW5x6LuY/8AsTq36UgFIblg==",
228
+ "cpu": [
229
+ "riscv64"
230
+ ],
231
+ "dev": true,
232
+ "license": "MIT",
233
+ "optional": true,
234
+ "os": [
235
+ "linux"
236
+ ],
237
+ "engines": {
238
+ "node": "^20.19.0 || >=22.12.0"
239
+ }
240
+ },
241
+ "node_modules/@oxlint/binding-linux-s390x-gnu": {
242
+ "version": "1.79.0",
243
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.79.0.tgz",
244
+ "integrity": "sha512-sv6AaVgU/eE6u+6WFiQVDcPPwTxP6IJMSB9k701W2r/r6Tx465e8vPvVyRxquNH4Vy6KwRNu90mVbxXJN8+5gg==",
245
+ "cpu": [
246
+ "s390x"
247
+ ],
248
+ "dev": true,
249
+ "license": "MIT",
250
+ "optional": true,
251
+ "os": [
252
+ "linux"
253
+ ],
254
+ "engines": {
255
+ "node": "^20.19.0 || >=22.12.0"
256
+ }
257
+ },
258
+ "node_modules/@oxlint/binding-linux-x64-gnu": {
259
+ "version": "1.79.0",
260
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.79.0.tgz",
261
+ "integrity": "sha512-iFZL02deziHslb3jEX9KdqlAkYoo4fGyotchKDzdfK1f5mxlIBeiQeHhvK3iFpuEJSB4ma/qeFn9oxPiwnhUPQ==",
262
+ "cpu": [
263
+ "x64"
264
+ ],
265
+ "dev": true,
266
+ "license": "MIT",
267
+ "optional": true,
268
+ "os": [
269
+ "linux"
270
+ ],
271
+ "engines": {
272
+ "node": "^20.19.0 || >=22.12.0"
273
+ }
274
+ },
275
+ "node_modules/@oxlint/binding-linux-x64-musl": {
276
+ "version": "1.79.0",
277
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-x64-musl/-/binding-linux-x64-musl-1.79.0.tgz",
278
+ "integrity": "sha512-3DtZR2raqObnh7wXZoFYFd0Fw7skBvcb3f7A+/lkEiDuh8hrE6vv9b/62Qxao1a9/OeHLw/FcXlXzgsW9wTRFg==",
279
+ "cpu": [
280
+ "x64"
281
+ ],
282
+ "dev": true,
283
+ "license": "MIT",
284
+ "optional": true,
285
+ "os": [
286
+ "linux"
287
+ ],
288
+ "engines": {
289
+ "node": "^20.19.0 || >=22.12.0"
290
+ }
291
+ },
292
+ "node_modules/@oxlint/binding-openharmony-arm64": {
293
+ "version": "1.79.0",
294
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-openharmony-arm64/-/binding-openharmony-arm64-1.79.0.tgz",
295
+ "integrity": "sha512-Oatt4GuA1WJkqzk2ozx4HrWROOi7opV3AKDw/U8qDIqeTqzsjn5K2x3REJMNjU3/KU/Bkq96Zi3CknaiDTaC/Q==",
296
+ "cpu": [
297
+ "arm64"
298
+ ],
299
+ "dev": true,
300
+ "license": "MIT",
301
+ "optional": true,
302
+ "os": [
303
+ "openharmony"
304
+ ],
305
+ "engines": {
306
+ "node": "^20.19.0 || >=22.12.0"
307
+ }
308
+ },
309
+ "node_modules/@oxlint/binding-win32-arm64-msvc": {
310
+ "version": "1.79.0",
311
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.79.0.tgz",
312
+ "integrity": "sha512-NAgZr9Qp8nIA9rpo0JEvwiabTF/2UVqBNnupBG9X4kxXcQoScJUTi+qHhvabb9s/thgj5wQ4XcIaJvb+ZMgoKw==",
313
+ "cpu": [
314
+ "arm64"
315
+ ],
316
+ "dev": true,
317
+ "license": "MIT",
318
+ "optional": true,
319
+ "os": [
320
+ "win32"
321
+ ],
322
+ "engines": {
323
+ "node": "^20.19.0 || >=22.12.0"
324
+ }
325
+ },
326
+ "node_modules/@oxlint/binding-win32-ia32-msvc": {
327
+ "version": "1.79.0",
328
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-1.79.0.tgz",
329
+ "integrity": "sha512-+KyXjIvcpaXmWW/j9NNY5yWjrIVxaX18VyIheQy3jwc2GSYgpCr7MGI/HxIGQ/shAL5IWEKbhsqoMpAO5Stiog==",
330
+ "cpu": [
331
+ "ia32"
332
+ ],
333
+ "dev": true,
334
+ "license": "MIT",
335
+ "optional": true,
336
+ "os": [
337
+ "win32"
338
+ ],
339
+ "engines": {
340
+ "node": "^20.19.0 || >=22.12.0"
341
+ }
342
+ },
343
+ "node_modules/@oxlint/binding-win32-x64-msvc": {
344
+ "version": "1.79.0",
345
+ "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.79.0.tgz",
346
+ "integrity": "sha512-mEelcCMMBS57sIXh2veGMNy+pQwuGtcMxHxGIZWQ5Ba9pJ5jCCUFOZB9E2JhBaxGsURe+WGe0zJp4RVre52gpQ==",
347
+ "cpu": [
348
+ "x64"
349
+ ],
350
+ "dev": true,
351
+ "license": "MIT",
352
+ "optional": true,
353
+ "os": [
354
+ "win32"
355
+ ],
356
+ "engines": {
357
+ "node": "^20.19.0 || >=22.12.0"
358
+ }
359
+ },
360
+ "node_modules/@rolldown/binding-android-arm-eabi": {
361
+ "version": "1.2.5",
362
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.5.tgz",
363
+ "integrity": "sha512-DLe/i+l8ynIBY7XEQ191TeZvCoowIGa18R+dIV30GW7DiOtp74i/xX8hs8GUjW5ARV7VZuie3d6AumSmCwbeRA==",
364
+ "cpu": [
365
+ "arm"
366
+ ],
367
+ "dev": true,
368
+ "license": "MIT",
369
+ "optional": true,
370
+ "os": [
371
+ "android"
372
+ ],
373
+ "engines": {
374
+ "node": "^20.19.0 || >=22.12.0"
375
+ }
376
+ },
377
+ "node_modules/@rolldown/binding-android-arm64": {
378
+ "version": "1.2.5",
379
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.5.tgz",
380
+ "integrity": "sha512-zXcwKlQApYAOELHd8PwKDFkagYF9Wy4e0RJ+0qnzl9Pjnpj75TEG8ufv40p2J7kCEfwZAsNiuzRIyNNMWT38ig==",
381
+ "cpu": [
382
+ "arm64"
383
+ ],
384
+ "dev": true,
385
+ "license": "MIT",
386
+ "optional": true,
387
+ "os": [
388
+ "android"
389
+ ],
390
+ "engines": {
391
+ "node": "^20.19.0 || >=22.12.0"
392
+ }
393
+ },
394
+ "node_modules/@rolldown/binding-darwin-arm64": {
395
+ "version": "1.2.5",
396
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.5.tgz",
397
+ "integrity": "sha512-dK4QakI42nzWgJT5sm4y4y/O//D4OxM75/cH28RLV+nzIN9AY+YsbuUVrUTjlLjXR6vpyxFbSsbmNuJ6BP9sww==",
398
+ "cpu": [
399
+ "arm64"
400
+ ],
401
+ "dev": true,
402
+ "license": "MIT",
403
+ "optional": true,
404
+ "os": [
405
+ "darwin"
406
+ ],
407
+ "engines": {
408
+ "node": "^20.19.0 || >=22.12.0"
409
+ }
410
+ },
411
+ "node_modules/@rolldown/binding-darwin-x64": {
412
+ "version": "1.2.5",
413
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.5.tgz",
414
+ "integrity": "sha512-fqSALaUu1Wjd1nK2uW2kJDWdLCc8lx1IcY+MTY26Aurfdx19anlzhqXOgCFbBFQnlFDTn4TC1/7Nz4Bl2mLP3A==",
415
+ "cpu": [
416
+ "x64"
417
+ ],
418
+ "dev": true,
419
+ "license": "MIT",
420
+ "optional": true,
421
+ "os": [
422
+ "darwin"
423
+ ],
424
+ "engines": {
425
+ "node": "^20.19.0 || >=22.12.0"
426
+ }
427
+ },
428
+ "node_modules/@rolldown/binding-freebsd-x64": {
429
+ "version": "1.2.5",
430
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.5.tgz",
431
+ "integrity": "sha512-/vCnNxlkxs9tKxNDcyWUePpJ/PgTzxIaVhoM5SmG8UV+GR/IcPam4VYxi7GIMo7PSDuNqlJqvprqii9NqqVCMw==",
432
+ "cpu": [
433
+ "x64"
434
+ ],
435
+ "dev": true,
436
+ "license": "MIT",
437
+ "optional": true,
438
+ "os": [
439
+ "freebsd"
440
+ ],
441
+ "engines": {
442
+ "node": "^20.19.0 || >=22.12.0"
443
+ }
444
+ },
445
+ "node_modules/@rolldown/binding-linux-arm-gnueabihf": {
446
+ "version": "1.2.5",
447
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.5.tgz",
448
+ "integrity": "sha512-abk0NLA519LxRCszmbE0jYKuQ9YPocOXTiOXOo6Yr+YAT95VH+PtqYAjOJvGKt3viEd/x4qzabAlwd5bHOOARg==",
449
+ "cpu": [
450
+ "arm"
451
+ ],
452
+ "dev": true,
453
+ "license": "MIT",
454
+ "optional": true,
455
+ "os": [
456
+ "linux"
457
+ ],
458
+ "engines": {
459
+ "node": "^20.19.0 || >=22.12.0"
460
+ }
461
+ },
462
+ "node_modules/@rolldown/binding-linux-arm64-gnu": {
463
+ "version": "1.2.5",
464
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.5.tgz",
465
+ "integrity": "sha512-Y7eALiJ8lr0M2HH103Js+g7V34wf6snlpZLAsHI90uLhr3PVlNsbFVAXJC9d/V6BnPyKtpSwI+NcB/RLxsQxuA==",
466
+ "cpu": [
467
+ "arm64"
468
+ ],
469
+ "dev": true,
470
+ "license": "MIT",
471
+ "optional": true,
472
+ "os": [
473
+ "linux"
474
+ ],
475
+ "engines": {
476
+ "node": "^20.19.0 || >=22.12.0"
477
+ }
478
+ },
479
+ "node_modules/@rolldown/binding-linux-arm64-musl": {
480
+ "version": "1.2.5",
481
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.5.tgz",
482
+ "integrity": "sha512-xMvZgnbZg4YVnR/AX2b3oOPDTFYJvUVaJg5FedA/LuvexAtXibZQej4cnTkw3rjsJ/ggUROB64TdtETiim+FYA==",
483
+ "cpu": [
484
+ "arm64"
485
+ ],
486
+ "dev": true,
487
+ "license": "MIT",
488
+ "optional": true,
489
+ "os": [
490
+ "linux"
491
+ ],
492
+ "engines": {
493
+ "node": "^20.19.0 || >=22.12.0"
494
+ }
495
+ },
496
+ "node_modules/@rolldown/binding-linux-ppc64-gnu": {
497
+ "version": "1.2.5",
498
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.5.tgz",
499
+ "integrity": "sha512-GRjeqTUDHTo5GwntsLaAMcBahG3nlpjftXWZLN73HiYQlhwEowvarFgQnRnQZtIp4keXX7quXFbG38uPZBa2EA==",
500
+ "cpu": [
501
+ "ppc64"
502
+ ],
503
+ "dev": true,
504
+ "license": "MIT",
505
+ "optional": true,
506
+ "os": [
507
+ "linux"
508
+ ],
509
+ "engines": {
510
+ "node": "^20.19.0 || >=22.12.0"
511
+ }
512
+ },
513
+ "node_modules/@rolldown/binding-linux-s390x-gnu": {
514
+ "version": "1.2.5",
515
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.5.tgz",
516
+ "integrity": "sha512-vLNTR45F2Uwc8AufkNXPmB4VliaXs+FvcheEogIzOXzO4l+LzieXF5A/TWxLy5HtqpsRCHUfd0lPVrrdgXdLHQ==",
517
+ "cpu": [
518
+ "s390x"
519
+ ],
520
+ "dev": true,
521
+ "license": "MIT",
522
+ "optional": true,
523
+ "os": [
524
+ "linux"
525
+ ],
526
+ "engines": {
527
+ "node": "^20.19.0 || >=22.12.0"
528
+ }
529
+ },
530
+ "node_modules/@rolldown/binding-linux-x64-gnu": {
531
+ "version": "1.2.5",
532
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.5.tgz",
533
+ "integrity": "sha512-Mgj59/HTuYeK9Gz2MA+mBWKnHsAgkBSec15ZMb1st3oIfFbX7gCjOae7GydHhzcyQi9Z/7M1QuN9bR3oFqF0jQ==",
534
+ "cpu": [
535
+ "x64"
536
+ ],
537
+ "dev": true,
538
+ "license": "MIT",
539
+ "optional": true,
540
+ "os": [
541
+ "linux"
542
+ ],
543
+ "engines": {
544
+ "node": "^20.19.0 || >=22.12.0"
545
+ }
546
+ },
547
+ "node_modules/@rolldown/binding-linux-x64-musl": {
548
+ "version": "1.2.5",
549
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.5.tgz",
550
+ "integrity": "sha512-mY8AP0/ichsbhAxGnLa3d3+MwV0EfgrPND2bplI3Ym8T6R2pJ0N87bvrKVwNXmdy3jnr6eQBecdqx/HMknBmpA==",
551
+ "cpu": [
552
+ "x64"
553
+ ],
554
+ "dev": true,
555
+ "license": "MIT",
556
+ "optional": true,
557
+ "os": [
558
+ "linux"
559
+ ],
560
+ "engines": {
561
+ "node": "^20.19.0 || >=22.12.0"
562
+ }
563
+ },
564
+ "node_modules/@rolldown/binding-openharmony-arm64": {
565
+ "version": "1.2.5",
566
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.5.tgz",
567
+ "integrity": "sha512-8SLssA2oweAxyRgDp789ACfRb/3P+zNRJpzZxSizxF9m8NUDQ4+3xjo8ttjhVGGw6Qxb70oZiEtIjaKikCO7Yw==",
568
+ "cpu": [
569
+ "arm64"
570
+ ],
571
+ "dev": true,
572
+ "license": "MIT",
573
+ "optional": true,
574
+ "os": [
575
+ "openharmony"
576
+ ],
577
+ "engines": {
578
+ "node": "^20.19.0 || >=22.12.0"
579
+ }
580
+ },
581
+ "node_modules/@rolldown/binding-win32-arm64-msvc": {
582
+ "version": "1.2.5",
583
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.5.tgz",
584
+ "integrity": "sha512-vGbruD5zquhoc8D9SViXgN2FBJtNdTyQ4DtG+SWiEGlJiAzoKcZ2xp+xuXCffhubVdt0NJlTZqkeRuERy7g8Cw==",
585
+ "cpu": [
586
+ "arm64"
587
+ ],
588
+ "dev": true,
589
+ "license": "MIT",
590
+ "optional": true,
591
+ "os": [
592
+ "win32"
593
+ ],
594
+ "engines": {
595
+ "node": "^20.19.0 || >=22.12.0"
596
+ }
597
+ },
598
+ "node_modules/@rolldown/binding-win32-x64-msvc": {
599
+ "version": "1.2.5",
600
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.5.tgz",
601
+ "integrity": "sha512-e/SXpgISz+IoqVcSSI0rx/d/he8zqLex+/rCWpnHpmVfmPIUjag9H6P7zotf0gJHwPUhQxZ/mF8tr6acebT9yw==",
602
+ "cpu": [
603
+ "x64"
604
+ ],
605
+ "dev": true,
606
+ "license": "MIT",
607
+ "optional": true,
608
+ "os": [
609
+ "win32"
610
+ ],
611
+ "engines": {
612
+ "node": "^20.19.0 || >=22.12.0"
613
+ }
614
+ },
615
+ "node_modules/@rolldown/pluginutils": {
616
+ "version": "1.0.1",
617
+ "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz",
618
+ "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==",
619
+ "dev": true,
620
+ "license": "MIT"
621
+ },
622
+ "node_modules/@types/dompurify": {
623
+ "version": "3.0.5",
624
+ "resolved": "https://registry.npmjs.org/@types/dompurify/-/dompurify-3.0.5.tgz",
625
+ "integrity": "sha512-1Wg0g3BtQF7sSb27fJQAKck1HECM6zV1EB66j8JH9i3LCjYabJa0FSdiSgsD5K/RbrsR0SiraKacLB+T8ZVYAg==",
626
+ "dev": true,
627
+ "license": "MIT",
628
+ "dependencies": {
629
+ "@types/trusted-types": "*"
630
+ }
631
+ },
632
+ "node_modules/@types/node": {
633
+ "version": "24.13.3",
634
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-24.13.3.tgz",
635
+ "integrity": "sha512-Dh8vAsV36ig5wa9OX4pXvMc9D3Veibfw2wix0CUwYODLD8nkj9UsLjASr49nPg+2eKzxhBV+v7L8pXvT4e639Q==",
636
+ "dev": true,
637
+ "license": "MIT",
638
+ "peer": true,
639
+ "dependencies": {
640
+ "undici-types": "~7.18.0"
641
+ }
642
+ },
643
+ "node_modules/@types/react": {
644
+ "version": "19.2.18",
645
+ "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.18.tgz",
646
+ "integrity": "sha512-AnzbBERsrLKtk2XSfTbYRLjQPdy116Sty4q+T+Bp3IC4l6jNBvreVPAHmpq9qhXQM7CXZPjLVmGMw9sy+hxQ3w==",
647
+ "dev": true,
648
+ "license": "MIT",
649
+ "peer": true,
650
+ "dependencies": {
651
+ "csstype": "^3.2.2"
652
+ }
653
+ },
654
+ "node_modules/@types/react-dom": {
655
+ "version": "19.2.4",
656
+ "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.4.tgz",
657
+ "integrity": "sha512-Bsc+QHgp+P/F02XDzNCY9jnZNCUuLki36KT7VKrTXXLdHf+vHMNZnW1rVu5DNW/rCK+fya3DATySbLM4yhtKUw==",
658
+ "dev": true,
659
+ "license": "MIT",
660
+ "peerDependencies": {
661
+ "@types/react": "^19.2.0"
662
+ }
663
+ },
664
+ "node_modules/@types/trusted-types": {
665
+ "version": "2.0.7",
666
+ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
667
+ "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
668
+ "devOptional": true,
669
+ "license": "MIT"
670
+ },
671
+ "node_modules/@vitejs/plugin-react": {
672
+ "version": "6.0.5",
673
+ "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-6.0.5.tgz",
674
+ "integrity": "sha512-BOVzne/NL162sMdResB25mUv+vWMF5NoAjNf09TeGlE7ZpszZWSD3winycicLJw72yeVsoCn/2kOhEuCvEShMA==",
675
+ "dev": true,
676
+ "license": "MIT",
677
+ "dependencies": {
678
+ "@rolldown/pluginutils": "^1.0.1"
679
+ },
680
+ "engines": {
681
+ "node": "^20.19.0 || >=22.12.0"
682
+ },
683
+ "peerDependencies": {
684
+ "@rolldown/plugin-babel": "^0.1.7 || ^0.2.0",
685
+ "babel-plugin-react-compiler": "^1.0.0",
686
+ "vite": "^8.0.0"
687
+ },
688
+ "peerDependenciesMeta": {
689
+ "@rolldown/plugin-babel": {
690
+ "optional": true
691
+ },
692
+ "babel-plugin-react-compiler": {
693
+ "optional": true
694
+ }
695
+ }
696
+ },
697
+ "node_modules/csstype": {
698
+ "version": "3.2.3",
699
+ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
700
+ "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
701
+ "dev": true,
702
+ "license": "MIT"
703
+ },
704
+ "node_modules/detect-libc": {
705
+ "version": "2.1.2",
706
+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
707
+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
708
+ "dev": true,
709
+ "license": "Apache-2.0",
710
+ "engines": {
711
+ "node": ">=8"
712
+ }
713
+ },
714
+ "node_modules/dompurify": {
715
+ "version": "3.4.14",
716
+ "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.14.tgz",
717
+ "integrity": "sha512-dVoH9z+MY+C9IilgGCk3YfFqjLi3fChm2OiKJMzh6axrJ5qwxqWaZamgmHrpv22CN/KdbZJuGEGgfQoL00LTdg==",
718
+ "license": "(MPL-2.0 OR Apache-2.0)",
719
+ "optionalDependencies": {
720
+ "@types/trusted-types": "^2.0.7"
721
+ }
722
+ },
723
+ "node_modules/fdir": {
724
+ "version": "6.5.0",
725
+ "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
726
+ "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
727
+ "dev": true,
728
+ "license": "MIT",
729
+ "engines": {
730
+ "node": ">=12.0.0"
731
+ },
732
+ "peerDependencies": {
733
+ "picomatch": "^3 || ^4"
734
+ },
735
+ "peerDependenciesMeta": {
736
+ "picomatch": {
737
+ "optional": true
738
+ }
739
+ }
740
+ },
741
+ "node_modules/fsevents": {
742
+ "version": "2.3.3",
743
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
744
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
745
+ "dev": true,
746
+ "hasInstallScript": true,
747
+ "license": "MIT",
748
+ "optional": true,
749
+ "os": [
750
+ "darwin"
751
+ ],
752
+ "engines": {
753
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
754
+ }
755
+ },
756
+ "node_modules/lightningcss": {
757
+ "version": "1.33.0",
758
+ "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz",
759
+ "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==",
760
+ "dev": true,
761
+ "license": "MPL-2.0",
762
+ "dependencies": {
763
+ "detect-libc": "^2.0.3"
764
+ },
765
+ "engines": {
766
+ "node": ">= 12.0.0"
767
+ },
768
+ "funding": {
769
+ "type": "opencollective",
770
+ "url": "https://opencollective.com/parcel"
771
+ },
772
+ "optionalDependencies": {
773
+ "lightningcss-android-arm64": "1.33.0",
774
+ "lightningcss-darwin-arm64": "1.33.0",
775
+ "lightningcss-darwin-x64": "1.33.0",
776
+ "lightningcss-freebsd-x64": "1.33.0",
777
+ "lightningcss-linux-arm-gnueabihf": "1.33.0",
778
+ "lightningcss-linux-arm64-gnu": "1.33.0",
779
+ "lightningcss-linux-arm64-musl": "1.33.0",
780
+ "lightningcss-linux-x64-gnu": "1.33.0",
781
+ "lightningcss-linux-x64-musl": "1.33.0",
782
+ "lightningcss-win32-arm64-msvc": "1.33.0",
783
+ "lightningcss-win32-x64-msvc": "1.33.0"
784
+ }
785
+ },
786
+ "node_modules/lightningcss-android-arm64": {
787
+ "version": "1.33.0",
788
+ "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz",
789
+ "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==",
790
+ "cpu": [
791
+ "arm64"
792
+ ],
793
+ "dev": true,
794
+ "license": "MPL-2.0",
795
+ "optional": true,
796
+ "os": [
797
+ "android"
798
+ ],
799
+ "engines": {
800
+ "node": ">= 12.0.0"
801
+ },
802
+ "funding": {
803
+ "type": "opencollective",
804
+ "url": "https://opencollective.com/parcel"
805
+ }
806
+ },
807
+ "node_modules/lightningcss-darwin-arm64": {
808
+ "version": "1.33.0",
809
+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz",
810
+ "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==",
811
+ "cpu": [
812
+ "arm64"
813
+ ],
814
+ "dev": true,
815
+ "license": "MPL-2.0",
816
+ "optional": true,
817
+ "os": [
818
+ "darwin"
819
+ ],
820
+ "engines": {
821
+ "node": ">= 12.0.0"
822
+ },
823
+ "funding": {
824
+ "type": "opencollective",
825
+ "url": "https://opencollective.com/parcel"
826
+ }
827
+ },
828
+ "node_modules/lightningcss-darwin-x64": {
829
+ "version": "1.33.0",
830
+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz",
831
+ "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==",
832
+ "cpu": [
833
+ "x64"
834
+ ],
835
+ "dev": true,
836
+ "license": "MPL-2.0",
837
+ "optional": true,
838
+ "os": [
839
+ "darwin"
840
+ ],
841
+ "engines": {
842
+ "node": ">= 12.0.0"
843
+ },
844
+ "funding": {
845
+ "type": "opencollective",
846
+ "url": "https://opencollective.com/parcel"
847
+ }
848
+ },
849
+ "node_modules/lightningcss-freebsd-x64": {
850
+ "version": "1.33.0",
851
+ "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz",
852
+ "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==",
853
+ "cpu": [
854
+ "x64"
855
+ ],
856
+ "dev": true,
857
+ "license": "MPL-2.0",
858
+ "optional": true,
859
+ "os": [
860
+ "freebsd"
861
+ ],
862
+ "engines": {
863
+ "node": ">= 12.0.0"
864
+ },
865
+ "funding": {
866
+ "type": "opencollective",
867
+ "url": "https://opencollective.com/parcel"
868
+ }
869
+ },
870
+ "node_modules/lightningcss-linux-arm-gnueabihf": {
871
+ "version": "1.33.0",
872
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz",
873
+ "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==",
874
+ "cpu": [
875
+ "arm"
876
+ ],
877
+ "dev": true,
878
+ "license": "MPL-2.0",
879
+ "optional": true,
880
+ "os": [
881
+ "linux"
882
+ ],
883
+ "engines": {
884
+ "node": ">= 12.0.0"
885
+ },
886
+ "funding": {
887
+ "type": "opencollective",
888
+ "url": "https://opencollective.com/parcel"
889
+ }
890
+ },
891
+ "node_modules/lightningcss-linux-arm64-gnu": {
892
+ "version": "1.33.0",
893
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz",
894
+ "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==",
895
+ "cpu": [
896
+ "arm64"
897
+ ],
898
+ "dev": true,
899
+ "license": "MPL-2.0",
900
+ "optional": true,
901
+ "os": [
902
+ "linux"
903
+ ],
904
+ "engines": {
905
+ "node": ">= 12.0.0"
906
+ },
907
+ "funding": {
908
+ "type": "opencollective",
909
+ "url": "https://opencollective.com/parcel"
910
+ }
911
+ },
912
+ "node_modules/lightningcss-linux-arm64-musl": {
913
+ "version": "1.33.0",
914
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz",
915
+ "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==",
916
+ "cpu": [
917
+ "arm64"
918
+ ],
919
+ "dev": true,
920
+ "license": "MPL-2.0",
921
+ "optional": true,
922
+ "os": [
923
+ "linux"
924
+ ],
925
+ "engines": {
926
+ "node": ">= 12.0.0"
927
+ },
928
+ "funding": {
929
+ "type": "opencollective",
930
+ "url": "https://opencollective.com/parcel"
931
+ }
932
+ },
933
+ "node_modules/lightningcss-linux-x64-gnu": {
934
+ "version": "1.33.0",
935
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz",
936
+ "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==",
937
+ "cpu": [
938
+ "x64"
939
+ ],
940
+ "dev": true,
941
+ "license": "MPL-2.0",
942
+ "optional": true,
943
+ "os": [
944
+ "linux"
945
+ ],
946
+ "engines": {
947
+ "node": ">= 12.0.0"
948
+ },
949
+ "funding": {
950
+ "type": "opencollective",
951
+ "url": "https://opencollective.com/parcel"
952
+ }
953
+ },
954
+ "node_modules/lightningcss-linux-x64-musl": {
955
+ "version": "1.33.0",
956
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz",
957
+ "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==",
958
+ "cpu": [
959
+ "x64"
960
+ ],
961
+ "dev": true,
962
+ "license": "MPL-2.0",
963
+ "optional": true,
964
+ "os": [
965
+ "linux"
966
+ ],
967
+ "engines": {
968
+ "node": ">= 12.0.0"
969
+ },
970
+ "funding": {
971
+ "type": "opencollective",
972
+ "url": "https://opencollective.com/parcel"
973
+ }
974
+ },
975
+ "node_modules/lightningcss-win32-arm64-msvc": {
976
+ "version": "1.33.0",
977
+ "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz",
978
+ "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==",
979
+ "cpu": [
980
+ "arm64"
981
+ ],
982
+ "dev": true,
983
+ "license": "MPL-2.0",
984
+ "optional": true,
985
+ "os": [
986
+ "win32"
987
+ ],
988
+ "engines": {
989
+ "node": ">= 12.0.0"
990
+ },
991
+ "funding": {
992
+ "type": "opencollective",
993
+ "url": "https://opencollective.com/parcel"
994
+ }
995
+ },
996
+ "node_modules/lightningcss-win32-x64-msvc": {
997
+ "version": "1.33.0",
998
+ "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz",
999
+ "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==",
1000
+ "cpu": [
1001
+ "x64"
1002
+ ],
1003
+ "dev": true,
1004
+ "license": "MPL-2.0",
1005
+ "optional": true,
1006
+ "os": [
1007
+ "win32"
1008
+ ],
1009
+ "engines": {
1010
+ "node": ">= 12.0.0"
1011
+ },
1012
+ "funding": {
1013
+ "type": "opencollective",
1014
+ "url": "https://opencollective.com/parcel"
1015
+ }
1016
+ },
1017
+ "node_modules/marked": {
1018
+ "version": "18.0.10",
1019
+ "resolved": "https://registry.npmjs.org/marked/-/marked-18.0.10.tgz",
1020
+ "integrity": "sha512-FJeH4bRpYoXiggcgriCGItKCSv3xkngJc4QCZ/rkQCogU3VYaLxYJoZl8Nw/b4+x7iij/pd+09mZ6A1dXzpL0A==",
1021
+ "license": "MIT",
1022
+ "bin": {
1023
+ "marked": "bin/marked.js"
1024
+ },
1025
+ "engines": {
1026
+ "node": ">= 20"
1027
+ }
1028
+ },
1029
+ "node_modules/nanoid": {
1030
+ "version": "3.3.18",
1031
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz",
1032
+ "integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==",
1033
+ "dev": true,
1034
+ "funding": [
1035
+ {
1036
+ "type": "github",
1037
+ "url": "https://github.com/sponsors/ai"
1038
+ }
1039
+ ],
1040
+ "license": "MIT",
1041
+ "bin": {
1042
+ "nanoid": "bin/nanoid.cjs"
1043
+ },
1044
+ "engines": {
1045
+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
1046
+ }
1047
+ },
1048
+ "node_modules/oxlint": {
1049
+ "version": "1.79.0",
1050
+ "resolved": "https://registry.npmjs.org/oxlint/-/oxlint-1.79.0.tgz",
1051
+ "integrity": "sha512-hVJ9hq9m2unPS+Of4eJJgCPdIeCC+3DHEUX3tkmrPJr3OK2hz7PhXwgC+ZP71ZcYu8cCDEtQrqLxWNvxBppBVg==",
1052
+ "dev": true,
1053
+ "license": "MIT",
1054
+ "bin": {
1055
+ "oxlint": "bin/oxlint"
1056
+ },
1057
+ "engines": {
1058
+ "node": "^20.19.0 || >=22.12.0"
1059
+ },
1060
+ "funding": {
1061
+ "url": "https://github.com/sponsors/Boshen"
1062
+ },
1063
+ "optionalDependencies": {
1064
+ "@oxlint/binding-android-arm-eabi": "1.79.0",
1065
+ "@oxlint/binding-android-arm64": "1.79.0",
1066
+ "@oxlint/binding-darwin-arm64": "1.79.0",
1067
+ "@oxlint/binding-darwin-x64": "1.79.0",
1068
+ "@oxlint/binding-freebsd-x64": "1.79.0",
1069
+ "@oxlint/binding-linux-arm-gnueabihf": "1.79.0",
1070
+ "@oxlint/binding-linux-arm-musleabihf": "1.79.0",
1071
+ "@oxlint/binding-linux-arm64-gnu": "1.79.0",
1072
+ "@oxlint/binding-linux-arm64-musl": "1.79.0",
1073
+ "@oxlint/binding-linux-ppc64-gnu": "1.79.0",
1074
+ "@oxlint/binding-linux-riscv64-gnu": "1.79.0",
1075
+ "@oxlint/binding-linux-riscv64-musl": "1.79.0",
1076
+ "@oxlint/binding-linux-s390x-gnu": "1.79.0",
1077
+ "@oxlint/binding-linux-x64-gnu": "1.79.0",
1078
+ "@oxlint/binding-linux-x64-musl": "1.79.0",
1079
+ "@oxlint/binding-openharmony-arm64": "1.79.0",
1080
+ "@oxlint/binding-win32-arm64-msvc": "1.79.0",
1081
+ "@oxlint/binding-win32-ia32-msvc": "1.79.0",
1082
+ "@oxlint/binding-win32-x64-msvc": "1.79.0"
1083
+ },
1084
+ "peerDependencies": {
1085
+ "oxlint-tsgolint": ">=7.0.2001",
1086
+ "vite-plus": "*"
1087
+ },
1088
+ "peerDependenciesMeta": {
1089
+ "oxlint-tsgolint": {
1090
+ "optional": true
1091
+ },
1092
+ "vite-plus": {
1093
+ "optional": true
1094
+ }
1095
+ }
1096
+ },
1097
+ "node_modules/picocolors": {
1098
+ "version": "1.1.1",
1099
+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
1100
+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
1101
+ "dev": true,
1102
+ "license": "ISC"
1103
+ },
1104
+ "node_modules/picomatch": {
1105
+ "version": "4.0.5",
1106
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",
1107
+ "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==",
1108
+ "dev": true,
1109
+ "license": "MIT",
1110
+ "peer": true,
1111
+ "engines": {
1112
+ "node": ">=12"
1113
+ },
1114
+ "funding": {
1115
+ "url": "https://github.com/sponsors/jonschlinkert"
1116
+ }
1117
+ },
1118
+ "node_modules/postcss": {
1119
+ "version": "8.5.26",
1120
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz",
1121
+ "integrity": "sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ==",
1122
+ "dev": true,
1123
+ "funding": [
1124
+ {
1125
+ "type": "opencollective",
1126
+ "url": "https://opencollective.com/postcss/"
1127
+ },
1128
+ {
1129
+ "type": "tidelift",
1130
+ "url": "https://tidelift.com/funding/github/npm/postcss"
1131
+ },
1132
+ {
1133
+ "type": "github",
1134
+ "url": "https://github.com/sponsors/ai"
1135
+ }
1136
+ ],
1137
+ "license": "MIT",
1138
+ "dependencies": {
1139
+ "nanoid": "^3.3.17",
1140
+ "picocolors": "^1.1.1",
1141
+ "source-map-js": "^1.2.1"
1142
+ },
1143
+ "engines": {
1144
+ "node": "^10 || ^12 || >=14"
1145
+ }
1146
+ },
1147
+ "node_modules/react": {
1148
+ "version": "19.2.8",
1149
+ "resolved": "https://registry.npmjs.org/react/-/react-19.2.8.tgz",
1150
+ "integrity": "sha512-PWaYA1L/q9u2u7xYQi+Y3L3Yfnie7XyLeaJICV1MGD6LprsBxcAqGjYyr0eY3p+QdsA+x/Irkt4Qif8D63+Sbw==",
1151
+ "license": "MIT",
1152
+ "peer": true,
1153
+ "engines": {
1154
+ "node": ">=0.10.0"
1155
+ }
1156
+ },
1157
+ "node_modules/react-dom": {
1158
+ "version": "19.2.8",
1159
+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.8.tgz",
1160
+ "integrity": "sha512-rVprimfGBG3DR+Tq0IQG2DT5PxKth1WIGDmj5yPmlzr4YBe7uyE+Du4oVqTDXZSHGGGXRtTJEGSSePyQCMBglQ==",
1161
+ "license": "MIT",
1162
+ "dependencies": {
1163
+ "scheduler": "^0.27.0"
1164
+ },
1165
+ "peerDependencies": {
1166
+ "react": "^19.2.8"
1167
+ }
1168
+ },
1169
+ "node_modules/rolldown": {
1170
+ "version": "1.2.5",
1171
+ "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.5.tgz",
1172
+ "integrity": "sha512-VD2IE5PUG4Oj8zz2VGykiYd5wbnjdIiSsNQb8Qu5B+noEp+A78mu2iVvpp27g8es14Tk9rofNs5Tku9iQCS4fA==",
1173
+ "dev": true,
1174
+ "license": "MIT",
1175
+ "dependencies": {
1176
+ "@oxc-project/types": "=0.146.0",
1177
+ "@rolldown/pluginutils": "^1.0.0"
1178
+ },
1179
+ "bin": {
1180
+ "rolldown": "bin/cli.mjs"
1181
+ },
1182
+ "engines": {
1183
+ "node": "^20.19.0 || >=22.12.0"
1184
+ },
1185
+ "optionalDependencies": {
1186
+ "@rolldown/binding-android-arm-eabi": "1.2.5",
1187
+ "@rolldown/binding-android-arm64": "1.2.5",
1188
+ "@rolldown/binding-darwin-arm64": "1.2.5",
1189
+ "@rolldown/binding-darwin-x64": "1.2.5",
1190
+ "@rolldown/binding-freebsd-x64": "1.2.5",
1191
+ "@rolldown/binding-linux-arm-gnueabihf": "1.2.5",
1192
+ "@rolldown/binding-linux-arm64-gnu": "1.2.5",
1193
+ "@rolldown/binding-linux-arm64-musl": "1.2.5",
1194
+ "@rolldown/binding-linux-ppc64-gnu": "1.2.5",
1195
+ "@rolldown/binding-linux-s390x-gnu": "1.2.5",
1196
+ "@rolldown/binding-linux-x64-gnu": "1.2.5",
1197
+ "@rolldown/binding-linux-x64-musl": "1.2.5",
1198
+ "@rolldown/binding-openharmony-arm64": "1.2.5",
1199
+ "@rolldown/binding-win32-arm64-msvc": "1.2.5",
1200
+ "@rolldown/binding-win32-x64-msvc": "1.2.5"
1201
+ }
1202
+ },
1203
+ "node_modules/scheduler": {
1204
+ "version": "0.27.0",
1205
+ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz",
1206
+ "integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==",
1207
+ "license": "MIT"
1208
+ },
1209
+ "node_modules/source-map-js": {
1210
+ "version": "1.2.1",
1211
+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
1212
+ "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
1213
+ "dev": true,
1214
+ "license": "BSD-3-Clause",
1215
+ "engines": {
1216
+ "node": ">=0.10.0"
1217
+ }
1218
+ },
1219
+ "node_modules/tinyglobby": {
1220
+ "version": "0.2.17",
1221
+ "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
1222
+ "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",
1223
+ "dev": true,
1224
+ "license": "MIT",
1225
+ "dependencies": {
1226
+ "fdir": "^6.5.0",
1227
+ "picomatch": "^4.0.4"
1228
+ },
1229
+ "engines": {
1230
+ "node": ">=12.0.0"
1231
+ },
1232
+ "funding": {
1233
+ "url": "https://github.com/sponsors/SuperchupuDev"
1234
+ }
1235
+ },
1236
+ "node_modules/typescript": {
1237
+ "version": "6.0.3",
1238
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",
1239
+ "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
1240
+ "dev": true,
1241
+ "license": "Apache-2.0",
1242
+ "bin": {
1243
+ "tsc": "bin/tsc",
1244
+ "tsserver": "bin/tsserver"
1245
+ },
1246
+ "engines": {
1247
+ "node": ">=14.17"
1248
+ }
1249
+ },
1250
+ "node_modules/undici-types": {
1251
+ "version": "7.18.2",
1252
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz",
1253
+ "integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==",
1254
+ "dev": true,
1255
+ "license": "MIT"
1256
+ },
1257
+ "node_modules/vite": {
1258
+ "version": "8.2.1",
1259
+ "resolved": "https://registry.npmjs.org/vite/-/vite-8.2.1.tgz",
1260
+ "integrity": "sha512-EU/eS7BH3XROHh2YnBefjM6DBKA6ZeMZEYQbj7NLWg5wHYlhB8B/Mayd5XsgWq+NFYccDOTemRpdETWR6Ka/lw==",
1261
+ "dev": true,
1262
+ "license": "MIT",
1263
+ "peer": true,
1264
+ "dependencies": {
1265
+ "lightningcss": "^1.33.0",
1266
+ "picomatch": "^4.0.5",
1267
+ "postcss": "^8.5.25",
1268
+ "rolldown": "~1.2.1",
1269
+ "tinyglobby": "^0.2.17"
1270
+ },
1271
+ "bin": {
1272
+ "vite": "bin/vite.js"
1273
+ },
1274
+ "engines": {
1275
+ "node": "^20.19.0 || >=22.12.0"
1276
+ },
1277
+ "funding": {
1278
+ "url": "https://github.com/vitejs/vite?sponsor=1"
1279
+ },
1280
+ "optionalDependencies": {
1281
+ "fsevents": "~2.3.3"
1282
+ },
1283
+ "peerDependencies": {
1284
+ "@types/node": "^20.19.0 || >=22.12.0",
1285
+ "@vitejs/devtools": "^0.4.0",
1286
+ "esbuild": "^0.27.0 || ^0.28.0",
1287
+ "jiti": ">=1.21.0",
1288
+ "less": "^4.0.0",
1289
+ "sass": "^1.70.0",
1290
+ "sass-embedded": "^1.70.0",
1291
+ "stylus": ">=0.54.8",
1292
+ "sugarss": "^5.0.0",
1293
+ "terser": "^5.16.0",
1294
+ "tsx": "^4.8.1",
1295
+ "yaml": "^2.4.2"
1296
+ },
1297
+ "peerDependenciesMeta": {
1298
+ "@types/node": {
1299
+ "optional": true
1300
+ },
1301
+ "@vitejs/devtools": {
1302
+ "optional": true
1303
+ },
1304
+ "esbuild": {
1305
+ "optional": true
1306
+ },
1307
+ "jiti": {
1308
+ "optional": true
1309
+ },
1310
+ "less": {
1311
+ "optional": true
1312
+ },
1313
+ "sass": {
1314
+ "optional": true
1315
+ },
1316
+ "sass-embedded": {
1317
+ "optional": true
1318
+ },
1319
+ "stylus": {
1320
+ "optional": true
1321
+ },
1322
+ "sugarss": {
1323
+ "optional": true
1324
+ },
1325
+ "terser": {
1326
+ "optional": true
1327
+ },
1328
+ "tsx": {
1329
+ "optional": true
1330
+ },
1331
+ "yaml": {
1332
+ "optional": true
1333
+ }
1334
+ }
1335
+ }
1336
+ }
1337
+ }
frontend/package.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "frontend",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build",
9
+ "lint": "oxlint",
10
+ "preview": "vite preview"
11
+ },
12
+ "dependencies": {
13
+ "dompurify": "^3.4.14",
14
+ "marked": "^18.0.10",
15
+ "react": "^19.2.8",
16
+ "react-dom": "^19.2.8"
17
+ },
18
+ "devDependencies": {
19
+ "@types/dompurify": "^3.0.5",
20
+ "@types/node": "^24.13.3",
21
+ "@types/react": "^19.2.17",
22
+ "@types/react-dom": "^19.2.3",
23
+ "@vitejs/plugin-react": "^6.0.4",
24
+ "oxlint": "^1.75.0",
25
+ "typescript": "~6.0.2",
26
+ "vite": "^8.2.0"
27
+ }
28
+ }
frontend/public/favicon.svg ADDED
frontend/public/icons.svg ADDED
frontend/src/App.tsx ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useCallback, useEffect, useState } from 'react'
2
+ import { getStatus } from './api/client.ts'
3
+ import type { StatusDetails } from './api/types.ts'
4
+ import Sidebar from './components/Sidebar.tsx'
5
+ import UploadView from './components/UploadView.tsx'
6
+ import WebImportView from './components/WebImportView.tsx'
7
+ import ChatView from './components/ChatView.tsx'
8
+ import SummarizeView from './components/SummarizeView.tsx'
9
+
10
+ export type ViewId = 'upload' | 'web' | 'chat' | 'summary'
11
+
12
+ const VIEW_NAMES: Record<ViewId, string> = {
13
+ upload: 'Upload Files',
14
+ web: 'Web Import',
15
+ chat: 'Q&A Chat',
16
+ summary: 'Summarize',
17
+ }
18
+
19
+ const STATUS_POLL_INTERVAL_MS = 30000
20
+
21
+ function App() {
22
+ const [activeView, setActiveView] = useState<ViewId>('upload')
23
+ const [status, setStatus] = useState<StatusDetails | null>(null)
24
+ const [statusError, setStatusError] = useState(false)
25
+
26
+ const refreshStatus = useCallback(async () => {
27
+ try {
28
+ const res = await getStatus()
29
+ setStatus(res.details)
30
+ setStatusError(false)
31
+ } catch {
32
+ setStatusError(true)
33
+ }
34
+ }, [])
35
+
36
+ useEffect(() => {
37
+ refreshStatus()
38
+ const interval = setInterval(refreshStatus, STATUS_POLL_INTERVAL_MS)
39
+ return () => clearInterval(interval)
40
+ }, [refreshStatus])
41
+
42
+ const hasDocuments = status?.has_documents ?? false
43
+ const topStatusText = statusError
44
+ ? 'Connection Error'
45
+ : hasDocuments
46
+ ? `Ready · ${status?.model ?? ''}`
47
+ : 'No Documents'
48
+ const topStatusColor = statusError ? 'var(--danger)' : hasDocuments ? 'var(--success)' : 'var(--text-light)'
49
+
50
+ return (
51
+ <div className="app-layout">
52
+ <Sidebar
53
+ activeView={activeView}
54
+ onViewChange={setActiveView}
55
+ status={status}
56
+ statusError={statusError}
57
+ onStatusRefresh={refreshStatus}
58
+ />
59
+
60
+ <main className="main-content">
61
+ <div className="topbar">
62
+ <div className="breadcrumb">
63
+ <span className="breadcrumb-item">{VIEW_NAMES[activeView]}</span>
64
+ </div>
65
+ <div className="topbar-actions">
66
+ <div className="status-badge">
67
+ <span className="status-dot" style={{ background: topStatusColor }} />
68
+ <span>{topStatusText}</span>
69
+ </div>
70
+ </div>
71
+ </div>
72
+
73
+ {activeView === 'upload' && <UploadView onIndexed={refreshStatus} />}
74
+ {activeView === 'web' && <WebImportView onIndexed={refreshStatus} />}
75
+ {activeView === 'chat' && <ChatView />}
76
+ {activeView === 'summary' && <SummarizeView />}
77
+ </main>
78
+ </div>
79
+ )
80
+ }
81
+
82
+ export default App
frontend/src/api/client.ts ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type {
2
+ UploadResponse,
3
+ ScrapeAndIndexRequest,
4
+ ScrapeAndIndexResponse,
5
+ DeleteDocumentResponse,
6
+ StreamQueryRequest,
7
+ QueryRequest,
8
+ QueryResponse,
9
+ SummarizeRequest,
10
+ SummarizeResponse,
11
+ ResetResponse,
12
+ StatusResponse,
13
+ SessionSummary,
14
+ SessionMessagesResponse,
15
+ RenameSessionRequest,
16
+ ApiErrorBody,
17
+ StreamEvent,
18
+ } from './types.ts'
19
+
20
+ async function parseErrorDetail(response: Response): Promise<string> {
21
+ try {
22
+ const body = (await response.json()) as ApiErrorBody
23
+ if (body && typeof body.detail === 'string') {
24
+ return body.detail
25
+ }
26
+ } catch {
27
+ // fall through
28
+ }
29
+ return `Request failed with status ${response.status}`
30
+ }
31
+
32
+ async function requestJson<T>(input: RequestInfo, init?: RequestInit): Promise<T> {
33
+ const response = await fetch(input, init)
34
+ if (!response.ok) {
35
+ throw new Error(await parseErrorDetail(response))
36
+ }
37
+ return (await response.json()) as T
38
+ }
39
+
40
+ function jsonInit(body: unknown, signal?: AbortSignal): RequestInit {
41
+ return {
42
+ method: 'POST',
43
+ headers: { 'Content-Type': 'application/json' },
44
+ body: JSON.stringify(body),
45
+ signal,
46
+ }
47
+ }
48
+
49
+ export async function uploadFile(file: File, signal?: AbortSignal): Promise<UploadResponse> {
50
+ const formData = new FormData()
51
+ formData.append('file', file)
52
+ return requestJson<UploadResponse>('/upload', { method: 'POST', body: formData, signal })
53
+ }
54
+
55
+ export async function scrapeAndIndex(
56
+ req: ScrapeAndIndexRequest,
57
+ signal?: AbortSignal,
58
+ ): Promise<ScrapeAndIndexResponse> {
59
+ return requestJson<ScrapeAndIndexResponse>('/scrape_and_index', jsonInit(req, signal))
60
+ }
61
+
62
+ export async function deleteDocument(documentName: string): Promise<DeleteDocumentResponse> {
63
+ return requestJson<DeleteDocumentResponse>(
64
+ `/documents/${encodeURIComponent(documentName)}`,
65
+ { method: 'DELETE' },
66
+ )
67
+ }
68
+
69
+ export async function query(req: QueryRequest, signal?: AbortSignal): Promise<QueryResponse> {
70
+ return requestJson<QueryResponse>('/query', jsonInit(req, signal))
71
+ }
72
+
73
+ export async function summarize(
74
+ req: SummarizeRequest,
75
+ signal?: AbortSignal,
76
+ ): Promise<SummarizeResponse> {
77
+ return requestJson<SummarizeResponse>('/summarize', jsonInit(req, signal))
78
+ }
79
+
80
+ export async function resetDocuments(): Promise<ResetResponse> {
81
+ return requestJson<ResetResponse>('/reset', { method: 'POST' })
82
+ }
83
+
84
+ export async function getStatus(signal?: AbortSignal): Promise<StatusResponse> {
85
+ return requestJson<StatusResponse>('/status', { signal })
86
+ }
87
+
88
+ export async function listSessions(signal?: AbortSignal): Promise<SessionSummary[]> {
89
+ return requestJson<SessionSummary[]>('/sessions', { signal })
90
+ }
91
+
92
+ export async function getSessionMessages(
93
+ sessionId: string,
94
+ signal?: AbortSignal,
95
+ ): Promise<SessionMessagesResponse> {
96
+ return requestJson<SessionMessagesResponse>(
97
+ `/sessions/${encodeURIComponent(sessionId)}/messages`,
98
+ { signal },
99
+ )
100
+ }
101
+
102
+ export async function renameSession(
103
+ sessionId: string,
104
+ req: RenameSessionRequest,
105
+ ): Promise<ResetResponse> {
106
+ return requestJson<ResetResponse>(`/sessions/${encodeURIComponent(sessionId)}`, {
107
+ method: 'PATCH',
108
+ headers: { 'Content-Type': 'application/json' },
109
+ body: JSON.stringify(req),
110
+ })
111
+ }
112
+
113
+ export async function deleteSession(sessionId: string): Promise<ResetResponse> {
114
+ return requestJson<ResetResponse>(`/sessions/${encodeURIComponent(sessionId)}`, {
115
+ method: 'DELETE',
116
+ })
117
+ }
118
+
119
+ /**
120
+ * Streams /stream_query as an async generator of parsed SSE frames.
121
+ * Consumes the response body manually via a reader (not EventSource, since
122
+ * this is a POST request).
123
+ */
124
+ export async function* streamQuery(
125
+ question: string,
126
+ sessionId?: string,
127
+ signal?: AbortSignal,
128
+ ): AsyncGenerator<StreamEvent> {
129
+ const body: StreamQueryRequest = { question, session_id: sessionId }
130
+
131
+ const response = await fetch('/stream_query', {
132
+ method: 'POST',
133
+ headers: { 'Content-Type': 'application/json' },
134
+ body: JSON.stringify(body),
135
+ signal,
136
+ })
137
+
138
+ if (!response.ok || !response.body) {
139
+ const detail = await parseErrorDetail(response)
140
+ yield { type: 'error', error: detail }
141
+ return
142
+ }
143
+
144
+ const reader = response.body.getReader()
145
+ const decoder = new TextDecoder()
146
+ let buffer = ''
147
+
148
+ try {
149
+ while (true) {
150
+ const { done, value } = await reader.read()
151
+ if (done) break
152
+
153
+ buffer += decoder.decode(value, { stream: true })
154
+ const lines = buffer.split('\n')
155
+ buffer = lines.pop() ?? ''
156
+
157
+ for (const line of lines) {
158
+ if (!line.startsWith('data: ')) continue
159
+ const data = line.slice(6)
160
+ if (data === '[DONE]') continue
161
+
162
+ let parsed: unknown
163
+ try {
164
+ parsed = JSON.parse(data)
165
+ } catch {
166
+ continue
167
+ }
168
+
169
+ if (parsed && typeof parsed === 'object') {
170
+ const obj = parsed as Record<string, unknown>
171
+ if (typeof obj.session_id === 'string') {
172
+ yield { type: 'session', sessionId: obj.session_id }
173
+ } else if (typeof obj.token === 'string') {
174
+ yield { type: 'token', token: obj.token }
175
+ } else if (typeof obj.final_answer === 'string') {
176
+ yield {
177
+ type: 'final',
178
+ answer: obj.final_answer,
179
+ sources: Array.isArray(obj.sources) ? (obj.sources as QueryResponse['sources']) : [],
180
+ }
181
+ } else if (typeof obj.error === 'string') {
182
+ yield { type: 'error', error: obj.error }
183
+ }
184
+ }
185
+ }
186
+ }
187
+ } finally {
188
+ reader.releaseLock()
189
+ }
190
+ }
frontend/src/api/types.ts ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Types mirroring the Studyson backend API contract.
2
+
3
+ export interface SourceInfo {
4
+ file_name: string
5
+ text: string
6
+ score: number | null
7
+ }
8
+
9
+ export interface UploadDetails {
10
+ filename: string
11
+ text_length: number
12
+ indexed_documents: string[]
13
+ }
14
+
15
+ export interface UploadResponse {
16
+ status: string
17
+ message: string
18
+ details: UploadDetails
19
+ }
20
+
21
+ export interface ScrapeAndIndexRequest {
22
+ url: string
23
+ session_id?: string
24
+ }
25
+
26
+ export interface ScrapeDetails {
27
+ url: string
28
+ title: string
29
+ text_length: number
30
+ indexed_documents: string[]
31
+ }
32
+
33
+ export interface ScrapeAndIndexResponse {
34
+ status: string
35
+ message: string
36
+ details: ScrapeDetails
37
+ }
38
+
39
+ export interface DeleteDocumentResponse {
40
+ status: string
41
+ message: string
42
+ deleted: string
43
+ indexed_documents: string[]
44
+ }
45
+
46
+ export interface StreamQueryRequest {
47
+ question: string
48
+ session_id?: string
49
+ }
50
+
51
+ export interface QueryRequest {
52
+ question: string
53
+ session_id?: string
54
+ }
55
+
56
+ export interface QueryResponse {
57
+ final_answer: string
58
+ sources: SourceInfo[]
59
+ }
60
+
61
+ export interface SummarizeRequest {
62
+ max_length: number
63
+ style?: string
64
+ }
65
+
66
+ export interface SummarizeResponse {
67
+ summary: string
68
+ word_count: number
69
+ source_documents: string[]
70
+ }
71
+
72
+ export interface ResetResponse {
73
+ status: string
74
+ message: string
75
+ }
76
+
77
+ export interface StatusDetails {
78
+ model: string
79
+ has_documents: boolean
80
+ indexed_documents: string[]
81
+ document_count: number
82
+ }
83
+
84
+ export interface StatusResponse {
85
+ status: string
86
+ message: string
87
+ details: StatusDetails
88
+ }
89
+
90
+ export interface SessionSummary {
91
+ session_id: string
92
+ title: string | null
93
+ created_at: string
94
+ updated_at: string
95
+ message_count: number
96
+ }
97
+
98
+ export interface SessionMessage {
99
+ role: 'user' | 'assistant'
100
+ content: string
101
+ sources: SourceInfo[] | null
102
+ created_at: string
103
+ }
104
+
105
+ export interface SessionMessagesResponse {
106
+ session_id: string
107
+ messages: SessionMessage[]
108
+ }
109
+
110
+ export interface RenameSessionRequest {
111
+ title: string
112
+ }
113
+
114
+ export interface ApiErrorBody {
115
+ detail: string
116
+ }
117
+
118
+ // Discriminated union of parsed SSE frames from /stream_query.
119
+ export type StreamEvent =
120
+ | { type: 'session'; sessionId: string }
121
+ | { type: 'token'; token: string }
122
+ | { type: 'final'; answer: string; sources: SourceInfo[] }
123
+ | { type: 'error'; error: string }
frontend/src/components/ChatView.tsx ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useCallback, useEffect, useRef, useState } from 'react'
2
+ import type { FormEvent } from 'react'
3
+ import { streamQuery } from '../api/client.ts'
4
+ import { useSession } from '../context/SessionContext.tsx'
5
+ import type { ChatMessage } from '../context/SessionContext.tsx'
6
+ import { useToast } from './shared/Toast.tsx'
7
+ import MarkdownRenderer from './shared/MarkdownRenderer.tsx'
8
+ import './chat.css'
9
+
10
+ function makeId(): string {
11
+ return crypto.randomUUID ? crypto.randomUUID() : `m_${Date.now()}_${Math.random().toString(36).slice(2)}`
12
+ }
13
+
14
+ export default function ChatView() {
15
+ const { sessionId, messages, loadHistory, appendMessage, updateLastMessage, isLoadingHistory } =
16
+ useSession()
17
+ const [question, setQuestion] = useState('')
18
+ const [isStreaming, setIsStreaming] = useState(false)
19
+ const abortControllerRef = useRef<AbortController | null>(null)
20
+ const messagesAreaRef = useRef<HTMLDivElement>(null)
21
+ const { showToast } = useToast()
22
+
23
+ useEffect(() => {
24
+ loadHistory()
25
+ // eslint-disable-next-line react-hooks/exhaustive-deps
26
+ }, [sessionId])
27
+
28
+ useEffect(() => {
29
+ const el = messagesAreaRef.current
30
+ if (el) {
31
+ el.scrollTop = el.scrollHeight
32
+ }
33
+ }, [messages])
34
+
35
+ const handleCancel = useCallback(() => {
36
+ abortControllerRef.current?.abort()
37
+ }, [])
38
+
39
+ const handleSubmit = useCallback(
40
+ async (e: FormEvent<HTMLFormElement>) => {
41
+ e.preventDefault()
42
+ const trimmed = question.trim()
43
+ if (!trimmed || isStreaming) return
44
+
45
+ const userMessage: ChatMessage = {
46
+ id: makeId(),
47
+ role: 'user',
48
+ content: trimmed,
49
+ sources: null,
50
+ status: 'done',
51
+ createdAt: new Date().toISOString(),
52
+ }
53
+ appendMessage(userMessage)
54
+ setQuestion('')
55
+
56
+ const assistantMessage: ChatMessage = {
57
+ id: makeId(),
58
+ role: 'assistant',
59
+ content: '',
60
+ sources: null,
61
+ status: 'pending',
62
+ createdAt: new Date().toISOString(),
63
+ }
64
+ appendMessage(assistantMessage)
65
+
66
+ const controller = new AbortController()
67
+ abortControllerRef.current = controller
68
+ setIsStreaming(true)
69
+
70
+ try {
71
+ for await (const event of streamQuery(trimmed, sessionId, controller.signal)) {
72
+ if (event.type === 'token') {
73
+ updateLastMessage((msg) => ({
74
+ ...msg,
75
+ content: msg.content + event.token,
76
+ status: 'streaming',
77
+ }))
78
+ } else if (event.type === 'final') {
79
+ updateLastMessage((msg) => ({
80
+ ...msg,
81
+ content: event.answer,
82
+ sources: event.sources,
83
+ status: 'done',
84
+ }))
85
+ } else if (event.type === 'error') {
86
+ updateLastMessage((msg) => ({
87
+ ...msg,
88
+ content: msg.content || `Error: ${event.error}`,
89
+ status: 'error',
90
+ }))
91
+ showToast(event.error, 'error')
92
+ }
93
+ }
94
+ } catch (err) {
95
+ if (err instanceof DOMException && err.name === 'AbortError') {
96
+ updateLastMessage((msg) => ({
97
+ ...msg,
98
+ status: 'done',
99
+ content: msg.content || '(cancelled)',
100
+ }))
101
+ } else {
102
+ const message = err instanceof Error ? err.message : 'Streaming failed'
103
+ updateLastMessage((msg) => ({ ...msg, status: 'error', content: msg.content || `Error: ${message}` }))
104
+ showToast(message, 'error')
105
+ }
106
+ } finally {
107
+ setIsStreaming(false)
108
+ abortControllerRef.current = null
109
+ }
110
+ },
111
+ [question, isStreaming, sessionId, appendMessage, updateLastMessage, showToast],
112
+ )
113
+
114
+ return (
115
+ <div className="view-container active">
116
+ <div className="view-header">
117
+ <h2 className="view-title">Interactive Q&A</h2>
118
+ <p className="view-description">Ask questions and get intelligent answers from your documents</p>
119
+ </div>
120
+
121
+ <div className="chat-container">
122
+ <div className="messages-area" ref={messagesAreaRef}>
123
+ {isLoadingHistory && messages.length === 0 ? (
124
+ <div className="empty-state">
125
+ <div className="empty-icon">⏳</div>
126
+ <h3>Loading history…</h3>
127
+ </div>
128
+ ) : messages.length === 0 ? (
129
+ <div className="empty-state">
130
+ <div className="empty-icon">💬</div>
131
+ <h3>Start a Conversation</h3>
132
+ <p>Ask me anything about your indexed documents</p>
133
+ </div>
134
+ ) : (
135
+ messages.map((msg) => (
136
+ <div className={`message ${msg.role}`} key={msg.id}>
137
+ <div className="message-bubble">
138
+ {msg.role === 'assistant' ? (
139
+ msg.content ? (
140
+ <MarkdownRenderer text={msg.content} className="message-content" />
141
+ ) : (
142
+ <div className="message-content typing-indicator">
143
+ <span />
144
+ <span />
145
+ <span />
146
+ </div>
147
+ )
148
+ ) : (
149
+ <div className="message-content">{msg.content}</div>
150
+ )}
151
+
152
+ {msg.role === 'assistant' && msg.status === 'streaming' && (
153
+ <div className="message-sources sources-loading">
154
+ <span className="loading-spinner dark" /> Sources loading…
155
+ </div>
156
+ )}
157
+
158
+ {msg.role === 'assistant' && msg.status === 'done' && msg.sources && msg.sources.length > 0 && (
159
+ <div className="message-sources">
160
+ <strong>Sources</strong>
161
+ {msg.sources.map((source, idx) => (
162
+ <div className="source-item" key={`${msg.id}-src-${idx}`}>
163
+ <strong>
164
+ {idx + 1}. {source.file_name}
165
+ {source.score != null ? ` (${source.score.toFixed(3)})` : ''}
166
+ </strong>
167
+ <p>{source.text}…</p>
168
+ </div>
169
+ ))}
170
+ </div>
171
+ )}
172
+ </div>
173
+ </div>
174
+ ))
175
+ )}
176
+ </div>
177
+ <form className="chat-input-area" onSubmit={handleSubmit}>
178
+ <div className="chat-input-wrapper">
179
+ <input
180
+ type="text"
181
+ className="chat-input"
182
+ placeholder="Type your question here..."
183
+ value={question}
184
+ onChange={(e) => setQuestion(e.target.value)}
185
+ disabled={isStreaming}
186
+ required
187
+ />
188
+ {isStreaming ? (
189
+ <button type="button" className="btn-send btn-cancel" onClick={handleCancel} title="Cancel">
190
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none">
191
+ <rect x="6" y="6" width="12" height="12" rx="2" fill="currentColor" />
192
+ </svg>
193
+ </button>
194
+ ) : (
195
+ <button type="submit" className="btn-send" title="Send">
196
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none">
197
+ <path
198
+ d="M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z"
199
+ stroke="currentColor"
200
+ strokeWidth="2"
201
+ strokeLinecap="round"
202
+ strokeLinejoin="round"
203
+ />
204
+ </svg>
205
+ </button>
206
+ )}
207
+ </div>
208
+ </form>
209
+ </div>
210
+ </div>
211
+ )
212
+ }
frontend/src/components/Sidebar.tsx ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useCallback, useState } from 'react'
2
+ import { deleteDocument, resetDocuments } from '../api/client.ts'
3
+ import { useTheme } from '../context/ThemeContext.tsx'
4
+ import { useToast } from './shared/Toast.tsx'
5
+ import type { StatusDetails } from '../api/types.ts'
6
+ import type { ViewId } from '../App.tsx'
7
+ import './sidebar.css'
8
+
9
+ interface NavEntry {
10
+ id: ViewId
11
+ icon: string
12
+ label: string
13
+ }
14
+
15
+ const NAV_ITEMS: NavEntry[] = [
16
+ { id: 'upload', icon: '📁', label: 'Upload Files' },
17
+ { id: 'web', icon: '🌍', label: 'Web Import' },
18
+ { id: 'chat', icon: '💭', label: 'Q&A Chat' },
19
+ { id: 'summary', icon: '📊', label: 'Summarize' },
20
+ ]
21
+
22
+ interface SidebarProps {
23
+ activeView: ViewId
24
+ onViewChange: (view: ViewId) => void
25
+ status: StatusDetails | null
26
+ statusError: boolean
27
+ onStatusRefresh: () => void
28
+ }
29
+
30
+ export default function Sidebar({
31
+ activeView,
32
+ onViewChange,
33
+ status,
34
+ statusError,
35
+ onStatusRefresh,
36
+ }: SidebarProps) {
37
+ const { theme, toggleTheme } = useTheme()
38
+ const { showToast } = useToast()
39
+ const [deletingDoc, setDeletingDoc] = useState<string | null>(null)
40
+ const [resetting, setResetting] = useState(false)
41
+
42
+ const docCount = status?.document_count ?? 0
43
+ const hasDocuments = status?.has_documents ?? false
44
+ const documents = status?.indexed_documents ?? []
45
+
46
+ const pulseColor = statusError
47
+ ? 'var(--danger)'
48
+ : hasDocuments
49
+ ? 'var(--success)'
50
+ : 'var(--text-light)'
51
+ const statusLabel = statusError ? 'Connection Error' : hasDocuments ? 'Ready' : 'No Docs'
52
+
53
+ const handleDelete = useCallback(
54
+ async (docName: string) => {
55
+ setDeletingDoc(docName)
56
+ try {
57
+ const res = await deleteDocument(docName)
58
+ showToast(res.message, 'success')
59
+ onStatusRefresh()
60
+ } catch (err) {
61
+ showToast(err instanceof Error ? err.message : 'Failed to delete document', 'error')
62
+ } finally {
63
+ setDeletingDoc(null)
64
+ }
65
+ },
66
+ [showToast, onStatusRefresh],
67
+ )
68
+
69
+ const handleReset = useCallback(async () => {
70
+ if (!window.confirm('Reset all documents? This cannot be undone.')) return
71
+ setResetting(true)
72
+ try {
73
+ const res = await resetDocuments()
74
+ showToast(res.message, 'success')
75
+ onStatusRefresh()
76
+ } catch (err) {
77
+ showToast(err instanceof Error ? err.message : 'Reset failed', 'error')
78
+ } finally {
79
+ setResetting(false)
80
+ }
81
+ }, [showToast, onStatusRefresh])
82
+
83
+ return (
84
+ <aside className="sidebar">
85
+ <div className="logo-section">
86
+ <div className="logo-icon">
87
+ <svg width="40" height="40" viewBox="0 0 40 40" fill="none">
88
+ <rect width="40" height="40" rx="12" fill="url(#grad1)" />
89
+ <path
90
+ d="M12 14h16M12 20h16M12 26h10"
91
+ stroke="white"
92
+ strokeWidth="2.5"
93
+ strokeLinecap="round"
94
+ />
95
+ <defs>
96
+ <linearGradient id="grad1" x1="0" y1="0" x2="40" y2="40">
97
+ <stop offset="0%" stopColor="#667eea" />
98
+ <stop offset="100%" stopColor="#764ba2" />
99
+ </linearGradient>
100
+ </defs>
101
+ </svg>
102
+ </div>
103
+ <h1 className="logo-text">Studyson</h1>
104
+ </div>
105
+
106
+ <nav className="nav-menu">
107
+ {NAV_ITEMS.map((item) => (
108
+ <button
109
+ key={item.id}
110
+ type="button"
111
+ className={`nav-item${activeView === item.id ? ' active' : ''}`}
112
+ onClick={() => onViewChange(item.id)}
113
+ >
114
+ <span className="nav-icon">{item.icon}</span>
115
+ <span className="nav-label">{item.label}</span>
116
+ </button>
117
+ ))}
118
+ </nav>
119
+
120
+ <div className="doc-list-section">
121
+ <div className="doc-list-header">
122
+ <span>Indexed Documents</span>
123
+ <span className="doc-list-count">{documents.length}</span>
124
+ </div>
125
+ {documents.length === 0 ? (
126
+ <p className="doc-list-empty">No documents yet</p>
127
+ ) : (
128
+ <ul className="doc-list">
129
+ {documents.map((doc) => (
130
+ <li key={doc} className="doc-list-item">
131
+ <span className="doc-list-name" title={doc}>
132
+ {doc}
133
+ </span>
134
+ <button
135
+ type="button"
136
+ className="doc-delete-btn"
137
+ onClick={() => handleDelete(doc)}
138
+ disabled={deletingDoc === doc}
139
+ aria-label={`Delete ${doc}`}
140
+ title={`Delete ${doc}`}
141
+ >
142
+ {deletingDoc === doc ? '…' : '×'}
143
+ </button>
144
+ </li>
145
+ ))}
146
+ </ul>
147
+ )}
148
+ </div>
149
+
150
+ <div className="sidebar-footer">
151
+ <div className="stats-card">
152
+ <div className="stat-item">
153
+ <span className="stat-label">Documents</span>
154
+ <span className="stat-value">{docCount}</span>
155
+ </div>
156
+ <div className="stat-indicator">
157
+ <div className="pulse-dot" style={{ background: pulseColor }} />
158
+ <span>{statusLabel}</span>
159
+ </div>
160
+ </div>
161
+
162
+ <button type="button" className="btn-theme-toggle" onClick={toggleTheme}>
163
+ <span>{theme === 'dark' ? '☀️' : '🌙'}</span>
164
+ <span>{theme === 'dark' ? 'Light Mode' : 'Dark Mode'}</span>
165
+ </button>
166
+
167
+ <button type="button" className="btn-reset" onClick={handleReset} disabled={resetting}>
168
+ <span>🗑️</span>
169
+ <span>{resetting ? 'Clearing…' : 'Clear All'}</span>
170
+ </button>
171
+ </div>
172
+ </aside>
173
+ )
174
+ }
frontend/src/components/SummarizeView.tsx ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useCallback, useState } from 'react'
2
+ import type { FormEvent } from 'react'
3
+ import { summarize } from '../api/client.ts'
4
+ import { useToast } from './shared/Toast.tsx'
5
+ import Loading from './shared/Loading.tsx'
6
+ import MarkdownRenderer from './shared/MarkdownRenderer.tsx'
7
+ import './summary.css'
8
+
9
+ interface SummaryResult {
10
+ summary: string
11
+ wordCount: number
12
+ sourceDocuments: string[]
13
+ }
14
+
15
+ export default function SummarizeView() {
16
+ const [maxLength, setMaxLength] = useState(500)
17
+ const [isSubmitting, setIsSubmitting] = useState(false)
18
+ const [result, setResult] = useState<SummaryResult | null>(null)
19
+ const [error, setError] = useState<string | null>(null)
20
+ const { showToast } = useToast()
21
+
22
+ const handleSubmit = useCallback(
23
+ async (e: FormEvent<HTMLFormElement>) => {
24
+ e.preventDefault()
25
+ setIsSubmitting(true)
26
+ setError(null)
27
+ try {
28
+ const res = await summarize({ max_length: maxLength })
29
+ setResult({
30
+ summary: res.summary,
31
+ wordCount: res.word_count,
32
+ sourceDocuments: res.source_documents,
33
+ })
34
+ } catch (err) {
35
+ const message = err instanceof Error ? err.message : 'Summarization failed'
36
+ setError(message)
37
+ showToast(message, 'error')
38
+ } finally {
39
+ setIsSubmitting(false)
40
+ }
41
+ },
42
+ [maxLength, showToast],
43
+ )
44
+
45
+ return (
46
+ <div className="view-container active">
47
+ <div className="view-header">
48
+ <h2 className="view-title">Document Summarization</h2>
49
+ <p className="view-description">Generate comprehensive summaries of your indexed content</p>
50
+ </div>
51
+
52
+ <div className="content-card">
53
+ <form className="summary-form" onSubmit={handleSubmit}>
54
+ <div className="form-group">
55
+ <label className="form-label" htmlFor="max-length">
56
+ Summary Length
57
+ </label>
58
+ <div className="slider-container">
59
+ <input
60
+ type="range"
61
+ id="max-length"
62
+ className="range-slider"
63
+ min={100}
64
+ max={2000}
65
+ step={100}
66
+ value={maxLength}
67
+ onChange={(e) => setMaxLength(Number(e.target.value))}
68
+ />
69
+ <div className="slider-value">
70
+ <span>{maxLength}</span> words
71
+ </div>
72
+ </div>
73
+ </div>
74
+ <button type="submit" className="btn-primary btn-large" disabled={isSubmitting}>
75
+ {isSubmitting ? (
76
+ <>
77
+ <Loading />
78
+ <span>Generating…</span>
79
+ </>
80
+ ) : (
81
+ <>
82
+ <span>Generate Summary</span>
83
+ <span className="btn-arrow">✨</span>
84
+ </>
85
+ )}
86
+ </button>
87
+ </form>
88
+
89
+ {error && <div className="result-message show error">{error}</div>}
90
+
91
+ {result && (
92
+ <div className="result-message show success summary-output">
93
+ <h3>Summary ({result.wordCount} words)</h3>
94
+ <MarkdownRenderer text={result.summary} />
95
+ {result.sourceDocuments.length > 0 && (
96
+ <p className="summary-sources">
97
+ <strong>Sources:</strong> {result.sourceDocuments.join(', ')}
98
+ </p>
99
+ )}
100
+ </div>
101
+ )}
102
+ </div>
103
+ </div>
104
+ )
105
+ }
frontend/src/components/UploadView.tsx ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useCallback, useRef, useState } from 'react'
2
+ import type { DragEvent } from 'react'
3
+ import { uploadFile } from '../api/client.ts'
4
+ import { useToast } from './shared/Toast.tsx'
5
+ import Loading from './shared/Loading.tsx'
6
+ import './upload.css'
7
+
8
+ type FileStatus = 'pending' | 'uploading' | 'success' | 'error'
9
+
10
+ interface UploadItem {
11
+ id: string
12
+ file: File
13
+ status: FileStatus
14
+ message?: string
15
+ }
16
+
17
+ const ACCEPTED_EXTENSIONS = ['.pdf', '.docx', '.txt', '.md']
18
+ const CONCURRENCY = 2
19
+
20
+ function formatFileSize(bytes: number): string {
21
+ if (!bytes) return '0 B'
22
+ const k = 1024
23
+ const sizes = ['B', 'KB', 'MB', 'GB']
24
+ const i = Math.floor(Math.log(bytes) / Math.log(k))
25
+ return `${Math.round((bytes / Math.pow(k, i)) * 100) / 100} ${sizes[i]}`
26
+ }
27
+
28
+ function makeId(): string {
29
+ return crypto.randomUUID ? crypto.randomUUID() : `f_${Date.now()}_${Math.random().toString(36).slice(2)}`
30
+ }
31
+
32
+ interface UploadViewProps {
33
+ onIndexed: () => void
34
+ }
35
+
36
+ export default function UploadView({ onIndexed }: UploadViewProps) {
37
+ const [items, setItems] = useState<UploadItem[]>([])
38
+ const [isDragging, setIsDragging] = useState(false)
39
+ const [isUploading, setIsUploading] = useState(false)
40
+ const fileInputRef = useRef<HTMLInputElement>(null)
41
+ const { showToast } = useToast()
42
+
43
+ const addFiles = useCallback((files: FileList | File[]) => {
44
+ const list = Array.from(files)
45
+ if (list.length === 0) return
46
+ setItems((prev) => [
47
+ ...prev,
48
+ ...list.map((file) => ({ id: makeId(), file, status: 'pending' as FileStatus })),
49
+ ])
50
+ }, [])
51
+
52
+ const handleInputChange = useCallback(
53
+ (e: React.ChangeEvent<HTMLInputElement>) => {
54
+ if (e.target.files) addFiles(e.target.files)
55
+ e.target.value = ''
56
+ },
57
+ [addFiles],
58
+ )
59
+
60
+ const handleDrop = useCallback(
61
+ (e: DragEvent<HTMLLabelElement>) => {
62
+ e.preventDefault()
63
+ setIsDragging(false)
64
+ if (e.dataTransfer?.files?.length) {
65
+ addFiles(e.dataTransfer.files)
66
+ }
67
+ },
68
+ [addFiles],
69
+ )
70
+
71
+ const handleDragOver = useCallback((e: DragEvent<HTMLLabelElement>) => {
72
+ e.preventDefault()
73
+ setIsDragging(true)
74
+ }, [])
75
+
76
+ const handleDragLeave = useCallback((e: DragEvent<HTMLLabelElement>) => {
77
+ e.preventDefault()
78
+ setIsDragging(false)
79
+ }, [])
80
+
81
+ const uploadOne = useCallback(async (item: UploadItem) => {
82
+ setItems((prev) =>
83
+ prev.map((it) => (it.id === item.id ? { ...it, status: 'uploading' } : it)),
84
+ )
85
+ try {
86
+ const res = await uploadFile(item.file)
87
+ setItems((prev) =>
88
+ prev.map((it) =>
89
+ it.id === item.id ? { ...it, status: 'success', message: res.message } : it,
90
+ ),
91
+ )
92
+ return true
93
+ } catch (err) {
94
+ const message = err instanceof Error ? err.message : 'Upload failed'
95
+ setItems((prev) =>
96
+ prev.map((it) => (it.id === item.id ? { ...it, status: 'error', message } : it)),
97
+ )
98
+ return false
99
+ }
100
+ }, [])
101
+
102
+ const handleUploadAll = useCallback(async () => {
103
+ const pending = items.filter((it) => it.status === 'pending' || it.status === 'error')
104
+ if (pending.length === 0) {
105
+ showToast('No files to upload', 'error')
106
+ return
107
+ }
108
+
109
+ setIsUploading(true)
110
+ let successCount = 0
111
+ let queueIndex = 0
112
+
113
+ async function worker() {
114
+ while (queueIndex < pending.length) {
115
+ const item = pending[queueIndex]
116
+ queueIndex += 1
117
+ if (!item) continue
118
+ const ok = await uploadOne(item)
119
+ if (ok) successCount += 1
120
+ }
121
+ }
122
+
123
+ const workers = Array.from({ length: Math.min(CONCURRENCY, pending.length) }, () => worker())
124
+ await Promise.all(workers)
125
+
126
+ setIsUploading(false)
127
+
128
+ if (successCount > 0) {
129
+ showToast(`${successCount} file(s) uploaded and indexed`, 'success')
130
+ onIndexed()
131
+ }
132
+ if (successCount < pending.length) {
133
+ showToast(`${pending.length - successCount} file(s) failed to upload`, 'error')
134
+ }
135
+ }, [items, uploadOne, showToast, onIndexed])
136
+
137
+ const removeItem = useCallback((id: string) => {
138
+ setItems((prev) => prev.filter((it) => it.id !== id))
139
+ }, [])
140
+
141
+ const clearFinished = useCallback(() => {
142
+ setItems((prev) => prev.filter((it) => it.status !== 'success'))
143
+ }, [])
144
+
145
+ const statusIcon: Record<FileStatus, string> = {
146
+ pending: '⏳',
147
+ uploading: '⬆️',
148
+ success: '✅',
149
+ error: '❌',
150
+ }
151
+
152
+ return (
153
+ <div className="view-container active">
154
+ <div className="view-header">
155
+ <h2 className="view-title">Upload Documents</h2>
156
+ <p className="view-description">
157
+ Import PDF, DOCX, TXT, or Markdown files to build a searchable knowledge base
158
+ </p>
159
+ </div>
160
+
161
+ <div className="content-card">
162
+ <div className="upload-area">
163
+ <input
164
+ ref={fileInputRef}
165
+ type="file"
166
+ id="file-input"
167
+ accept={ACCEPTED_EXTENSIONS.join(',')}
168
+ multiple
169
+ hidden
170
+ onChange={handleInputChange}
171
+ />
172
+ <label
173
+ htmlFor="file-input"
174
+ className={`drop-zone${isDragging ? ' dragging' : ''}`}
175
+ onDrop={handleDrop}
176
+ onDragOver={handleDragOver}
177
+ onDragEnter={handleDragOver}
178
+ onDragLeave={handleDragLeave}
179
+ >
180
+ <div className="drop-zone-icon">📄</div>
181
+ <h3 className="drop-zone-title">
182
+ {items.length > 0 ? 'Add more files' : 'Drop your files here'}
183
+ </h3>
184
+ <p className="drop-zone-desc">PDF, DOCX, TXT, or Markdown — click to browse (multiple allowed)</p>
185
+ </label>
186
+
187
+ {items.length > 0 && (
188
+ <div className="file-list">
189
+ {items.map((item) => (
190
+ <div className="file-info" key={item.id}>
191
+ <span className="file-icon">📎</span>
192
+ <span className="file-name-display">{item.file.name}</span>
193
+ <span className="file-size">{formatFileSize(item.file.size)}</span>
194
+ <span className={`file-status file-status-${item.status}`}>
195
+ {statusIcon[item.status]}{' '}
196
+ {item.status === 'uploading'
197
+ ? 'Uploading…'
198
+ : item.status === 'error'
199
+ ? item.message ?? 'Failed'
200
+ : item.status === 'success'
201
+ ? 'Indexed'
202
+ : 'Pending'}
203
+ </span>
204
+ {item.status !== 'uploading' && (
205
+ <button
206
+ type="button"
207
+ className="file-remove-btn"
208
+ onClick={() => removeItem(item.id)}
209
+ aria-label={`Remove ${item.file.name}`}
210
+ >
211
+ ×
212
+ </button>
213
+ )}
214
+ </div>
215
+ ))}
216
+ </div>
217
+ )}
218
+
219
+ <div className="upload-actions">
220
+ <button
221
+ type="button"
222
+ className="btn-primary btn-large"
223
+ onClick={handleUploadAll}
224
+ disabled={isUploading || items.every((it) => it.status === 'success')}
225
+ >
226
+ {isUploading ? (
227
+ <>
228
+ <Loading />
229
+ <span>Uploading…</span>
230
+ </>
231
+ ) : (
232
+ <>
233
+ <span>Upload & Index {items.length > 0 ? `(${items.length})` : ''}</span>
234
+ <span className="btn-arrow">→</span>
235
+ </>
236
+ )}
237
+ </button>
238
+ {items.some((it) => it.status === 'success') && (
239
+ <button type="button" className="btn-secondary" onClick={clearFinished}>
240
+ Clear finished
241
+ </button>
242
+ )}
243
+ </div>
244
+ </div>
245
+ </div>
246
+ </div>
247
+ )
248
+ }
frontend/src/components/WebImportView.tsx ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useCallback, useState } from 'react'
2
+ import type { FormEvent } from 'react'
3
+ import { scrapeAndIndex } from '../api/client.ts'
4
+ import { useSession } from '../context/SessionContext.tsx'
5
+ import { useToast } from './shared/Toast.tsx'
6
+ import Loading from './shared/Loading.tsx'
7
+ import './web.css'
8
+
9
+ interface WebImportViewProps {
10
+ onIndexed: () => void
11
+ }
12
+
13
+ export default function WebImportView({ onIndexed }: WebImportViewProps) {
14
+ const [url, setUrl] = useState('')
15
+ const [isSubmitting, setIsSubmitting] = useState(false)
16
+ const [result, setResult] = useState<{ message: string; type: 'success' | 'error' } | null>(null)
17
+ const { sessionId } = useSession()
18
+ const { showToast } = useToast()
19
+
20
+ const handleSubmit = useCallback(
21
+ async (e: FormEvent<HTMLFormElement>) => {
22
+ e.preventDefault()
23
+ if (!url.trim()) return
24
+
25
+ setIsSubmitting(true)
26
+ setResult(null)
27
+ try {
28
+ const res = await scrapeAndIndex({ url: url.trim(), session_id: sessionId })
29
+ setResult({ message: res.message, type: 'success' })
30
+ showToast(res.message, 'success')
31
+ setUrl('')
32
+ onIndexed()
33
+ } catch (err) {
34
+ const message = err instanceof Error ? err.message : 'Scraping failed'
35
+ setResult({ message, type: 'error' })
36
+ showToast(message, 'error')
37
+ } finally {
38
+ setIsSubmitting(false)
39
+ }
40
+ },
41
+ [url, sessionId, showToast, onIndexed],
42
+ )
43
+
44
+ return (
45
+ <div className="view-container active">
46
+ <div className="view-header">
47
+ <h2 className="view-title">Import from Web</h2>
48
+ <p className="view-description">Extract and index content from any webpage</p>
49
+ </div>
50
+
51
+ <div className="content-card">
52
+ <form className="web-form" onSubmit={handleSubmit}>
53
+ <div className="input-group">
54
+ <span className="input-icon">🔗</span>
55
+ <input
56
+ type="url"
57
+ className="input-field"
58
+ placeholder="https://example.com/article"
59
+ value={url}
60
+ onChange={(e) => setUrl(e.target.value)}
61
+ required
62
+ />
63
+ </div>
64
+ <button type="submit" className="btn-primary btn-large" disabled={isSubmitting}>
65
+ {isSubmitting ? (
66
+ <>
67
+ <Loading />
68
+ <span>Fetching…</span>
69
+ </>
70
+ ) : (
71
+ <>
72
+ <span>Fetch & Index Content</span>
73
+ <span className="btn-arrow">→</span>
74
+ </>
75
+ )}
76
+ </button>
77
+ </form>
78
+ {result && (
79
+ <div className={`result-message show ${result.type}`}>{result.message}</div>
80
+ )}
81
+ </div>
82
+ </div>
83
+ )
84
+ }
frontend/src/components/chat.css ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .chat-container {
2
+ background: var(--bg-card);
3
+ border-radius: 16px;
4
+ box-shadow: var(--shadow-md);
5
+ display: flex;
6
+ flex-direction: column;
7
+ height: 600px;
8
+ }
9
+
10
+ .messages-area {
11
+ flex: 1;
12
+ overflow-y: auto;
13
+ padding: 2rem;
14
+ }
15
+
16
+ .empty-state {
17
+ height: 100%;
18
+ display: flex;
19
+ flex-direction: column;
20
+ align-items: center;
21
+ justify-content: center;
22
+ color: var(--text-secondary);
23
+ text-align: center;
24
+ }
25
+
26
+ .empty-icon {
27
+ font-size: 4rem;
28
+ margin-bottom: 1rem;
29
+ opacity: 0.5;
30
+ }
31
+
32
+ .empty-state h3 {
33
+ font-size: 1.5rem;
34
+ margin-bottom: 0.5rem;
35
+ color: var(--text-primary);
36
+ }
37
+
38
+ .message {
39
+ margin-bottom: 1.5rem;
40
+ display: flex;
41
+ gap: 1rem;
42
+ animation: slideIn 0.3s ease;
43
+ }
44
+
45
+ .message-bubble {
46
+ max-width: 70%;
47
+ padding: 1.25rem 1.5rem;
48
+ border-radius: 16px;
49
+ line-height: 1.6;
50
+ }
51
+
52
+ .message.user .message-bubble {
53
+ background: var(--gradient-primary);
54
+ color: white;
55
+ margin-left: auto;
56
+ border-bottom-right-radius: 4px;
57
+ }
58
+
59
+ .message.assistant .message-bubble {
60
+ background: var(--bg-main);
61
+ color: var(--text-primary);
62
+ border-bottom-left-radius: 4px;
63
+ }
64
+
65
+ .typing-indicator {
66
+ display: flex;
67
+ gap: 0.3rem;
68
+ padding: 0.25rem 0;
69
+ }
70
+
71
+ .typing-indicator span {
72
+ width: 7px;
73
+ height: 7px;
74
+ border-radius: 50%;
75
+ background: var(--text-secondary);
76
+ animation: pulse 1.2s infinite;
77
+ }
78
+
79
+ .typing-indicator span:nth-child(2) {
80
+ animation-delay: 0.2s;
81
+ }
82
+
83
+ .typing-indicator span:nth-child(3) {
84
+ animation-delay: 0.4s;
85
+ }
86
+
87
+ .message-sources {
88
+ margin-top: 1rem;
89
+ padding-top: 1rem;
90
+ border-top: 1px solid var(--border);
91
+ font-size: 0.875rem;
92
+ }
93
+
94
+ .message.user .message-sources {
95
+ border-top: 1px solid rgba(255, 255, 255, 0.2);
96
+ }
97
+
98
+ .sources-loading {
99
+ display: flex;
100
+ align-items: center;
101
+ gap: 0.5rem;
102
+ color: var(--text-secondary);
103
+ font-style: italic;
104
+ }
105
+
106
+ .source-item {
107
+ margin-top: 0.75rem;
108
+ padding: 0.75rem;
109
+ background: rgba(102, 126, 234, 0.08);
110
+ border-radius: 8px;
111
+ font-size: 0.85rem;
112
+ }
113
+
114
+ .message.user .source-item {
115
+ background: rgba(255, 255, 255, 0.1);
116
+ }
117
+
118
+ .source-item strong {
119
+ display: block;
120
+ margin-bottom: 0.25rem;
121
+ }
122
+
123
+ .chat-input-area {
124
+ padding: 1.5rem;
125
+ border-top: 1px solid var(--border);
126
+ }
127
+
128
+ .chat-input-wrapper {
129
+ display: flex;
130
+ gap: 1rem;
131
+ align-items: center;
132
+ }
133
+
134
+ .chat-input {
135
+ flex: 1;
136
+ padding: 1rem 1.5rem;
137
+ border: 2px solid var(--border);
138
+ border-radius: 12px;
139
+ font-size: 1rem;
140
+ font-family: inherit;
141
+ transition: all 0.3s ease;
142
+ background: var(--bg-card);
143
+ color: var(--text-primary);
144
+ }
145
+
146
+ .chat-input:focus {
147
+ outline: none;
148
+ border-color: var(--primary);
149
+ box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
150
+ }
151
+
152
+ .chat-input:disabled {
153
+ opacity: 0.6;
154
+ }
155
+
156
+ .btn-send {
157
+ width: 50px;
158
+ height: 50px;
159
+ border-radius: 12px;
160
+ background: var(--gradient-primary);
161
+ border: none;
162
+ color: white;
163
+ cursor: pointer;
164
+ display: flex;
165
+ align-items: center;
166
+ justify-content: center;
167
+ transition: all 0.3s ease;
168
+ flex-shrink: 0;
169
+ }
170
+
171
+ .btn-send:hover {
172
+ transform: scale(1.05);
173
+ box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
174
+ }
175
+
176
+ .btn-cancel {
177
+ background: var(--danger);
178
+ }
179
+
180
+ @media (max-width: 768px) {
181
+ .message-bubble {
182
+ max-width: 85%;
183
+ }
184
+ }
frontend/src/components/shared/Loading.tsx ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ interface LoadingProps {
2
+ variant?: 'light' | 'dark'
3
+ }
4
+
5
+ export default function Loading({ variant = 'light' }: LoadingProps) {
6
+ return <span className={`loading-spinner${variant === 'dark' ? ' dark' : ''}`} aria-hidden="true" />
7
+ }
frontend/src/components/shared/MarkdownRenderer.tsx ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useMemo } from 'react'
2
+ import { marked } from 'marked'
3
+ import DOMPurify from 'dompurify'
4
+
5
+ interface MarkdownRendererProps {
6
+ text: string
7
+ className?: string
8
+ }
9
+
10
+ export default function MarkdownRenderer({ text, className }: MarkdownRendererProps) {
11
+ const html = useMemo(() => {
12
+ const rawHtml = marked.parse(text, { breaks: true, gfm: true }) as string
13
+ return DOMPurify.sanitize(rawHtml)
14
+ }, [text])
15
+
16
+ const classes = ['markdown-body', className].filter(Boolean).join(' ')
17
+
18
+ // eslint-disable-next-line react/no-danger
19
+ return <div className={classes} dangerouslySetInnerHTML={{ __html: html }} />
20
+ }
frontend/src/components/shared/Toast.tsx ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { createContext, useCallback, useContext, useMemo, useRef, useState } from 'react'
2
+ import type { ReactNode } from 'react'
3
+ import './toast.css'
4
+
5
+ export type ToastType = 'success' | 'error' | 'info'
6
+
7
+ interface ToastItem {
8
+ id: string
9
+ message: string
10
+ type: ToastType
11
+ visible: boolean
12
+ }
13
+
14
+ interface ToastContextValue {
15
+ showToast: (message: string, type?: ToastType, duration?: number) => void
16
+ }
17
+
18
+ const ToastContext = createContext<ToastContextValue | undefined>(undefined)
19
+
20
+ export function ToastProvider({ children }: { children: ReactNode }) {
21
+ const [toasts, setToasts] = useState<ToastItem[]>([])
22
+ const counterRef = useRef(0)
23
+
24
+ const showToast = useCallback((message: string, type: ToastType = 'info', duration = 4000) => {
25
+ const id = `toast_${Date.now()}_${counterRef.current++}`
26
+ setToasts((prev) => [...prev, { id, message, type, visible: false }])
27
+
28
+ // Trigger enter animation on next frame.
29
+ requestAnimationFrame(() => {
30
+ setToasts((prev) => prev.map((t) => (t.id === id ? { ...t, visible: true } : t)))
31
+ })
32
+
33
+ setTimeout(() => {
34
+ setToasts((prev) => prev.map((t) => (t.id === id ? { ...t, visible: false } : t)))
35
+ setTimeout(() => {
36
+ setToasts((prev) => prev.filter((t) => t.id !== id))
37
+ }, 300)
38
+ }, duration)
39
+ }, [])
40
+
41
+ const value = useMemo(() => ({ showToast }), [showToast])
42
+
43
+ return (
44
+ <ToastContext.Provider value={value}>
45
+ {children}
46
+ <div className="toast-container" aria-live="polite">
47
+ {toasts.map((t) => (
48
+ <div key={t.id} className={`toast toast-${t.type}${t.visible ? ' show' : ''}`}>
49
+ {t.message}
50
+ </div>
51
+ ))}
52
+ </div>
53
+ </ToastContext.Provider>
54
+ )
55
+ }
56
+
57
+ export function useToast(): ToastContextValue {
58
+ const ctx = useContext(ToastContext)
59
+ if (!ctx) {
60
+ throw new Error('useToast must be used within a ToastProvider')
61
+ }
62
+ return ctx
63
+ }
frontend/src/components/shared/toast.css ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .toast-container {
2
+ position: fixed;
3
+ top: 1rem;
4
+ right: 1rem;
5
+ display: flex;
6
+ flex-direction: column;
7
+ gap: 0.5rem;
8
+ z-index: 9999;
9
+ pointer-events: none;
10
+ }
11
+ .toast {
12
+ pointer-events: auto;
13
+ min-width: 240px;
14
+ max-width: 360px;
15
+ padding: 0.75rem 1rem;
16
+ border-radius: 10px;
17
+ color: white;
18
+ font-size: 0.9rem;
19
+ box-shadow: var(--shadow-md);
20
+ opacity: 0;
21
+ transform: translateX(20px);
22
+ transition:
23
+ opacity 0.25s ease,
24
+ transform 0.25s ease;
25
+ }
26
+ .toast.show {
27
+ opacity: 1;
28
+ transform: translateX(0);
29
+ }
30
+ .toast-success {
31
+ background: var(--success);
32
+ }
33
+ .toast-error {
34
+ background: var(--danger);
35
+ }
36
+ .toast-info {
37
+ background: var(--primary);
38
+ }
frontend/src/components/sidebar.css ADDED
@@ -0,0 +1,334 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .sidebar {
2
+ width: 280px;
3
+ background: var(--bg-sidebar);
4
+ color: white;
5
+ display: flex;
6
+ flex-direction: column;
7
+ position: fixed;
8
+ height: 100vh;
9
+ left: 0;
10
+ top: 0;
11
+ z-index: 100;
12
+ box-shadow: var(--shadow-lg);
13
+ }
14
+
15
+ .logo-section {
16
+ padding: 2rem 1.5rem;
17
+ display: flex;
18
+ align-items: center;
19
+ gap: 1rem;
20
+ border-bottom: 1px solid rgba(255, 255, 255, 0.1);
21
+ flex-shrink: 0;
22
+ }
23
+
24
+ .logo-icon {
25
+ flex-shrink: 0;
26
+ }
27
+
28
+ .logo-text {
29
+ font-size: 1.5rem;
30
+ font-weight: 700;
31
+ background: var(--gradient-primary);
32
+ -webkit-background-clip: text;
33
+ -webkit-text-fill-color: transparent;
34
+ background-clip: text;
35
+ }
36
+
37
+ .nav-menu {
38
+ padding: 1.5rem 1rem;
39
+ display: flex;
40
+ flex-direction: column;
41
+ gap: 0.5rem;
42
+ flex-shrink: 0;
43
+ }
44
+
45
+ .nav-item {
46
+ display: flex;
47
+ align-items: center;
48
+ gap: 1rem;
49
+ padding: 1rem 1.25rem;
50
+ background: transparent;
51
+ border: none;
52
+ border-radius: 12px;
53
+ color: rgba(255, 255, 255, 0.7);
54
+ cursor: pointer;
55
+ transition: all 0.3s ease;
56
+ font-size: 0.95rem;
57
+ font-weight: 500;
58
+ width: 100%;
59
+ text-align: left;
60
+ }
61
+
62
+ .nav-item:hover {
63
+ background: rgba(255, 255, 255, 0.08);
64
+ color: white;
65
+ transform: translateX(4px);
66
+ }
67
+
68
+ .nav-item.active {
69
+ background: var(--gradient-primary);
70
+ color: white;
71
+ box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
72
+ }
73
+
74
+ .nav-icon {
75
+ font-size: 1.5rem;
76
+ }
77
+
78
+ /* ===== DOCUMENT LIST ===== */
79
+ .doc-list-section {
80
+ flex: 1;
81
+ min-height: 0;
82
+ padding: 0.5rem 1.5rem;
83
+ display: flex;
84
+ flex-direction: column;
85
+ overflow: hidden;
86
+ }
87
+
88
+ .doc-list-header {
89
+ display: flex;
90
+ justify-content: space-between;
91
+ align-items: center;
92
+ font-size: 0.8rem;
93
+ text-transform: uppercase;
94
+ letter-spacing: 0.05em;
95
+ color: rgba(255, 255, 255, 0.5);
96
+ padding: 0.5rem 0;
97
+ flex-shrink: 0;
98
+ }
99
+
100
+ .doc-list-count {
101
+ background: rgba(255, 255, 255, 0.1);
102
+ border-radius: 10px;
103
+ padding: 0.1rem 0.5rem;
104
+ font-weight: 600;
105
+ }
106
+
107
+ .doc-list-empty {
108
+ color: rgba(255, 255, 255, 0.4);
109
+ font-size: 0.85rem;
110
+ padding: 0.5rem 0;
111
+ }
112
+
113
+ .doc-list {
114
+ list-style: none;
115
+ overflow-y: auto;
116
+ flex: 1;
117
+ display: flex;
118
+ flex-direction: column;
119
+ gap: 0.35rem;
120
+ padding-bottom: 0.5rem;
121
+ }
122
+
123
+ .doc-list-item {
124
+ display: flex;
125
+ align-items: center;
126
+ gap: 0.5rem;
127
+ background: rgba(255, 255, 255, 0.05);
128
+ border-radius: 8px;
129
+ padding: 0.5rem 0.5rem 0.5rem 0.75rem;
130
+ font-size: 0.8rem;
131
+ }
132
+
133
+ .doc-list-name {
134
+ flex: 1;
135
+ overflow: hidden;
136
+ text-overflow: ellipsis;
137
+ white-space: nowrap;
138
+ color: rgba(255, 255, 255, 0.85);
139
+ }
140
+
141
+ .doc-delete-btn {
142
+ flex-shrink: 0;
143
+ width: 22px;
144
+ height: 22px;
145
+ border-radius: 6px;
146
+ border: none;
147
+ background: rgba(245, 101, 101, 0.15);
148
+ color: #fc8181;
149
+ cursor: pointer;
150
+ font-size: 1rem;
151
+ line-height: 1;
152
+ display: flex;
153
+ align-items: center;
154
+ justify-content: center;
155
+ transition: all 0.2s ease;
156
+ }
157
+
158
+ .doc-delete-btn:hover:not(:disabled) {
159
+ background: rgba(245, 101, 101, 0.35);
160
+ }
161
+
162
+ .doc-delete-btn:disabled {
163
+ opacity: 0.6;
164
+ cursor: not-allowed;
165
+ }
166
+
167
+ .sidebar-footer {
168
+ padding: 1.5rem 1rem;
169
+ border-top: 1px solid rgba(255, 255, 255, 0.1);
170
+ flex-shrink: 0;
171
+ display: flex;
172
+ flex-direction: column;
173
+ gap: 0.75rem;
174
+ }
175
+
176
+ .stats-card {
177
+ background: rgba(255, 255, 255, 0.05);
178
+ padding: 1rem;
179
+ border-radius: 12px;
180
+ }
181
+
182
+ .stat-item {
183
+ display: flex;
184
+ justify-content: space-between;
185
+ align-items: center;
186
+ margin-bottom: 0.75rem;
187
+ }
188
+
189
+ .stat-label {
190
+ font-size: 0.85rem;
191
+ color: rgba(255, 255, 255, 0.6);
192
+ }
193
+
194
+ .stat-value {
195
+ font-size: 1.5rem;
196
+ font-weight: 700;
197
+ color: var(--accent);
198
+ }
199
+
200
+ .stat-indicator {
201
+ display: flex;
202
+ align-items: center;
203
+ gap: 0.5rem;
204
+ font-size: 0.85rem;
205
+ color: rgba(255, 255, 255, 0.7);
206
+ }
207
+
208
+ .pulse-dot {
209
+ width: 8px;
210
+ height: 8px;
211
+ background: var(--success);
212
+ border-radius: 50%;
213
+ animation: pulse 2s infinite;
214
+ flex-shrink: 0;
215
+ }
216
+
217
+ .btn-theme-toggle {
218
+ width: 100%;
219
+ padding: 0.875rem 1rem;
220
+ background: rgba(255, 255, 255, 0.06);
221
+ border: 1px solid rgba(255, 255, 255, 0.12);
222
+ border-radius: 10px;
223
+ color: rgba(255, 255, 255, 0.85);
224
+ font-weight: 500;
225
+ cursor: pointer;
226
+ transition: all 0.3s ease;
227
+ display: flex;
228
+ align-items: center;
229
+ justify-content: center;
230
+ gap: 0.5rem;
231
+ }
232
+
233
+ .btn-theme-toggle:hover {
234
+ background: rgba(255, 255, 255, 0.12);
235
+ }
236
+
237
+ .btn-reset {
238
+ width: 100%;
239
+ padding: 0.875rem 1rem;
240
+ background: rgba(245, 101, 101, 0.1);
241
+ border: 1px solid rgba(245, 101, 101, 0.3);
242
+ border-radius: 10px;
243
+ color: #fc8181;
244
+ font-weight: 500;
245
+ cursor: pointer;
246
+ transition: all 0.3s ease;
247
+ display: flex;
248
+ align-items: center;
249
+ justify-content: center;
250
+ gap: 0.5rem;
251
+ }
252
+
253
+ .btn-reset:hover:not(:disabled) {
254
+ background: rgba(245, 101, 101, 0.2);
255
+ border-color: rgba(245, 101, 101, 0.5);
256
+ }
257
+
258
+ .btn-reset:disabled {
259
+ opacity: 0.6;
260
+ cursor: not-allowed;
261
+ }
262
+
263
+ /* ===== MAIN CONTENT (shared shell) ===== */
264
+ .main-content {
265
+ margin-left: 280px;
266
+ flex: 1;
267
+ min-height: 100vh;
268
+ display: flex;
269
+ flex-direction: column;
270
+ }
271
+
272
+ .topbar {
273
+ background: var(--bg-card);
274
+ padding: 1.5rem 2.5rem;
275
+ display: flex;
276
+ justify-content: space-between;
277
+ align-items: center;
278
+ box-shadow: var(--shadow-sm);
279
+ position: sticky;
280
+ top: 0;
281
+ z-index: 50;
282
+ }
283
+
284
+ .breadcrumb-item {
285
+ font-size: 1.25rem;
286
+ font-weight: 600;
287
+ color: var(--text-primary);
288
+ }
289
+
290
+ .status-badge {
291
+ display: flex;
292
+ align-items: center;
293
+ gap: 0.5rem;
294
+ padding: 0.5rem 1rem;
295
+ background: var(--bg-main);
296
+ border-radius: 20px;
297
+ font-size: 0.875rem;
298
+ font-weight: 500;
299
+ color: var(--text-primary);
300
+ }
301
+
302
+ .status-dot {
303
+ width: 8px;
304
+ height: 8px;
305
+ border-radius: 50%;
306
+ animation: pulse 2s infinite;
307
+ flex-shrink: 0;
308
+ }
309
+
310
+ /* ===== RESPONSIVE ===== */
311
+ @media (max-width: 1024px) {
312
+ .sidebar {
313
+ width: 240px;
314
+ }
315
+
316
+ .main-content {
317
+ margin-left: 240px;
318
+ }
319
+ }
320
+
321
+ @media (max-width: 768px) {
322
+ .sidebar {
323
+ transform: translateX(-100%);
324
+ transition: transform 0.3s ease;
325
+ }
326
+
327
+ .main-content {
328
+ margin-left: 0;
329
+ }
330
+
331
+ .topbar {
332
+ padding: 1rem 1.5rem;
333
+ }
334
+ }
frontend/src/components/summary.css ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .summary-form {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 2rem;
5
+ }
6
+
7
+ .form-group {
8
+ display: flex;
9
+ flex-direction: column;
10
+ gap: 1rem;
11
+ }
12
+
13
+ .form-label {
14
+ font-size: 1.05rem;
15
+ font-weight: 600;
16
+ color: var(--text-primary);
17
+ }
18
+
19
+ .slider-container {
20
+ display: flex;
21
+ align-items: center;
22
+ gap: 1.5rem;
23
+ }
24
+
25
+ .range-slider {
26
+ flex: 1;
27
+ height: 8px;
28
+ border-radius: 4px;
29
+ background: var(--gradient-primary);
30
+ outline: none;
31
+ -webkit-appearance: none;
32
+ }
33
+
34
+ .range-slider::-webkit-slider-thumb {
35
+ -webkit-appearance: none;
36
+ width: 24px;
37
+ height: 24px;
38
+ border-radius: 50%;
39
+ background: white;
40
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
41
+ cursor: pointer;
42
+ }
43
+
44
+ .range-slider::-moz-range-thumb {
45
+ width: 24px;
46
+ height: 24px;
47
+ border-radius: 50%;
48
+ background: white;
49
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
50
+ cursor: pointer;
51
+ border: none;
52
+ }
53
+
54
+ .slider-value {
55
+ min-width: 100px;
56
+ padding: 0.75rem 1.25rem;
57
+ background: var(--bg-main);
58
+ border-radius: 8px;
59
+ font-weight: 600;
60
+ text-align: center;
61
+ color: var(--primary);
62
+ }
63
+
64
+ .summary-output h3 {
65
+ font-size: 1.25rem;
66
+ margin-bottom: 1rem;
67
+ color: var(--text-primary);
68
+ }
69
+
70
+ .summary-output p {
71
+ line-height: 1.8;
72
+ margin-bottom: 1rem;
73
+ }
74
+
75
+ .summary-sources {
76
+ margin-top: 1rem;
77
+ padding-top: 1rem;
78
+ border-top: 1px solid var(--border);
79
+ font-size: 0.9rem;
80
+ color: var(--text-secondary);
81
+ }
frontend/src/components/upload.css ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .upload-area {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 1.5rem;
5
+ }
6
+
7
+ .drop-zone {
8
+ border: 3px dashed var(--border);
9
+ border-radius: 16px;
10
+ padding: 3rem 2rem;
11
+ text-align: center;
12
+ cursor: pointer;
13
+ transition: all 0.3s ease;
14
+ background: var(--bg-main);
15
+ display: block;
16
+ }
17
+
18
+ .drop-zone:hover {
19
+ border-color: var(--primary);
20
+ }
21
+
22
+ .drop-zone.dragging {
23
+ border-color: var(--primary);
24
+ background: rgba(102, 126, 234, 0.08);
25
+ }
26
+
27
+ .drop-zone-icon {
28
+ font-size: 4rem;
29
+ margin-bottom: 1rem;
30
+ }
31
+
32
+ .drop-zone-title {
33
+ font-size: 1.35rem;
34
+ font-weight: 600;
35
+ color: var(--text-primary);
36
+ margin-bottom: 0.5rem;
37
+ }
38
+
39
+ .drop-zone-desc {
40
+ color: var(--text-secondary);
41
+ font-size: 1rem;
42
+ }
43
+
44
+ .file-list {
45
+ display: flex;
46
+ flex-direction: column;
47
+ gap: 0.75rem;
48
+ }
49
+
50
+ .file-info {
51
+ padding: 1.25rem;
52
+ background: var(--bg-card);
53
+ border: 1px solid var(--border);
54
+ border-radius: 12px;
55
+ display: flex;
56
+ align-items: center;
57
+ gap: 1rem;
58
+ box-shadow: var(--shadow-sm);
59
+ }
60
+
61
+ .file-icon {
62
+ font-size: 1.5rem;
63
+ }
64
+
65
+ .file-name-display {
66
+ flex: 1;
67
+ font-weight: 600;
68
+ color: var(--text-primary);
69
+ overflow: hidden;
70
+ text-overflow: ellipsis;
71
+ white-space: nowrap;
72
+ }
73
+
74
+ .file-size {
75
+ color: var(--text-secondary);
76
+ font-size: 0.875rem;
77
+ flex-shrink: 0;
78
+ }
79
+
80
+ .file-status {
81
+ font-size: 0.85rem;
82
+ flex-shrink: 0;
83
+ color: var(--text-secondary);
84
+ white-space: nowrap;
85
+ }
86
+
87
+ .file-status-success {
88
+ color: var(--success);
89
+ }
90
+
91
+ .file-status-error {
92
+ color: var(--danger);
93
+ }
94
+
95
+ .file-remove-btn {
96
+ flex-shrink: 0;
97
+ width: 24px;
98
+ height: 24px;
99
+ border-radius: 6px;
100
+ border: none;
101
+ background: transparent;
102
+ color: var(--text-secondary);
103
+ cursor: pointer;
104
+ font-size: 1.1rem;
105
+ line-height: 1;
106
+ }
107
+
108
+ .file-remove-btn:hover {
109
+ background: rgba(245, 101, 101, 0.15);
110
+ color: var(--danger);
111
+ }
112
+
113
+ .upload-actions {
114
+ display: flex;
115
+ gap: 1rem;
116
+ align-items: center;
117
+ }
118
+
119
+ .upload-actions .btn-primary {
120
+ flex: 1;
121
+ }
122
+
123
+ .btn-secondary {
124
+ padding: 1rem 1.5rem;
125
+ background: transparent;
126
+ border: 2px solid var(--border);
127
+ border-radius: 12px;
128
+ color: var(--text-secondary);
129
+ font-weight: 600;
130
+ cursor: pointer;
131
+ transition: all 0.2s ease;
132
+ white-space: nowrap;
133
+ }
134
+
135
+ .btn-secondary:hover {
136
+ border-color: var(--primary);
137
+ color: var(--primary);
138
+ }
frontend/src/components/web.css ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .web-form {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 1.5rem;
5
+ }
6
+
7
+ .input-group {
8
+ position: relative;
9
+ }
10
+
11
+ .input-icon {
12
+ position: absolute;
13
+ left: 1.25rem;
14
+ top: 50%;
15
+ transform: translateY(-50%);
16
+ font-size: 1.5rem;
17
+ }
18
+
19
+ .input-field {
20
+ width: 100%;
21
+ padding: 1.25rem 1.25rem 1.25rem 3.5rem;
22
+ border: 2px solid var(--border);
23
+ border-radius: 12px;
24
+ font-size: 1rem;
25
+ transition: all 0.3s ease;
26
+ font-family: inherit;
27
+ background: var(--bg-card);
28
+ color: var(--text-primary);
29
+ }
30
+
31
+ .input-field:focus {
32
+ outline: none;
33
+ border-color: var(--primary);
34
+ box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
35
+ }
frontend/src/context/SessionContext.tsx ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { createContext, useCallback, useContext, useMemo, useState } from 'react'
2
+ import type { ReactNode } from 'react'
3
+ import { getSessionMessages } from '../api/client.ts'
4
+ import type { SourceInfo } from '../api/types.ts'
5
+
6
+ export type MessageStatus = 'pending' | 'streaming' | 'done' | 'error'
7
+
8
+ export interface ChatMessage {
9
+ id: string
10
+ role: 'user' | 'assistant'
11
+ content: string
12
+ sources: SourceInfo[] | null
13
+ status: MessageStatus
14
+ createdAt: string
15
+ }
16
+
17
+ interface SessionContextValue {
18
+ sessionId: string
19
+ messages: ChatMessage[]
20
+ isLoadingHistory: boolean
21
+ loadHistory: () => Promise<void>
22
+ appendMessage: (message: ChatMessage) => void
23
+ updateLastMessage: (updater: (message: ChatMessage) => ChatMessage) => void
24
+ switchSession: (newSessionId: string) => void
25
+ setMessages: (messages: ChatMessage[]) => void
26
+ }
27
+
28
+ const SESSION_KEY = 'studyson:session_id'
29
+
30
+ const SessionContext = createContext<SessionContextValue | undefined>(undefined)
31
+
32
+ function getOrCreateSessionId(): string {
33
+ let id = localStorage.getItem(SESSION_KEY)
34
+ if (!id) {
35
+ id = crypto.randomUUID()
36
+ localStorage.setItem(SESSION_KEY, id)
37
+ }
38
+ return id
39
+ }
40
+
41
+ function makeMessageId(): string {
42
+ return crypto.randomUUID ? crypto.randomUUID() : `m_${Date.now()}_${Math.random().toString(36).slice(2)}`
43
+ }
44
+
45
+ export function SessionProvider({ children }: { children: ReactNode }) {
46
+ const [sessionId, setSessionId] = useState<string>(getOrCreateSessionId)
47
+ const [messages, setMessages] = useState<ChatMessage[]>([])
48
+ const [isLoadingHistory, setIsLoadingHistory] = useState(false)
49
+
50
+ const loadHistory = useCallback(async () => {
51
+ setIsLoadingHistory(true)
52
+ try {
53
+ const currentId = localStorage.getItem(SESSION_KEY) ?? sessionId
54
+ const res = await getSessionMessages(currentId)
55
+ const hydrated: ChatMessage[] = res.messages.map((m) => ({
56
+ id: makeMessageId(),
57
+ role: m.role,
58
+ content: m.content,
59
+ sources: m.sources,
60
+ status: 'done',
61
+ createdAt: m.created_at,
62
+ }))
63
+ setMessages(hydrated)
64
+ } catch {
65
+ // Leave messages as-is on failure; UI surfaces errors via toast at call sites.
66
+ } finally {
67
+ setIsLoadingHistory(false)
68
+ }
69
+ }, [sessionId])
70
+
71
+ const appendMessage = useCallback((message: ChatMessage) => {
72
+ setMessages((prev) => [...prev, message])
73
+ }, [])
74
+
75
+ const updateLastMessage = useCallback((updater: (message: ChatMessage) => ChatMessage) => {
76
+ setMessages((prev) => {
77
+ if (prev.length === 0) return prev
78
+ const next = prev.slice()
79
+ const last = next[next.length - 1]
80
+ if (!last) return prev
81
+ next[next.length - 1] = updater(last)
82
+ return next
83
+ })
84
+ }, [])
85
+
86
+ const switchSession = useCallback((newSessionId: string) => {
87
+ localStorage.setItem(SESSION_KEY, newSessionId)
88
+ setSessionId(newSessionId)
89
+ setMessages([])
90
+ }, [])
91
+
92
+ const value = useMemo(
93
+ () => ({
94
+ sessionId,
95
+ messages,
96
+ isLoadingHistory,
97
+ loadHistory,
98
+ appendMessage,
99
+ updateLastMessage,
100
+ switchSession,
101
+ setMessages,
102
+ }),
103
+ [sessionId, messages, isLoadingHistory, loadHistory, appendMessage, updateLastMessage, switchSession],
104
+ )
105
+
106
+ return <SessionContext.Provider value={value}>{children}</SessionContext.Provider>
107
+ }
108
+
109
+ export function useSession(): SessionContextValue {
110
+ const ctx = useContext(SessionContext)
111
+ if (!ctx) {
112
+ throw new Error('useSession must be used within a SessionProvider')
113
+ }
114
+ return ctx
115
+ }
frontend/src/context/ThemeContext.tsx ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'
2
+ import type { ReactNode } from 'react'
3
+
4
+ export type Theme = 'light' | 'dark'
5
+
6
+ interface ThemeContextValue {
7
+ theme: Theme
8
+ toggleTheme: () => void
9
+ }
10
+
11
+ const THEME_KEY = 'studyson:theme'
12
+
13
+ const ThemeContext = createContext<ThemeContextValue | undefined>(undefined)
14
+
15
+ function getInitialTheme(): Theme {
16
+ const stored = localStorage.getItem(THEME_KEY)
17
+ if (stored === 'light' || stored === 'dark') {
18
+ return stored
19
+ }
20
+ if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
21
+ return 'dark'
22
+ }
23
+ return 'light'
24
+ }
25
+
26
+ export function ThemeProvider({ children }: { children: ReactNode }) {
27
+ const [theme, setTheme] = useState<Theme>(getInitialTheme)
28
+
29
+ useEffect(() => {
30
+ document.documentElement.dataset.theme = theme
31
+ localStorage.setItem(THEME_KEY, theme)
32
+ }, [theme])
33
+
34
+ const toggleTheme = useCallback(() => {
35
+ setTheme((prev) => (prev === 'light' ? 'dark' : 'light'))
36
+ }, [])
37
+
38
+ const value = useMemo(() => ({ theme, toggleTheme }), [theme, toggleTheme])
39
+
40
+ return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>
41
+ }
42
+
43
+ export function useTheme(): ThemeContextValue {
44
+ const ctx = useContext(ThemeContext)
45
+ if (!ctx) {
46
+ throw new Error('useTheme must be used within a ThemeProvider')
47
+ }
48
+ return ctx
49
+ }
frontend/src/index.css ADDED
@@ -0,0 +1 @@
 
 
1
+ @import './styles/global.css';
frontend/src/main.tsx ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { StrictMode } from 'react'
2
+ import { createRoot } from 'react-dom/client'
3
+ import './index.css'
4
+ import App from './App.tsx'
5
+ import { ThemeProvider } from './context/ThemeContext.tsx'
6
+ import { SessionProvider } from './context/SessionContext.tsx'
7
+ import { ToastProvider } from './components/shared/Toast.tsx'
8
+
9
+ createRoot(document.getElementById('root')!).render(
10
+ <StrictMode>
11
+ <ThemeProvider>
12
+ <ToastProvider>
13
+ <SessionProvider>
14
+ <App />
15
+ </SessionProvider>
16
+ </ToastProvider>
17
+ </ThemeProvider>
18
+ </StrictMode>,
19
+ )
frontend/src/styles/global.css ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import './variables.css';
2
+
3
+ * {
4
+ margin: 0;
5
+ padding: 0;
6
+ box-sizing: border-box;
7
+ }
8
+
9
+ html,
10
+ body,
11
+ #root {
12
+ height: 100%;
13
+ }
14
+
15
+ body {
16
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
17
+ background: var(--bg-main);
18
+ color: var(--text-primary);
19
+ line-height: 1.6;
20
+ overflow-x: hidden;
21
+ transition: background 0.2s ease, color 0.2s ease;
22
+ }
23
+
24
+ button,
25
+ input,
26
+ textarea {
27
+ font-family: inherit;
28
+ }
29
+
30
+ .app-layout {
31
+ display: flex;
32
+ min-height: 100vh;
33
+ }
34
+
35
+ @keyframes pulse {
36
+ 0%,
37
+ 100% {
38
+ opacity: 1;
39
+ transform: scale(1);
40
+ }
41
+ 50% {
42
+ opacity: 0.5;
43
+ transform: scale(1.1);
44
+ }
45
+ }
46
+
47
+ @keyframes slideIn {
48
+ from {
49
+ opacity: 0;
50
+ transform: translateY(10px);
51
+ }
52
+ to {
53
+ opacity: 1;
54
+ transform: translateY(0);
55
+ }
56
+ }
57
+
58
+ @keyframes spin {
59
+ to {
60
+ transform: rotate(360deg);
61
+ }
62
+ }
63
+
64
+ /* ===== BUTTONS ===== */
65
+ .btn-primary {
66
+ background: var(--gradient-primary);
67
+ color: white;
68
+ border: none;
69
+ border-radius: 12px;
70
+ font-weight: 600;
71
+ cursor: pointer;
72
+ transition: all 0.3s ease;
73
+ box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
74
+ }
75
+
76
+ .btn-primary:hover:not(:disabled) {
77
+ transform: translateY(-2px);
78
+ box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
79
+ }
80
+
81
+ .btn-primary:active:not(:disabled) {
82
+ transform: translateY(0);
83
+ }
84
+
85
+ .btn-primary:disabled {
86
+ opacity: 0.7;
87
+ cursor: not-allowed;
88
+ }
89
+
90
+ .btn-large {
91
+ padding: 1.25rem 2rem;
92
+ font-size: 1.05rem;
93
+ display: flex;
94
+ align-items: center;
95
+ justify-content: center;
96
+ gap: 0.75rem;
97
+ width: 100%;
98
+ }
99
+
100
+ .btn-arrow {
101
+ font-size: 1.5rem;
102
+ transition: transform 0.3s ease;
103
+ }
104
+
105
+ .btn-primary:hover:not(:disabled) .btn-arrow {
106
+ transform: translateX(4px);
107
+ }
108
+
109
+ /* ===== VIEW CONTAINERS ===== */
110
+ .view-container {
111
+ padding: 2.5rem;
112
+ flex: 1;
113
+ }
114
+
115
+ .view-header {
116
+ margin-bottom: 2rem;
117
+ }
118
+
119
+ .view-title {
120
+ font-size: 2rem;
121
+ font-weight: 700;
122
+ color: var(--text-primary);
123
+ margin-bottom: 0.5rem;
124
+ }
125
+
126
+ .view-description {
127
+ font-size: 1.05rem;
128
+ color: var(--text-secondary);
129
+ }
130
+
131
+ .content-card {
132
+ background: var(--bg-card);
133
+ border-radius: 16px;
134
+ padding: 2.5rem;
135
+ box-shadow: var(--shadow-md);
136
+ }
137
+
138
+ /* ===== RESULT MESSAGES ===== */
139
+ .result-message {
140
+ margin-top: 1.5rem;
141
+ padding: 1.25rem 1.5rem;
142
+ border-radius: 12px;
143
+ display: none;
144
+ animation: slideIn 0.3s ease;
145
+ }
146
+
147
+ .result-message.show {
148
+ display: block;
149
+ }
150
+
151
+ .result-message.success {
152
+ background: #f0fff4;
153
+ border: 1px solid #9ae6b4;
154
+ color: #22543d;
155
+ }
156
+
157
+ .result-message.error {
158
+ background: #fff5f5;
159
+ border: 1px solid #feb2b2;
160
+ color: #742a2a;
161
+ }
162
+
163
+ .result-message.info {
164
+ background: #ebf8ff;
165
+ border: 1px solid #90cdf4;
166
+ color: #2c5282;
167
+ }
168
+
169
+ :root[data-theme='dark'] .result-message.success {
170
+ background: rgba(72, 187, 120, 0.12);
171
+ border-color: rgba(72, 187, 120, 0.4);
172
+ color: #9ae6b4;
173
+ }
174
+
175
+ :root[data-theme='dark'] .result-message.error {
176
+ background: rgba(245, 101, 101, 0.12);
177
+ border-color: rgba(245, 101, 101, 0.4);
178
+ color: #feb2b2;
179
+ }
180
+
181
+ :root[data-theme='dark'] .result-message.info {
182
+ background: rgba(102, 126, 234, 0.12);
183
+ border-color: rgba(102, 126, 234, 0.4);
184
+ color: #90cdf4;
185
+ }
186
+
187
+ /* ===== LOADING STATE ===== */
188
+ .loading-spinner {
189
+ display: inline-block;
190
+ width: 18px;
191
+ height: 18px;
192
+ border: 3px solid rgba(255, 255, 255, 0.3);
193
+ border-top-color: white;
194
+ border-radius: 50%;
195
+ animation: spin 0.8s linear infinite;
196
+ }
197
+
198
+ .loading-spinner.dark {
199
+ border: 3px solid rgba(102, 126, 234, 0.2);
200
+ border-top-color: var(--primary);
201
+ }
202
+
203
+ /* ===== SCROLLBAR ===== */
204
+ ::-webkit-scrollbar {
205
+ width: 10px;
206
+ }
207
+
208
+ ::-webkit-scrollbar-track {
209
+ background: var(--bg-main);
210
+ }
211
+
212
+ ::-webkit-scrollbar-thumb {
213
+ background: var(--gradient-primary);
214
+ border-radius: 5px;
215
+ }
216
+
217
+ ::-webkit-scrollbar-thumb:hover {
218
+ background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);
219
+ }
220
+
221
+ /* ===== Markdown ===== */
222
+ .markdown-body {
223
+ line-height: 1.6;
224
+ }
225
+ .markdown-body p {
226
+ margin: 0 0 0.6em 0;
227
+ }
228
+ .markdown-body h1,
229
+ .markdown-body h2,
230
+ .markdown-body h3 {
231
+ margin: 0.8em 0 0.4em;
232
+ font-weight: 600;
233
+ }
234
+ .markdown-body ul,
235
+ .markdown-body ol {
236
+ margin: 0 0 0.6em 1.4em;
237
+ }
238
+ .markdown-body code {
239
+ background: rgba(0, 0, 0, 0.06);
240
+ padding: 0.1em 0.35em;
241
+ border-radius: 4px;
242
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
243
+ font-size: 0.9em;
244
+ }
245
+ .markdown-body pre {
246
+ background: #1e293b;
247
+ color: #e2e8f0;
248
+ padding: 0.9em 1em;
249
+ border-radius: 8px;
250
+ overflow-x: auto;
251
+ margin: 0 0 0.8em;
252
+ }
253
+ .markdown-body pre code {
254
+ background: transparent;
255
+ color: inherit;
256
+ padding: 0;
257
+ }
258
+ .markdown-body blockquote {
259
+ border-left: 3px solid var(--primary);
260
+ padding-left: 0.8em;
261
+ color: var(--text-secondary);
262
+ margin: 0 0 0.6em;
263
+ }
264
+
265
+ :root[data-theme='dark'] .markdown-body code {
266
+ background: rgba(255, 255, 255, 0.08);
267
+ }
268
+
269
+ /* ===== RESPONSIVE ===== */
270
+ @media (max-width: 768px) {
271
+ .view-container {
272
+ padding: 1.5rem;
273
+ }
274
+
275
+ .content-card {
276
+ padding: 1.5rem;
277
+ }
278
+ }
frontend/src/styles/variables.css ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Design tokens ported from the vanilla Studyson app (static/css/style.css),
2
+ extended with a dark palette activated via [data-theme="dark"]. */
3
+
4
+ :root {
5
+ --primary: #667eea;
6
+ --primary-dark: #5568d3;
7
+ --secondary: #764ba2;
8
+ --accent: #f093fb;
9
+ --bg-main: #f7f9fc;
10
+ --bg-card: #ffffff;
11
+ --bg-sidebar: #1a1f36;
12
+ --text-primary: #2d3748;
13
+ --text-secondary: #718096;
14
+ --text-light: #a0aec0;
15
+ --border: #e2e8f0;
16
+ --success: #48bb78;
17
+ --danger: #f56565;
18
+ --warning: #ed8936;
19
+ --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
20
+ --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
21
+ --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
22
+
23
+ --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
24
+ }
25
+
26
+ :root[data-theme='dark'] {
27
+ --primary: #7c8ff0;
28
+ --primary-dark: #667eea;
29
+ --secondary: #8a5cb5;
30
+ --accent: #f2a6fc;
31
+ --bg-main: #12131c;
32
+ --bg-card: #1b1d2b;
33
+ --bg-sidebar: #0e0f18;
34
+ --text-primary: #e6e8f0;
35
+ --text-secondary: #a0a8c0;
36
+ --text-light: #6b7290;
37
+ --border: #2b2e42;
38
+ --success: #48bb78;
39
+ --danger: #f56565;
40
+ --warning: #ed8936;
41
+ --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
42
+ --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
43
+ --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.55);
44
+
45
+ --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
46
+ }
frontend/tsconfig.app.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
+ "target": "es2023",
5
+ "lib": ["ES2023", "DOM"],
6
+ "module": "esnext",
7
+ "types": ["vite/client"],
8
+ "allowArbitraryExtensions": true,
9
+ "skipLibCheck": true,
10
+
11
+ /* Bundler mode */
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "moduleDetection": "force",
16
+ "noEmit": true,
17
+ "jsx": "react-jsx",
18
+
19
+ /* Linting */
20
+ "noUnusedLocals": true,
21
+ "noUnusedParameters": true,
22
+ "erasableSyntaxOnly": true,
23
+ "noFallthroughCasesInSwitch": true
24
+ },
25
+ "include": ["src"]
26
+ }
frontend/tsconfig.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "files": [],
3
+ "references": [
4
+ { "path": "./tsconfig.app.json" },
5
+ { "path": "./tsconfig.node.json" }
6
+ ]
7
+ }
frontend/tsconfig.node.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
+ "target": "es2023",
5
+ "lib": ["ES2023"],
6
+ "types": ["node"],
7
+ "skipLibCheck": true,
8
+
9
+ /* Bundler mode */
10
+ "module": "nodenext",
11
+ "allowImportingTsExtensions": true,
12
+ "verbatimModuleSyntax": true,
13
+ "moduleDetection": "force",
14
+ "noEmit": true,
15
+
16
+ /* Linting */
17
+ "noUnusedLocals": true,
18
+ "noUnusedParameters": true,
19
+ "erasableSyntaxOnly": true,
20
+ "noFallthroughCasesInSwitch": true
21
+ },
22
+ "include": ["vite.config.ts"]
23
+ }
frontend/vite.config.ts ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+
4
+ const PROXY_PATHS = [
5
+ '/upload',
6
+ '/scrape_and_index',
7
+ '/documents',
8
+ '/stream_query',
9
+ '/query',
10
+ '/summarize',
11
+ '/reset',
12
+ '/status',
13
+ '/sessions',
14
+ ]
15
+
16
+ // https://vite.dev/config/
17
+ export default defineConfig({
18
+ plugins: [react()],
19
+ server: {
20
+ proxy: Object.fromEntries(
21
+ PROXY_PATHS.map((path) => [
22
+ path,
23
+ {
24
+ target: 'http://localhost:7860',
25
+ changeOrigin: true,
26
+ },
27
+ ]),
28
+ ),
29
+ },
30
+ build: {
31
+ outDir: 'dist',
32
+ emptyOutDir: true,
33
+ },
34
+ })
requirements-dev.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ -r requirements.txt
2
+ pytest>=8.3.0
requirements.txt CHANGED
@@ -3,7 +3,7 @@ uvicorn[standard]>=0.34.0
3
  python-multipart>=0.0.18
4
  llama-index>=0.14.0
5
  llama-index-llms-groq>=0.4.0
6
- llama-index-embeddings-fastembed>=0.4.0
7
  llama-index-vector-stores-chroma>=0.5.0
8
  chromadb>=0.6.0
9
  pypdf>=5.4.0
@@ -14,4 +14,3 @@ beautifulsoup4>=4.12.3
14
  httpx>=0.28.0
15
  pydantic>=2.10.0
16
  pydantic-settings>=2.7.0
17
- fastembed>=0.5.0
 
3
  python-multipart>=0.0.18
4
  llama-index>=0.14.0
5
  llama-index-llms-groq>=0.4.0
6
+ llama-index-embeddings-huggingface>=0.5.0
7
  llama-index-vector-stores-chroma>=0.5.0
8
  chromadb>=0.6.0
9
  pypdf>=5.4.0
 
14
  httpx>=0.28.0
15
  pydantic>=2.10.0
16
  pydantic-settings>=2.7.0
 
static/css/style.css DELETED
@@ -1,807 +0,0 @@
1
- * {
2
- margin: 0;
3
- padding: 0;
4
- box-sizing: border-box;
5
- }
6
-
7
- :root {
8
- --primary: #667eea;
9
- --primary-dark: #5568d3;
10
- --secondary: #764ba2;
11
- --accent: #f093fb;
12
- --bg-main: #f7f9fc;
13
- --bg-card: #ffffff;
14
- --bg-sidebar: #1a1f36;
15
- --text-primary: #2d3748;
16
- --text-secondary: #718096;
17
- --text-light: #a0aec0;
18
- --border: #e2e8f0;
19
- --success: #48bb78;
20
- --danger: #f56565;
21
- --warning: #ed8936;
22
- --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
23
- --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
24
- --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
25
- }
26
-
27
- body {
28
- font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
29
- background: var(--bg-main);
30
- color: var(--text-primary);
31
- line-height: 1.6;
32
- overflow-x: hidden;
33
- }
34
-
35
- .app-layout {
36
- display: flex;
37
- min-height: 100vh;
38
- }
39
-
40
- /* ===== SIDEBAR ===== */
41
- .sidebar {
42
- width: 280px;
43
- background: var(--bg-sidebar);
44
- color: white;
45
- display: flex;
46
- flex-direction: column;
47
- position: fixed;
48
- height: 100vh;
49
- left: 0;
50
- top: 0;
51
- z-index: 100;
52
- box-shadow: var(--shadow-lg);
53
- }
54
-
55
- .logo-section {
56
- padding: 2rem 1.5rem;
57
- display: flex;
58
- align-items: center;
59
- gap: 1rem;
60
- border-bottom: 1px solid rgba(255, 255, 255, 0.1);
61
- }
62
-
63
- .logo-icon {
64
- flex-shrink: 0;
65
- }
66
-
67
- .logo-text {
68
- font-size: 1.5rem;
69
- font-weight: 700;
70
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
71
- -webkit-background-clip: text;
72
- -webkit-text-fill-color: transparent;
73
- background-clip: text;
74
- }
75
-
76
- .nav-menu {
77
- flex: 1;
78
- padding: 1.5rem 1rem;
79
- display: flex;
80
- flex-direction: column;
81
- gap: 0.5rem;
82
- }
83
-
84
- .nav-item {
85
- display: flex;
86
- align-items: center;
87
- gap: 1rem;
88
- padding: 1rem 1.25rem;
89
- background: transparent;
90
- border: none;
91
- border-radius: 12px;
92
- color: rgba(255, 255, 255, 0.7);
93
- cursor: pointer;
94
- transition: all 0.3s ease;
95
- font-size: 0.95rem;
96
- font-weight: 500;
97
- width: 100%;
98
- text-align: left;
99
- }
100
-
101
- .nav-item:hover {
102
- background: rgba(255, 255, 255, 0.08);
103
- color: white;
104
- transform: translateX(4px);
105
- }
106
-
107
- .nav-item.active {
108
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
109
- color: white;
110
- box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
111
- }
112
-
113
- .nav-icon {
114
- font-size: 1.5rem;
115
- }
116
-
117
- .sidebar-footer {
118
- padding: 1.5rem 1rem;
119
- border-top: 1px solid rgba(255, 255, 255, 0.1);
120
- }
121
-
122
- .stats-card {
123
- background: rgba(255, 255, 255, 0.05);
124
- padding: 1rem;
125
- border-radius: 12px;
126
- margin-bottom: 1rem;
127
- }
128
-
129
- .stat-item {
130
- display: flex;
131
- justify-content: space-between;
132
- align-items: center;
133
- margin-bottom: 0.75rem;
134
- }
135
-
136
- .stat-label {
137
- font-size: 0.85rem;
138
- color: rgba(255, 255, 255, 0.6);
139
- }
140
-
141
- .stat-value {
142
- font-size: 1.5rem;
143
- font-weight: 700;
144
- color: var(--accent);
145
- }
146
-
147
- .stat-indicator {
148
- display: flex;
149
- align-items: center;
150
- gap: 0.5rem;
151
- font-size: 0.85rem;
152
- color: rgba(255, 255, 255, 0.7);
153
- }
154
-
155
- .pulse-dot {
156
- width: 8px;
157
- height: 8px;
158
- background: var(--success);
159
- border-radius: 50%;
160
- animation: pulse 2s infinite;
161
- }
162
-
163
- @keyframes pulse {
164
- 0%, 100% { opacity: 1; transform: scale(1); }
165
- 50% { opacity: 0.5; transform: scale(1.1); }
166
- }
167
-
168
- .btn-reset {
169
- width: 100%;
170
- padding: 0.875rem 1rem;
171
- background: rgba(245, 101, 101, 0.1);
172
- border: 1px solid rgba(245, 101, 101, 0.3);
173
- border-radius: 10px;
174
- color: #fc8181;
175
- font-weight: 500;
176
- cursor: pointer;
177
- transition: all 0.3s ease;
178
- display: flex;
179
- align-items: center;
180
- justify-content: center;
181
- gap: 0.5rem;
182
- }
183
-
184
- .btn-reset:hover {
185
- background: rgba(245, 101, 101, 0.2);
186
- border-color: rgba(245, 101, 101, 0.5);
187
- }
188
-
189
- /* ===== MAIN CONTENT ===== */
190
- .main-content {
191
- margin-left: 280px;
192
- flex: 1;
193
- min-height: 100vh;
194
- display: flex;
195
- flex-direction: column;
196
- }
197
-
198
- .topbar {
199
- background: white;
200
- padding: 1.5rem 2.5rem;
201
- display: flex;
202
- justify-content: space-between;
203
- align-items: center;
204
- box-shadow: var(--shadow-sm);
205
- position: sticky;
206
- top: 0;
207
- z-index: 50;
208
- }
209
-
210
- .breadcrumb-item {
211
- font-size: 1.25rem;
212
- font-weight: 600;
213
- color: var(--text-primary);
214
- }
215
-
216
- .status-badge {
217
- display: flex;
218
- align-items: center;
219
- gap: 0.5rem;
220
- padding: 0.5rem 1rem;
221
- background: var(--bg-main);
222
- border-radius: 20px;
223
- font-size: 0.875rem;
224
- font-weight: 500;
225
- }
226
-
227
- .status-dot {
228
- width: 8px;
229
- height: 8px;
230
- background: var(--success);
231
- border-radius: 50%;
232
- animation: pulse 2s infinite;
233
- }
234
-
235
- /* ===== VIEW CONTAINERS ===== */
236
- .view-container {
237
- display: none;
238
- padding: 2.5rem;
239
- flex: 1;
240
- }
241
-
242
- .view-container.active {
243
- display: block;
244
- }
245
-
246
- .view-header {
247
- margin-bottom: 2rem;
248
- }
249
-
250
- .view-title {
251
- font-size: 2rem;
252
- font-weight: 700;
253
- color: var(--text-primary);
254
- margin-bottom: 0.5rem;
255
- }
256
-
257
- .view-description {
258
- font-size: 1.05rem;
259
- color: var(--text-secondary);
260
- }
261
-
262
- .content-card {
263
- background: var(--bg-card);
264
- border-radius: 16px;
265
- padding: 2.5rem;
266
- box-shadow: var(--shadow-md);
267
- }
268
-
269
- /* ===== UPLOAD AREA ===== */
270
- .upload-area {
271
- display: flex;
272
- flex-direction: column;
273
- gap: 1.5rem;
274
- }
275
-
276
- .drop-zone {
277
- border: 3px dashed var(--border);
278
- border-radius: 16px;
279
- padding: 3rem 2rem;
280
- text-align: center;
281
- cursor: pointer;
282
- transition: all 0.3s ease;
283
- background: var(--bg-main);
284
- }
285
-
286
- .drop-zone:hover {
287
- border-color: var(--primary);
288
- background: #f7faff;
289
- }
290
-
291
- .drop-zone-icon {
292
- font-size: 4rem;
293
- margin-bottom: 1rem;
294
- }
295
-
296
- .drop-zone-title {
297
- font-size: 1.35rem;
298
- font-weight: 600;
299
- color: var(--text-primary);
300
- margin-bottom: 0.5rem;
301
- }
302
-
303
- .drop-zone-desc {
304
- color: var(--text-secondary);
305
- font-size: 1rem;
306
- }
307
-
308
- .file-info {
309
- margin-top: 1.5rem;
310
- padding: 1.25rem;
311
- background: white;
312
- border-radius: 12px;
313
- display: flex;
314
- align-items: center;
315
- gap: 1rem;
316
- box-shadow: var(--shadow-sm);
317
- }
318
-
319
- .file-icon {
320
- font-size: 2rem;
321
- }
322
-
323
- .file-name-display {
324
- flex: 1;
325
- font-weight: 600;
326
- color: var(--text-primary);
327
- }
328
-
329
- .file-size {
330
- color: var(--text-secondary);
331
- font-size: 0.875rem;
332
- }
333
-
334
- /* ===== BUTTONS ===== */
335
- .btn-primary {
336
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
337
- color: white;
338
- border: none;
339
- border-radius: 12px;
340
- font-weight: 600;
341
- cursor: pointer;
342
- transition: all 0.3s ease;
343
- box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
344
- }
345
-
346
- .btn-primary:hover {
347
- transform: translateY(-2px);
348
- box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
349
- }
350
-
351
- .btn-primary:active {
352
- transform: translateY(0);
353
- }
354
-
355
- .btn-large {
356
- padding: 1.25rem 2rem;
357
- font-size: 1.05rem;
358
- display: flex;
359
- align-items: center;
360
- justify-content: center;
361
- gap: 0.75rem;
362
- }
363
-
364
- .btn-arrow {
365
- font-size: 1.5rem;
366
- transition: transform 0.3s ease;
367
- }
368
-
369
- .btn-primary:hover .btn-arrow {
370
- transform: translateX(4px);
371
- }
372
-
373
- /* ===== WEB FORM ===== */
374
- .web-form {
375
- display: flex;
376
- flex-direction: column;
377
- gap: 1.5rem;
378
- }
379
-
380
- .input-group {
381
- position: relative;
382
- }
383
-
384
- .input-icon {
385
- position: absolute;
386
- left: 1.25rem;
387
- top: 50%;
388
- transform: translateY(-50%);
389
- font-size: 1.5rem;
390
- }
391
-
392
- .input-field {
393
- width: 100%;
394
- padding: 1.25rem 1.25rem 1.25rem 3.5rem;
395
- border: 2px solid var(--border);
396
- border-radius: 12px;
397
- font-size: 1rem;
398
- transition: all 0.3s ease;
399
- font-family: inherit;
400
- }
401
-
402
- .input-field:focus {
403
- outline: none;
404
- border-color: var(--primary);
405
- box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
406
- }
407
-
408
- /* ===== CHAT CONTAINER ===== */
409
- .chat-container {
410
- background: var(--bg-card);
411
- border-radius: 16px;
412
- box-shadow: var(--shadow-md);
413
- display: flex;
414
- flex-direction: column;
415
- height: 600px;
416
- }
417
-
418
- .messages-area {
419
- flex: 1;
420
- overflow-y: auto;
421
- padding: 2rem;
422
- }
423
-
424
- .empty-state {
425
- height: 100%;
426
- display: flex;
427
- flex-direction: column;
428
- align-items: center;
429
- justify-content: center;
430
- color: var(--text-secondary);
431
- text-align: center;
432
- }
433
-
434
- .empty-icon {
435
- font-size: 4rem;
436
- margin-bottom: 1rem;
437
- opacity: 0.5;
438
- }
439
-
440
- .empty-state h3 {
441
- font-size: 1.5rem;
442
- margin-bottom: 0.5rem;
443
- color: var(--text-primary);
444
- }
445
-
446
- .message {
447
- margin-bottom: 1.5rem;
448
- display: flex;
449
- gap: 1rem;
450
- animation: slideIn 0.3s ease;
451
- }
452
-
453
- @keyframes slideIn {
454
- from {
455
- opacity: 0;
456
- transform: translateY(10px);
457
- }
458
- to {
459
- opacity: 1;
460
- transform: translateY(0);
461
- }
462
- }
463
-
464
- .message-bubble {
465
- max-width: 70%;
466
- padding: 1.25rem 1.5rem;
467
- border-radius: 16px;
468
- line-height: 1.6;
469
- }
470
-
471
- .message.user .message-bubble {
472
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
473
- color: white;
474
- margin-left: auto;
475
- border-bottom-right-radius: 4px;
476
- }
477
-
478
- .message.assistant .message-bubble {
479
- background: var(--bg-main);
480
- color: var(--text-primary);
481
- border-bottom-left-radius: 4px;
482
- }
483
-
484
- .message-sources {
485
- margin-top: 1rem;
486
- padding-top: 1rem;
487
- border-top: 1px solid rgba(255, 255, 255, 0.2);
488
- font-size: 0.875rem;
489
- }
490
-
491
- .source-item {
492
- margin-top: 0.75rem;
493
- padding: 0.75rem;
494
- background: rgba(255, 255, 255, 0.1);
495
- border-radius: 8px;
496
- font-size: 0.85rem;
497
- }
498
-
499
- .source-item strong {
500
- display: block;
501
- margin-bottom: 0.25rem;
502
- }
503
-
504
- .chat-input-area {
505
- padding: 1.5rem;
506
- border-top: 1px solid var(--border);
507
- }
508
-
509
- .chat-input-wrapper {
510
- display: flex;
511
- gap: 1rem;
512
- align-items: center;
513
- }
514
-
515
- .chat-input {
516
- flex: 1;
517
- padding: 1rem 1.5rem;
518
- border: 2px solid var(--border);
519
- border-radius: 12px;
520
- font-size: 1rem;
521
- font-family: inherit;
522
- transition: all 0.3s ease;
523
- }
524
-
525
- .chat-input:focus {
526
- outline: none;
527
- border-color: var(--primary);
528
- box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
529
- }
530
-
531
- .btn-send {
532
- width: 50px;
533
- height: 50px;
534
- border-radius: 12px;
535
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
536
- border: none;
537
- color: white;
538
- cursor: pointer;
539
- display: flex;
540
- align-items: center;
541
- justify-content: center;
542
- transition: all 0.3s ease;
543
- flex-shrink: 0;
544
- }
545
-
546
- .btn-send:hover {
547
- transform: scale(1.05);
548
- box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
549
- }
550
-
551
- /* ===== SUMMARY FORM ===== */
552
- .summary-form {
553
- display: flex;
554
- flex-direction: column;
555
- gap: 2rem;
556
- }
557
-
558
- .form-group {
559
- display: flex;
560
- flex-direction: column;
561
- gap: 1rem;
562
- }
563
-
564
- .form-label {
565
- font-size: 1.05rem;
566
- font-weight: 600;
567
- color: var(--text-primary);
568
- }
569
-
570
- .slider-container {
571
- display: flex;
572
- align-items: center;
573
- gap: 1.5rem;
574
- }
575
-
576
- .range-slider {
577
- flex: 1;
578
- height: 8px;
579
- border-radius: 4px;
580
- background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
581
- outline: none;
582
- -webkit-appearance: none;
583
- }
584
-
585
- .range-slider::-webkit-slider-thumb {
586
- -webkit-appearance: none;
587
- width: 24px;
588
- height: 24px;
589
- border-radius: 50%;
590
- background: white;
591
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
592
- cursor: pointer;
593
- }
594
-
595
- .range-slider::-moz-range-thumb {
596
- width: 24px;
597
- height: 24px;
598
- border-radius: 50%;
599
- background: white;
600
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
601
- cursor: pointer;
602
- border: none;
603
- }
604
-
605
- .slider-value {
606
- min-width: 100px;
607
- padding: 0.75rem 1.25rem;
608
- background: var(--bg-main);
609
- border-radius: 8px;
610
- font-weight: 600;
611
- text-align: center;
612
- color: var(--primary);
613
- }
614
-
615
- /* ===== RESULT MESSAGES ===== */
616
- .result-message {
617
- margin-top: 1.5rem;
618
- padding: 1.25rem 1.5rem;
619
- border-radius: 12px;
620
- display: none;
621
- animation: slideIn 0.3s ease;
622
- }
623
-
624
- .result-message.show {
625
- display: block;
626
- }
627
-
628
- .result-message.success {
629
- background: #f0fff4;
630
- border: 1px solid #9ae6b4;
631
- color: #22543d;
632
- }
633
-
634
- .result-message.error {
635
- background: #fff5f5;
636
- border: 1px solid #feb2b2;
637
- color: #742a2a;
638
- }
639
-
640
- .result-message.info {
641
- background: #ebf8ff;
642
- border: 1px solid #90cdf4;
643
- color: #2c5282;
644
- }
645
-
646
- .summary-output h3 {
647
- font-size: 1.25rem;
648
- margin-bottom: 1rem;
649
- color: var(--text-primary);
650
- }
651
-
652
- .summary-output p {
653
- line-height: 1.8;
654
- margin-bottom: 1rem;
655
- }
656
-
657
- /* ===== RESPONSIVE ===== */
658
- @media (max-width: 1024px) {
659
- .sidebar {
660
- width: 240px;
661
- }
662
-
663
- .main-content {
664
- margin-left: 240px;
665
- }
666
- }
667
-
668
- @media (max-width: 768px) {
669
- .sidebar {
670
- transform: translateX(-100%);
671
- transition: transform 0.3s ease;
672
- }
673
-
674
- .sidebar.mobile-open {
675
- transform: translateX(0);
676
- }
677
-
678
- .main-content {
679
- margin-left: 0;
680
- }
681
-
682
- .topbar {
683
- padding: 1rem 1.5rem;
684
- }
685
-
686
- .view-container {
687
- padding: 1.5rem;
688
- }
689
-
690
- .content-card {
691
- padding: 1.5rem;
692
- }
693
-
694
- .message-bubble {
695
- max-width: 85%;
696
- }
697
- }
698
-
699
- /* ===== LOADING STATE ===== */
700
- .loading {
701
- display: inline-block;
702
- width: 18px;
703
- height: 18px;
704
- border: 3px solid rgba(255, 255, 255, 0.3);
705
- border-top-color: white;
706
- border-radius: 50%;
707
- animation: spin 0.8s linear infinite;
708
- }
709
-
710
- @keyframes spin {
711
- to { transform: rotate(360deg); }
712
- }
713
-
714
- /* ===== SCROLLBAR ===== */
715
- ::-webkit-scrollbar {
716
- width: 10px;
717
- }
718
-
719
- ::-webkit-scrollbar-track {
720
- background: var(--bg-main);
721
- }
722
-
723
- ::-webkit-scrollbar-thumb {
724
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
725
- border-radius: 5px;
726
- }
727
-
728
- ::-webkit-scrollbar-thumb:hover {
729
- background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);
730
- }
731
-
732
- /* ===== Toasts ===== */
733
- .toast-container {
734
- position: fixed;
735
- top: 1rem;
736
- right: 1rem;
737
- display: flex;
738
- flex-direction: column;
739
- gap: 0.5rem;
740
- z-index: 9999;
741
- pointer-events: none;
742
- }
743
- .toast {
744
- pointer-events: auto;
745
- min-width: 240px;
746
- max-width: 360px;
747
- padding: 0.75rem 1rem;
748
- border-radius: 10px;
749
- color: white;
750
- font-size: 0.9rem;
751
- box-shadow: var(--shadow-md);
752
- opacity: 0;
753
- transform: translateX(20px);
754
- transition: opacity 0.25s ease, transform 0.25s ease;
755
- }
756
- .toast.show { opacity: 1; transform: translateX(0); }
757
- .toast-success { background: var(--success); }
758
- .toast-error { background: var(--danger); }
759
- .toast-info { background: var(--primary); }
760
-
761
- /* ===== Drag highlight ===== */
762
- .drop-zone.dragging {
763
- border-color: var(--primary);
764
- background: rgba(102, 126, 234, 0.06);
765
- }
766
-
767
- /* ===== Markdown ===== */
768
- .markdown-body { line-height: 1.6; }
769
- .markdown-body p { margin: 0 0 0.6em 0; }
770
- .markdown-body h1, .markdown-body h2, .markdown-body h3 {
771
- margin: 0.8em 0 0.4em;
772
- font-weight: 600;
773
- }
774
- .markdown-body ul, .markdown-body ol { margin: 0 0 0.6em 1.4em; }
775
- .markdown-body code {
776
- background: rgba(0,0,0,0.06);
777
- padding: 0.1em 0.35em;
778
- border-radius: 4px;
779
- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
780
- font-size: 0.9em;
781
- }
782
- .markdown-body pre {
783
- background: #1e293b;
784
- color: #e2e8f0;
785
- padding: 0.9em 1em;
786
- border-radius: 8px;
787
- overflow-x: auto;
788
- margin: 0 0 0.8em;
789
- }
790
- .markdown-body pre code {
791
- background: transparent;
792
- color: inherit;
793
- padding: 0;
794
- }
795
- .markdown-body blockquote {
796
- border-left: 3px solid var(--primary);
797
- padding-left: 0.8em;
798
- color: var(--text-secondary);
799
- margin: 0 0 0.6em;
800
- }
801
- .summary-sources {
802
- margin-top: 1rem;
803
- padding-top: 1rem;
804
- border-top: 1px solid var(--border);
805
- font-size: 0.9rem;
806
- color: var(--text-secondary);
807
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
static/index.html DELETED
@@ -1,194 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Studyson - Smart Document Assistant</title>
7
- <link rel="stylesheet" href="/static/css/style.css">
8
- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
9
- <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js" defer></script>
10
- <script src="https://cdn.jsdelivr.net/npm/dompurify@3.2.4/dist/purify.min.js" defer></script>
11
- </head>
12
- <body>
13
- <div class="app-layout">
14
- <!-- Sidebar Navigation -->
15
- <aside class="sidebar">
16
- <div class="logo-section">
17
- <div class="logo-icon">
18
- <svg width="40" height="40" viewBox="0 0 40 40" fill="none">
19
- <rect width="40" height="40" rx="12" fill="url(#grad1)"/>
20
- <path d="M12 14h16M12 20h16M12 26h10" stroke="white" stroke-width="2.5" stroke-linecap="round"/>
21
- <defs>
22
- <linearGradient id="grad1" x1="0" y1="0" x2="40" y2="40">
23
- <stop offset="0%" stop-color="#667eea"/>
24
- <stop offset="100%" stop-color="#764ba2"/>
25
- </linearGradient>
26
- </defs>
27
- </svg>
28
- </div>
29
- <h1 class="logo-text">Studyson</h1>
30
- </div>
31
-
32
- <nav class="nav-menu">
33
- <button class="nav-item active" data-view="upload">
34
- <span class="nav-icon">📁</span>
35
- <span class="nav-label">Upload Files</span>
36
- </button>
37
- <button class="nav-item" data-view="web">
38
- <span class="nav-icon">🌍</span>
39
- <span class="nav-label">Web Import</span>
40
- </button>
41
- <button class="nav-item" data-view="chat">
42
- <span class="nav-icon">💭</span>
43
- <span class="nav-label">Q&A Chat</span>
44
- </button>
45
- <button class="nav-item" data-view="summary">
46
- <span class="nav-icon">📊</span>
47
- <span class="nav-label">Summarize</span>
48
- </button>
49
- </nav>
50
-
51
- <div class="sidebar-footer">
52
- <div class="stats-card">
53
- <div class="stat-item">
54
- <span class="stat-label">Documents</span>
55
- <span class="stat-value" id="doc-count-sidebar">0</span>
56
- </div>
57
- <div class="stat-indicator">
58
- <div class="pulse-dot" id="status-pulse"></div>
59
- <span id="status-text-sidebar">Ready</span>
60
- </div>
61
- </div>
62
- <button id="reset-btn-sidebar" class="btn-reset">
63
- <span>🗑️</span>
64
- <span>Clear All</span>
65
- </button>
66
- </div>
67
- </aside>
68
-
69
- <!-- Main Content Area -->
70
- <main class="main-content">
71
- <div class="topbar">
72
- <div class="breadcrumb">
73
- <span class="breadcrumb-item" id="current-view-name">Upload Files</span>
74
- </div>
75
- <div class="topbar-actions">
76
- <div class="status-badge" id="status-badge">
77
- <span class="status-dot"></span>
78
- <span id="status-text-top">System Ready</span>
79
- </div>
80
- </div>
81
- </div>
82
-
83
- <!-- Upload View -->
84
- <div class="view-container active" id="view-upload">
85
- <div class="view-header">
86
- <h2 class="view-title">Upload Documents</h2>
87
- <p class="view-description">Import PDF, DOCX, TXT, or Markdown files to build a searchable knowledge base</p>
88
- </div>
89
-
90
- <div class="content-card">
91
- <form id="upload-form" class="upload-area">
92
- <input type="file" id="file-input" accept=".pdf,.docx,.txt,.md" hidden>
93
- <label for="file-input" class="drop-zone">
94
- <div class="drop-zone-icon">📄</div>
95
- <h3 class="drop-zone-title" id="drop-zone-title">Drop your file here</h3>
96
- <p class="drop-zone-desc">PDF, DOCX, TXT, or Markdown — click to browse</p>
97
- <div class="file-info" id="file-info" style="display: none;">
98
- <span class="file-icon">📎</span>
99
- <span class="file-name-display" id="file-name-display"></span>
100
- <span class="file-size" id="file-size-display"></span>
101
- </div>
102
- </label>
103
- <button type="submit" class="btn-primary btn-large">
104
- <span>Upload & Index Document</span>
105
- <span class="btn-arrow">→</span>
106
- </button>
107
- </form>
108
- <div id="upload-result" class="result-message"></div>
109
- </div>
110
- </div>
111
-
112
- <!-- Web Scrape View -->
113
- <div class="view-container" id="view-web">
114
- <div class="view-header">
115
- <h2 class="view-title">Import from Web</h2>
116
- <p class="view-description">Extract and index content from any webpage</p>
117
- </div>
118
-
119
- <div class="content-card">
120
- <form id="scrape-form" class="web-form">
121
- <div class="input-group">
122
- <span class="input-icon">🔗</span>
123
- <input type="url" id="url-input" class="input-field" placeholder="https://example.com/article" required>
124
- </div>
125
- <button type="submit" class="btn-primary btn-large">
126
- <span>Fetch & Index Content</span>
127
- <span class="btn-arrow">→</span>
128
- </button>
129
- </form>
130
- <div id="scrape-result" class="result-message"></div>
131
- </div>
132
- </div>
133
-
134
- <!-- Chat View -->
135
- <div class="view-container" id="view-chat">
136
- <div class="view-header">
137
- <h2 class="view-title">Interactive Q&A</h2>
138
- <p class="view-description">Ask questions and get intelligent answers from your documents</p>
139
- </div>
140
-
141
- <div class="chat-container">
142
- <div class="messages-area" id="chat-messages">
143
- <div class="empty-state">
144
- <div class="empty-icon">💬</div>
145
- <h3>Start a Conversation</h3>
146
- <p>Ask me anything about your indexed documents</p>
147
- </div>
148
- </div>
149
- <form id="chat-form" class="chat-input-area">
150
- <div class="chat-input-wrapper">
151
- <input type="text" id="question-input" class="chat-input" placeholder="Type your question here..." required>
152
- <button type="submit" class="btn-send">
153
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none">
154
- <path d="M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
155
- </svg>
156
- </button>
157
- </div>
158
- </form>
159
- </div>
160
- </div>
161
-
162
- <!-- Summary View -->
163
- <div class="view-container" id="view-summary">
164
- <div class="view-header">
165
- <h2 class="view-title">Document Summarization</h2>
166
- <p class="view-description">Generate comprehensive summaries of your indexed content</p>
167
- </div>
168
-
169
- <div class="content-card">
170
- <form id="summarize-form" class="summary-form">
171
- <div class="form-group">
172
- <label class="form-label">Summary Length</label>
173
- <div class="slider-container">
174
- <input type="range" id="max-length" class="range-slider" min="100" max="2000" step="100" value="500">
175
- <div class="slider-value">
176
- <span id="length-display">500</span> words
177
- </div>
178
- </div>
179
- </div>
180
- <button type="submit" class="btn-primary btn-large">
181
- <span>Generate Summary</span>
182
- <span class="btn-arrow">✨</span>
183
- </button>
184
- </form>
185
- <div id="summary-result" class="result-message summary-output"></div>
186
- </div>
187
- </div>
188
- </main>
189
- </div>
190
-
191
- <div id="toast-container" class="toast-container" aria-live="polite"></div>
192
- <script src="/static/js/app.js"></script>
193
- </body>
194
- </html>