|
|
||
|---|---|---|
| app | ||
| frontend | ||
| .gitignore | ||
| Dockerfile | ||
| FIXES.md | ||
| Makefile | ||
| README.md | ||
| USAGE.md | ||
| create_test_pdf.py | ||
| docker-compose.yml | ||
| requirements.txt | ||
| test.pdf | ||
| test_api.py | ||
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)
-
Set up the environment:
make setup -
Run the application:
make run -
Open your browser and navigate to
http://localhost:8000
Using Docker Compose (Deployment)
-
Build and start the services:
make docker -
Access the application at
http://localhost:8000
How to Use
-
Upload a PDF:
- Click "Choose File" and select a PDF document
- Click "Upload PDF"
- The uploaded PDF will appear in the dropdown list
-
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
-
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 fileGET /api/pdf/list- List all uploaded PDFsGET /api/pdf/view/{filename}- View a specific PDF
Chat and Translation
POST /api/chat/message- Send a message to the AI assistantPOST /api/chat/translate- Translate text to Chinese
Development
-
Install dependencies:
pip install -r requirements.txt -
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:
- Frontend: Simple HTML/CSS/JavaScript interface for PDF viewing and chat
- Backend: FastAPI application with separate modules for PDF management and chat services
- Storage: Local file system storage for uploaded PDFs
- Deployment: Docker Compose configuration for easy deployment
The application is designed to be easily extensible with additional AI services for translation and chat functionality.