Go to file
xutiansheng 53de7d1247 Initial commit 2025-09-06 12:27:31 +08:00
app Initial commit 2025-09-06 12:27:31 +08:00
frontend Initial commit 2025-09-06 12:27:31 +08:00
.gitignore Initial commit 2025-09-06 12:27:31 +08:00
Dockerfile Initial commit 2025-09-06 12:27:31 +08:00
FIXES.md Initial commit 2025-09-06 12:27:31 +08:00
Makefile Initial commit 2025-09-06 12:27:31 +08:00
README.md Initial commit 2025-09-06 12:27:31 +08:00
USAGE.md Initial commit 2025-09-06 12:27:31 +08:00
create_test_pdf.py Initial commit 2025-09-06 12:27:31 +08:00
docker-compose.yml Initial commit 2025-09-06 12:27:31 +08:00
requirements.txt Initial commit 2025-09-06 12:27:31 +08:00
test.pdf Initial commit 2025-09-06 12:27:31 +08:00
test_api.py Initial commit 2025-09-06 12:27:31 +08:00

README.md

PDF Literature Reader

A web-based PDF literature reader with AI translation and chat capabilities.

Features

  • Split-view PDF reading (original on left, translation on right)
  • AI-powered translation
  • Intelligent chat interface
  • Docker Compose deployment ready
  • RESTful API for PDF management and AI services

Project Structure

paper-assistant/
├── app/                 # FastAPI backend
│   ├── main.py         # Application entry point
│   ├── api/            # API routes
│   ├── core/           # Core configurations
│   ├── models/         # Data models
│   ├── schemas/        # Pydantic schemas
│   └── utils/          # Utility functions
├── frontend/           # Frontend application
├── docker-compose.yml  # Docker Compose configuration
├── Dockerfile          # Backend Dockerfile
└── requirements.txt    # Python dependencies

Quick Start

Using Virtual Environment (Development)

  1. Set up the environment:

    make setup
    
  2. Run the application:

    make run
    
  3. Open your browser and navigate to http://localhost:8000

Using Docker Compose (Deployment)

  1. Build and start the services:

    make docker
    
  2. Access the application at http://localhost:8000

How to Use

  1. Upload a PDF:

    • Click "Choose File" and select a PDF document
    • Click "Upload PDF"
    • The uploaded PDF will appear in the dropdown list
  2. View a PDF:

    • Select a PDF from the dropdown list
    • The original PDF will display in the left panel
    • A simulated translation will appear in the right panel
  3. Chat with AI:

    • Type your question in the chat input at the bottom
    • Click "Send" or press Enter
    • Receive a simulated AI response

API Endpoints

PDF Management

  • POST /api/pdf/upload - Upload a PDF file
  • GET /api/pdf/list - List all uploaded PDFs
  • GET /api/pdf/view/{filename} - View a specific PDF

Chat and Translation

  • POST /api/chat/message - Send a message to the AI assistant
  • POST /api/chat/translate - Translate text to Chinese

Development

  1. Install dependencies:

    pip install -r requirements.txt
    
  2. Run the application:

    uvicorn app.main:app --reload
    

Testing

Run the API tests:

make test

Create a test PDF:

python create_test_pdf.py

Deployment with Docker Compose

docker-compose up -d

Stop the services:

make docker-stop

Architecture

This application follows a modular architecture with clear separation of concerns:

  1. Frontend: Simple HTML/CSS/JavaScript interface for PDF viewing and chat
  2. Backend: FastAPI application with separate modules for PDF management and chat services
  3. Storage: Local file system storage for uploaded PDFs
  4. Deployment: Docker Compose configuration for easy deployment

The application is designed to be easily extensible with additional AI services for translation and chat functionality.