ai-argument/
backend/
app/
venv/
requirements.txt
run.py
frontend/
public/
src/
index.html
package-lock.json
package.json
postcss.config.js
tailwind.config.js
tsconfig.json
tsconfig.node.json
vite.config.ts
src/
main/
preload/
renderer/
shared/
ai-argument.code-workspace
argument.md
config.example.json
HOW-TO-USE-DOCUMENTS.md
index.html
package-lock.json
package.json
PROJECT.yaml
README.md
README.sync-conflict-20260802-120012-WRHFNHE.md
sample-argument.xml
tsconfig.json
tsconfig.node.json
vite.config.ts
[DRAFT — edit this] A professional standalone web application for analyzing, editing, and validating argument structures using AI. Built with FastAPI (backend) and React (frontend). Inferred stage: development. Define the specific deliverable, success state, and timeline.
Success criteria:| Code | /Users/friedrichstr/ai-mac-studio/scholarly/projects/ai-argument |
| Check | Path | Status | Detail |
|---|---|---|---|
| code | /Users/friedrichstr/ai-mac-studio/scholarly/projects/ai-argu | ✓ ok | 19 items, last_modified=2026-08-24 |
A professional standalone web application for analyzing, editing, and validating argument structures using AI. Built with FastAPI (backend) and React (frontend).
cd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure API key (required for AI features)
# Edit .env file and add your Gemini API key
# Get a key at: https://makersuite.google.com/app/apikey
# Start the server
uvicorn app.main:app --reload --port 5400
cd frontend
# Install dependencies
npm install
# Start development server
npm run dev
Open your browser to: http://localhost:5173
The AI Argument Editor uses a flexible, portable path configuration system that allows the application to run seamlessly on different computers with different file system architectures.
The path system supports:
- Relative paths (resolved from application root)
- Absolute paths (for external drives or specific locations)
- Auto-detection (for pdai document sources)
- Per-machine configuration (via config.json)
- Environment variable overrides (via .env)
Located in the application root directory. Created automatically when you change settings, or create manually:
{
"paths": {
"data_folder": "data",
"xml_folder": "arguments",
"exports_folder": "exports",
"pdai_path": null
}
}
| Field | Description | Default |
|---|---|---|
data_folder |
Root folder for all data storage | "data" (relative) |
xml_folder |
Subfolder for XML argument files | "arguments" |
exports_folder |
Subfolder for exported files | "exports" |
pdai_path |
Path to pdai document collection | null (auto-detect) |
For sensitive settings and overrides:
# Required for AI features
GEMINI_API_KEY=your_api_key_here
# AI Model (strictly enforced - do not change)
GEMINI_MODEL=gemini-3.8-flash
# Optional: Override application root
APP_ROOT=/custom/path/to/app
# Debug mode
DEBUG=false
# Server port
PORT=5400
Paths are resolved in the following order:
/ (Unix) or drive letter (Windows)APP_ROOTAPP_ROOT env var is set → use that pathbackend/ folder// Relative paths (portable - recommended)
{
"paths": {
"data_folder": "data",
"xml_folder": "arguments"
}
}
// Resolves to: /path/to/ai-argument/data/arguments/
// Absolute paths (machine-specific)
{
"paths": {
"data_folder": "/Users/shared/argument-data",
"xml_folder": "arguments"
}
}
// Resolves to: /Users/shared/argument-data/arguments/
// External drive (for pdai documents)
{
"paths": {
"pdai_path": "/Volumes/ExternalDrive/2026project/pdai"
}
}
The pdai path can be configured in three ways:
When pdai_path is null, the system searches these locations in order:
/Volumes/PortableMacAir/2026project/pdai (External drive)~/Dropbox/202x/2026project/pdai (Dropbox sync)~/Dropbox/Buero/Begutachtung/Promotionen/Berthoud/pdai (Legacy){
"paths": {
"pdai_path": "/Volumes/MyDrive/pdai"
}
}
# Set custom path
curl -X PUT http://localhost:5400/api/config/pdai-path \
-H "Content-Type: application/json" \
-d '{"path": "/Volumes/MyDrive/pdai"}'
# Use auto-detection
curl -X POST http://localhost:5400/api/config/pdai-path/auto-detect
To use the application on multiple computers:
The application is in a synced Dropbox folder. Both computers access the same files.
config.json (same on both machines):
{
"paths": {
"data_folder": "data",
"xml_folder": "arguments",
"exports_folder": "exports",
"pdai_path": null
}
}
The pdai path auto-detects based on what's available on each machine.
Each machine has data in different locations.
Machine A (MacBook) - config.json:
{
"paths": {
"data_folder": "/Users/alice/Documents/argument-data",
"pdai_path": "/Volumes/PortableMacAir/2026project/pdai"
}
}
Machine B (Desktop) - config.json:
{
"paths": {
"data_folder": "/home/bob/argument-data",
"pdai_path": "/mnt/external/pdai"
}
}
Solution: Don't sync config.json - let each machine have its own. Add to .gitignore:
config.json
Application and data on a USB drive.
config.json:
{
"paths": {
"data_folder": "data",
"xml_folder": "arguments",
"exports_folder": "exports"
}
}
Using relative paths, everything stays within the application folder on the USB drive.
ai-argument/
├── config.json # Path configuration (machine-specific)
├── backend/
│ ├── .env # Environment variables (machine-specific)
│ ├── app/
│ │ ├── config.py # Configuration manager
│ │ ├── services/
│ │ │ └── document_service.py # pdai auto-detection
│ │ └── ...
│ └── requirements.txt
├── frontend/
│ └── ...
├── data/ # Default data folder (relative)
│ ├── arguments/ # XML argument files
│ └── exports/ # Exported files
└── README.md
The configuration can be read and modified via the API:
| Endpoint | Method | Description |
|---|---|---|
/api/config/ |
GET | Get full configuration including paths and pdai status |
/api/config/paths |
PUT | Update data/xml/exports paths |
/api/config/pdai-path |
PUT | Set custom pdai path |
/api/config/pdai-path/auto-detect |
POST | Clear custom pdai path, use auto-detection |
/api/config/health |
GET | Check if configured paths exist |
curl http://localhost:5400/api/config/
Response:
{
"app_name": "AI Argument Editor",
"app_root": "/Users/alice/Dropbox/ai-argument",
"paths": {
"data_folder": "data",
"xml_folder": "arguments",
"exports_folder": "exports",
"data_path_absolute": "/Users/alice/Dropbox/ai-argument/data",
"xml_path_absolute": "/Users/alice/Dropbox/ai-argument/data/arguments",
"exports_path_absolute": "/Users/alice/Dropbox/ai-argument/data/exports"
},
"ai": {
"model": "gemini-3.8-flash",
"api_key_configured": true
},
"pdai": {
"path": null,
"effective_path": "/Volumes/PortableMacAir/2026project/pdai",
"auto_detected_path": "/Volumes/PortableMacAir/2026project/pdai",
"available": true,
"document_count": 12
}
}
The pdai folder was not found. Check: 1. Is the external drive connected? 2. Is the path correct in Settings? 3. Try clicking "Auto-detect" in Settings
The configured path doesn't exist or isn't writable. Check:
1. Run GET /api/config/health to verify paths
2. Ensure the data folder exists and is writable
3. Check file permissions
The config.json file may be malformed. Check:
1. Validate JSON syntax
2. Ensure all path values are strings
3. Check the server logs for errors
ai-argument/
├── backend/
│ ├── app/
│ │ ├── main.py # FastAPI application
│ │ ├── config.py # Configuration management
│ │ ├── models.py # Pydantic models
│ │ ├── schemas/
│ │ │ └── argument.dtd # XML schema for arguments
│ │ ├── routers/
│ │ │ ├── files.py # File management endpoints
│ │ │ ├── arguments.py # Argument processing endpoints
│ │ │ ├── config.py # Configuration endpoints
│ │ │ └── documents.py # pdai document endpoints
│ │ └── services/
│ │ ├── xml_service.py # XML parsing/generation
│ │ ├── ai_service.py # Gemini AI integration
│ │ └── document_service.py # pdai document access
│ ├── data/
│ │ ├── arguments/ # XML argument files
│ │ └── exports/ # Exported files
│ ├── requirements.txt
│ └── .env
├── frontend/
│ ├── src/
│ │ ├── App.tsx
│ │ ├── components/
│ │ │ ├── Dashboard.tsx
│ │ │ ├── FileManager.tsx
│ │ │ ├── ArgumentEditor.tsx
│ │ │ ├── Settings.tsx
│ │ │ ├── graph/ # React Flow components
│ │ │ │ ├── ArgumentGraph.tsx
│ │ │ │ ├── PropositionNode.tsx
│ │ │ │ └── PremiseEdge.tsx
│ │ │ └── documents/ # pdai integration
│ │ │ ├── DocumentSelector.tsx
│ │ │ └── SourcePanel.tsx
│ │ ├── services/api.ts
│ │ ├── store.ts
│ │ └── types.ts
│ └── package.json
├── config.json # Path configuration
└── README.md
GET /api/files/ - List all argument filesGET /api/files/{filename} - Load a specific filePOST /api/files/{filename} - Create a new filePUT /api/files/{filename} - Update a fileDELETE /api/files/{filename} - Delete a filePOST /api/files/rename - Rename a filePOST /api/arguments/validate - Validate argument structurePOST /api/arguments/export - Export to XMLPOST /api/arguments/analyze - AI analysisPOST /api/arguments/ai/validate - AI validationPOST /api/arguments/ai/suggest - AI suggestionsPOST /api/arguments/ai/extract - Extract from textGET /api/documents/ - List available documentsGET /api/documents/status - Get pdai availability statusGET /api/documents/{id} - Get document detailsGET /api/documents/{id}/pages - Load page contentPOST /api/documents/{id}/extract-argument - Extract argument from pagesGET /api/config/ - Get full configurationPUT /api/config/paths - Update path configurationPUT /api/config/pdai-path - Set pdai pathPOST /api/config/pdai-path/auto-detect - Auto-detect pdaiGET /api/config/health - Health checkArguments are stored in XML format following the DTD schema:
<?xml version="1.0" encoding="UTF-8"?>
<argument title="Argument Title" source="Source Reference"
document_id="E57" page_range="1-5">
<meta created="2026-02-02" model="gemini-3.8-flash" version="1.0"/>
<proposition id="P1" label="First Premise" type="premise">
<text>The proposition text</text>
<premises/>
<rule>assumption</rule>
<comment>Optional comment</comment>
</proposition>
<proposition id="C1" label="Conclusion" type="conclusion" source_page="3">
<text>The conclusion</text>
<premises>
<ref id="P1"/>
</premises>
<rule>modus ponens</rule>
<comment>Derived from P1</comment>
</proposition>
</argument>
The application uses Google Gemini (gemini-3.8-flash) for:
MIT License