Scholar Sense
+Sentiment analysis for research papers
+
+## Features
-## Read our wiki
-- [Design](https://git.ecdf.ed.ac.uk/psd2425/Rose-Campbell/sentiment-analysis/-/wikis/Design)
-- [Planning](https://git.ecdf.ed.ac.uk/psd2425/Rose-Campbell/sentiment-analysis/-/wikis/Planning)
-- [Implementation](https://git.ecdf.ed.ac.uk/psd2425/Rose-Campbell/sentiment-analysis/-/wikis/Implementation)
+- **PDF Upload**: Upload academic research papers in PDF format
+- **Sentiment Analysis**: Analyze paper sentiment towards specific keywords
+- **Citation Support**: Extract and display citations with page references
+- **Interactive Chat**: Query-based interface for analysis
+- **Modern UI**: Next.js with Tailwind CSS
-## System Architecture
-The project is built as a monorepo using Turborepo to manage multiple services:
+## Tech Stack
-1. **Frontend**: Next.js application that provides the user interface
-2. **Backend**: Flask-based API service that performs the sentiment analysis
+### Backend
+- **FastAPI**: High-performance Python web framework
+- **LangChain**: RAG pipeline orchestration
+- **ChromaDB**: Vector database for embeddings
+- **Google Gemini**: LLM for analysis
+- **PyMuPDF & pdfplumber**: PDF processing
-### Architecture Diagram
-```
-┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
-│ │ │ │ │ │
-│ Frontend │ ──────► │ Backend │ ──────► │ GROBID Service │
-│ (Next.js) │ │ (Flask) │ │ (PDF Parser) │
-│ │ │ │ │ │
-└─────────────────┘ └─────────────────┘ └─────────────────┘
-
-```
-
-## Key Features
-- Upload and analyze PDF documents
-- Perform topic-focused sentiment analysis
-- Extract relevant sentences and keywords
-- Visual representation of sentiment results
-
-## Getting Started
-
-### Prerequisites
-- Node.js 18.0+
-- Python 3.8+
-- Docker (for GROBID service)
+### Frontend
+- **Next.js 14**: React framework with App Router
+- **Tailwind CSS**: Utility-first styling
+- **TypeScript**: Type-safe development
+- **Axios**: HTTP client
-### Setup Steps
+## Project Structure
-1. **Clone the repository**
-```bash
-git clone https://git.ecdf.ed.ac.uk/psd2425/Rose-Campbell/sentiment-analysis.git
-cd sentiment-analysis
```
-
-2. **Start the GROBID service** (required for PDF processing)
-```bash
-cd apps/backend/grobid_deployment && chmod +x deploy-grobid.sh
-./deploy-grobid.sh
+windows-build/
+├── backend/
+│ ├── main.py # FastAPI application
+│ ├── config.py # Configuration settings
+│ ├── requirements.txt # Python dependencies
+│ ├── .env # Environment variables
+│ ├── routers/
+│ │ ├── upload.py # PDF upload endpoints
+│ │ └── chat.py # Chat/analysis endpoints
+│ ├── services/
+│ │ ├── pdf_processor.py # PDF extraction and chunking
+│ │ └── rag_service.py # RAG pipeline and LLM
+│ ├── uploads/ # Uploaded PDFs (auto-created)
+│ └── chroma_db/ # Vector database (auto-created)
+│
+└── frontend/
+ ├── app/
+ │ ├── layout.tsx # Root layout
+ │ ├── page.tsx # Main page with tabs
+ │ └── globals.css # Global styles
+ ├── components/
+ │ ├── UploadTab.tsx # Upload interface
+ │ └── ChatTab.tsx # Chat interface
+ ├── package.json
+ ├── tsconfig.json
+ ├── tailwind.config.js
+ └── next.config.js
```
-3. **Set up the backend**
-```bash
-cd apps/backend && chmod +x start_conda.sh
-./start_conda.sh
-```
+## Setup Instructions
-4. **Set up the frontend**
-```bash
-cd apps/frontend
-npm install
-npm run dev
-```
+### Prerequisites
+- Python 3.9+
+- Node.js 18+
+- Google API Key (for Gemini)
-5. **Access the application**
-- Frontend: http://localhost:3000
-- Backend API: http://localhost:5000
-- GROBID Service: http://localhost:8070
+### Backend Setup
-## Directory Structure
-```
-sentiment-analysis/
-├── apps/
-│ ├── frontend/ # Next.js frontend application
-│ └── backend/ # Flask backend service
-├── packages/ # Shared packages and utilities
-├── README.md # This file
-└── package.json # Root package.json for Turborepo
+1. Navigate to backend directory:
+```powershell
+cd backend
```
-## Detailed Documentation
-For more detailed information about each component:
+2. Create a virtual environment:
+```powershell
+python -m venv venv
+.\venv\Scripts\Activate
+```
-- [Frontend Documentation](apps/frontend/README.md)
-- [Backend Documentation](apps/backend/README.md)
\ No newline at end of file
+3. Install dependencies:
+```powershell
+pip install -r requirements.txt
+```
\ No newline at end of file
diff --git a/apps/backend/.dockerignore b/apps/backend/.dockerignore
new file mode 100644
index 0000000..d0a36be
--- /dev/null
+++ b/apps/backend/.dockerignore
@@ -0,0 +1,18 @@
+venv/
+__pycache__/
+*.pyc
+*.pyo
+*.pyd
+.Python
+.env
+.git
+.gitignore
+*.md
+.pytest_cache/
+.coverage
+htmlcov/
+.mypy_cache/
+uploads/*
+chroma_db/*
+!uploads/.gitkeep
+!chroma_db/.gitkeep
diff --git a/apps/backend/.gitignore b/apps/backend/.gitignore
old mode 100644
new mode 100755
index 4ccfbfa..eede5b7
--- a/apps/backend/.gitignore
+++ b/apps/backend/.gitignore
@@ -1,5 +1,6 @@
-.env.example
-/uploads
-/testing
-/__pycache__
-/logs
\ No newline at end of file
+uploads/
+chroma_db/
+__pycache__/
+*.pyc
+venv/
+.env
diff --git a/apps/backend/API_DOCS.md b/apps/backend/API_DOCS.md
deleted file mode 100644
index 624b14b..0000000
--- a/apps/backend/API_DOCS.md
+++ /dev/null
@@ -1,536 +0,0 @@
-# ScholarSense API Documentation
-
-## Overview
-ScholarSense provides a RESTful API for academic paper analysis using Retrieval-Augmented Generation (RAG). Upload PDF papers, query them with natural language questions, and receive citation-grounded answers.
-
-## Base URL
-```
-http://localhost:5000
-```
-
-## Authentication
-Currently no authentication required (add for production).
-
----
-
-## Endpoints
-
-### 1. System Status
-
-#### GET `/status`
-Check system health and RAG statistics.
-
-**Response:**
-```json
-{
- "status": "ok",
- "timestamp": "2025-11-14T10:30:00",
- "services": {
- "grobid": {
- "available": true,
- "url": "http://localhost:8070"
- }
- },
- "rag_stats": {
- "total_papers": 5,
- "total_chunks": 450,
- "embedding_model": "BAAI/bge-large-en-v1.5",
- "embedding_dimension": 1024,
- "llm_model": "gemini-pro"
- }
-}
-```
-
----
-
-### 2. Upload Paper
-
-#### POST `/upload`
-Upload and ingest an academic PDF paper into the RAG system.
-
-**Request:**
-- Content-Type: `multipart/form-data`
-- Body: `file` (PDF file)
-
-**Response:**
-```json
-{
- "status": "ok",
- "result": {
- "paper_id": "abc123def456...",
- "title": "Attention Is All You Need",
- "chunks_processed": 45,
- "sections_processed": 7,
- "filename": "transformer_paper.pdf",
- "upload_date": "2025-11-14T10:35:00"
- }
-}
-```
-
----
-
-### 3. Query Papers
-
-#### POST `/query`
-Query uploaded papers using natural language.
-
-**Request:**
-```json
-{
- "query": "What are the main advantages of transformers over RNNs?",
- "paper_ids": ["abc123", "def456"], // Optional: specific papers
- "n_results": 5 // Optional: number of context chunks (default: 5)
-}
-```
-
-**Response:**
-```json
-{
- "status": "ok",
- "result": {
- "answer": "Transformers offer several advantages over RNNs [1][2]...",
- "citations": [
- {
- "citation_number": 1,
- "paper_title": "Attention Is All You Need",
- "section": "Introduction",
- "page": "2",
- "paper_id": "abc123"
- }
- ],
- "contexts": [
- {
- "text": "Unlike RNNs, transformers can process...",
- "metadata": {
- "paper_id": "abc123",
- "title": "Attention Is All You Need",
- "section": "Introduction",
- "page": "2"
- },
- "relevance_score": 0.89
- }
- ],
- "model": "gemini-pro",
- "contexts_used": 5
- }
-}
-```
-
----
-
-### 4. List Papers
-
-#### GET `/papers`
-List all uploaded papers.
-
-**Response:**
-```json
-{
- "status": "ok",
- "papers": [
- {
- "paper_id": "abc123",
- "title": "Attention Is All You Need",
- "authors": "Vaswani et al.",
- "year": "2017",
- "upload_date": "2025-11-14T10:35:00"
- }
- ],
- "total": 1
-}
-```
-
----
-
-### 5. Delete Paper
-
-#### DELETE `/papers/Sentiment analysis for research papers
++ Analyze the research paper's sentiment towards a specific keyword or topic. +
+"{evidence.text}"
++ Enter a keyword above to analyze the sentiment of your research papers +
+ {documents.length === 0 && ( ++ ⚠️ No documents uploaded yet. Upload a PDF first! +
+ )} ++ Upload your academic research paper (PDF) to begin sentiment analysis. +
++ Drag and drop your PDF here, or +
+ +Selected file:
+{file.name}
++ {(file.size / 1024 / 1024).toFixed(2)} MB +
++ {uploadStatus.type === 'success' ? '✓ Success!' : '✗ Error'} +
+{uploadStatus.message}
+- Compare multiple papers across different aspects -
-- No papers available. Upload some papers first. -
- )} -- {selectedPapers.length} paper(s) selected -
-{paper.title}
- {paper.authors && ( -{paper.authors}
- )} - {paper.year && ( -Year: {paper.year}
- )} -- Upload at least 2 papers to compare them -
- - Upload Papers - -- Upload PDF papers to query them with AI-powered citation-grounded answers -
-- Ask questions across all uploaded papers -
- - - -- Browse and manage uploaded papers -
- - - -- Compare methodologies and findings -
- -Loading papers...
-- Manage your uploaded academic papers -
-- 👤 {paper.authors} -
- )} -- Start by uploading some academic papers to build your library -
- - Upload Your First Paper - -- Ask questions and get citation-grounded answers from your papers -
-- {citation.paper_title} -
-- Section: {citation.section} | Page: {citation.page} -
-{context.text}
-- Page: {context.metadata.page} -
-- Upload some academic papers first to start querying -
- - Upload Papers - -Loading...
-- {selectedFile ? selectedFile.name : 'Drop your academic PDF here'} -
-- or click to browse (max 50MB) -
-{selectedFile.name}
-- {(selectedFile.size / 1024 / 1024).toFixed(2)} MB -
-{children}
- - ); -} diff --git a/packages/ui/src/code.tsx b/packages/ui/src/code.tsx deleted file mode 100644 index f7cbd22..0000000 --- a/packages/ui/src/code.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { type JSX } from "react"; - -export function Code({ - children, - className, -}: { - children: React.ReactNode; - className?: string; -}): JSX.Element { - return{children};
-}
diff --git a/packages/ui/tsconfig.json b/packages/ui/tsconfig.json
deleted file mode 100644
index ca86687..0000000
--- a/packages/ui/tsconfig.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "extends": "@repo/typescript-config/react-library.json",
- "compilerOptions": {
- "outDir": "dist"
- },
- "include": ["src"],
- "exclude": ["node_modules", "dist"]
-}
diff --git a/packages/ui/turbo/generators/config.ts b/packages/ui/turbo/generators/config.ts
deleted file mode 100644
index 40100ba..0000000
--- a/packages/ui/turbo/generators/config.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import type { PlopTypes } from "@turbo/gen";
-
-// Learn more about Turborepo Generators at https://turbo.build/repo/docs/core-concepts/monorepos/code-generation
-
-export default function generator(plop: PlopTypes.NodePlopAPI): void {
- // A simple generator to add a new React component to the internal UI library
- plop.setGenerator("react-component", {
- description: "Adds a new react component",
- prompts: [
- {
- type: "input",
- name: "name",
- message: "What is the name of the component?",
- },
- ],
- actions: [
- {
- type: "add",
- path: "src/{{kebabCase name}}.tsx",
- templateFile: "templates/component.hbs",
- },
- {
- type: "append",
- path: "package.json",
- pattern: /"exports": {(?