Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ downloads/
eggs/
.eggs/
lib/
!webview-poc/ragas-webview/src/lib/
lib64/
parts/
sdist/
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[project]
name = "ragas"
version = "0.1.0"
description = "Add your description here"
requires-python = ">=3.12"
dependencies = [
"fastapi>=0.116.1",
"pendulum>=3.0.0",
"ragas-experimental>=0.3.0",
"uvicorn>=0.35.0",
]
93 changes: 93 additions & 0 deletions webview-poc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Virtual environments
venv/
env/
ENV/
env.bak/
venv.bak/

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Node.js
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# React/Vite
dist/
dist-ssr/
*.local

# Environment variables
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Logs
logs/
*.log

# Coverage
coverage/
*.lcov

# ESLint
.eslintcache

# Prettier
.prettierignore

# TypeScript
*.tsbuildinfo

# Temporary files
*.tmp
*.temp

# Built frontend bundle (generated by build script)
js-bundle/
private_toolings
!webview-poc/ragas-webview/src/lib
!src/lib
!webview-poc/ragas-webview/src/lib/*/**
149 changes: 149 additions & 0 deletions webview-poc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Ragas Webview CLI

A web-based file viewer with React frontend and Python backend. Easily spin up a web interface to browse and view local project files.

## Features

- 🚀 **Standalone CLI** - Single command to start web server
- ⚛️ **React Frontend** - Modern web interface for file browsing
- 🐍 **Python Backend** - FastAPI server with file serving capabilities
- 🔄 **Development Mode** - Hot reload for both frontend and backend
- 📦 **Production Ready** - Bundled React app served by Python server

## Installation

### Using uv (recommended)

```shell
#For development (both React + Python servers):
uv run python scripts/dev.py <directory>
# uv run python scripts/dev.py ./logs

#For production (Python server only):
uv run python -m ragas_webview_cli <directory>
# uv run python -m ragas_webview_cli ./logs

```


```bash
# Install with uv
uv init

# Or install from local directory
cd webview-poc
uv sync

uv run python scripts/dev.py

uv run python -m ragas_webview_cli logs
```

### Using pip

```bash
pip install ragas-webview-cli

# Or install from local directory
cd webview-poc
pip install -e .
```

## Usage

### Production Mode (Bundled)

```bash
# Start the webview server
uv run ragas-webview-cli --port 8000 --host 127.0.0.1

# Or use Python directly
uv run python -m ragas_webview_cli.cli --port 8000
```

### Development Mode

```bash
# Run both React dev server and Python API server
uv run python scripts/dev.py

# This starts:
# - React dev server on http://localhost:3000 (with hot reload)
# - Python API server on http://localhost:8000
```

### Building React Bundle

```bash
# Build React app for production
uv run python scripts/build.py

# Or build directly with npm
cd ragas-webview
npm run build:bundle
```

## Development Setup

### Prerequisites

- Python 3.9+
- Node.js 18+
- uv (recommended) or pip

### Setup

```bash
# Clone and setup with uv
git clone <repo>
cd webview-poc
uv sync

# Install React dependencies
cd ragas-webview
npm install
cd ..

# Run development environment
uv run python scripts/dev.py
```

## Project Structure

```
webview-poc/
├── README.md
├── pyproject.toml # ← Package configuration
├── uv.lock # ← UV lock file
├── js-bundle/ # ← Built React app (not packaged)
├── ragas-webview/ # ← React source (not packaged)
├── scripts/ # ← Development scripts (not packaged)
│ ├── dev.py # ← Development server script
│ └── build.py # ← Build script
└── ragas_webview_cli/ # ← Main package (packaged in pip)
├── __init__.py
├── cli.py # ← CLI entry point
├── config.py # ← Configuration
└── server.py # ← FastAPI server
```

## Configuration

All server ports and hosts are configured in `ragas_webview_cli/config.py`:

```python
BACKEND_PORT = 8000
FRONTEND_PORT = 3000
BACKEND_HOST = "127.0.0.1"
FRONTEND_HOST = "127.0.0.1"
```

## API Endpoints

- `GET /` - Serves React app (production) or API info (development)
- `GET /api/health` - Health check endpoint
- `GET /assets/*` - Static assets (CSS, JS, images)

## License

MIT License
66 changes: 66 additions & 0 deletions webview-poc/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[project]
name = "ragas-webview-cli"
version = "0.1.0"
description = "Web-based file viewer with React frontend and Python backend"
readme = "README.md"
requires-python = ">=3.9"
authors = [
{name = "Ragas Team", email = "[email protected]"}
]
keywords = ["webview", "file-viewer", "react", "fastapi"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]

dependencies = [
"fastapi>=0.100.0",
"uvicorn[standard]>=0.23.0",
"typer>=0.9.0",
"pydantic>=2.0.0",
"pendulum>=3.0.0",
]

[project.optional-dependencies]
dev = [
"pytest>=7.0.0",
"pytest-asyncio>=0.21.0",
"httpx>=0.24.0", # For testing FastAPI
"black>=23.0.0",
"ruff>=0.1.0",
]

# No scripts - use python -m ragas_webview_cli.cli or direct import

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["ragas_webview_cli"]

[tool.uv]
dev-dependencies = [
"pytest>=7.0.0",
"pytest-asyncio>=0.21.0",
"httpx>=0.24.0",
"black>=23.0.0",
"ruff>=0.1.0",
]

# Removed ragas-experimental dependency

[tool.ruff]
select = ["E", "F", "I"]
ignore = ["E501"]
line-length = 88
target-version = "py39"

[tool.black]
line-length = 88
target-version = ["py39"]
26 changes: 26 additions & 0 deletions webview-poc/ragas-webview/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
!webview-poc/ragas-webview/src/lib/*/**
!lib/*/**
10 changes: 10 additions & 0 deletions webview-poc/ragas-webview/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @type {import("prettier").Config} */
module.exports = {
semi: true,
singleQuote: true,
trailingComma: 'all',
tabWidth: 2,
useTabs: false,
bracketSpacing: true,
arrowParens: 'always',
};
Loading
Loading