docs and api mostly work

This commit is contained in:
2026-01-03 13:18:42 -07:00
parent 81ea22eae9
commit 55b0a698d0
11 changed files with 181 additions and 23 deletions

View File

@@ -353,3 +353,92 @@ Updated:
```
The Phase 1 implementation successfully transforms the CLI tool into a modern web application while preserving all existing functionality and data compatibility.
## Docker Build Issue Resolution
**Problem**: The original Docker build was failing with the error:
```
npm error The `npm ci` command can only install with an existing package-lock.json or
npm error npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
npm error later to generate a package-lock.json file, then try again.
```
**Solution**: Updated the frontend Dockerfile to use `npm install` instead of `npm ci` since no package-lock.json file exists yet. The updated Dockerfile now works correctly:
```dockerfile
# Install dependencies
# Use npm install for development (npm ci requires package-lock.json)
RUN npm install
```
**Verification**: Docker build now completes successfully and the frontend container can be built and run without errors.
## Docker Permission Error Resolution
**Problem**: The backend container was failing with the error:
```
PermissionError: [Errno 13] Permission denied: '/data'
```
**Root Cause**: The issue was in `backend/main.py` where the data directory path was incorrectly calculated:
```python
# Incorrect calculation
data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data")
# This resulted in '/data' instead of '/app/data'
```
**Solution**: Fixed the path calculation to use the configuration-based approach:
```python
# Correct calculation using settings
from pathlib import Path
from app.core.config import settings
data_dir = Path(settings.DATA_DIR) # 'data' -> resolves to '/app/data' in container
data_dir.mkdir(exist_ok=True)
```
**Additional Considerations**:
1. **User Permissions**: The Dockerfile creates a non-root user `appuser` with UID 1000, which matches the typical host user UID for better volume permission compatibility.
2. **Volume Mount**: The docker-compose.yml mounts `./data:/app/data` ensuring data persistence.
3. **Directory Permissions**: The host `data/` directory has permissions `700` (owner only), but since the container user has the same UID (1000), it can access the directory.
**Verification**:
- Docker builds complete successfully for both backend and frontend
- Backend container starts without permission errors
- API endpoints respond correctly
- Health check endpoint returns `{"status": "healthy"}`
- FastAPI documentation endpoints (`/docs` and `/redoc`) are now always enabled
## FastAPI Documentation Endpoints Fix
**Problem**: FastAPI's built-in documentation endpoints (`/docs` and `/redoc`) were not working because they were only enabled when `DEBUG=true`.
**Root Cause**: In `backend/main.py`, the documentation endpoints were conditionally enabled:
```python
docs_url="/docs" if settings.DEBUG else None,
redoc_url="/redoc" if settings.DEBUG else None,
```
**Solution**: Removed the conditional logic to always enable documentation endpoints:
```python
docs_url="/docs",
redoc_url="/redoc",
```
**Verification**:
- `/docs` endpoint returns HTTP 200 with Swagger UI
- `/redoc` endpoint returns HTTP 200 with ReDoc documentation
- `/openapi.json` provides the OpenAPI schema
- Root endpoint correctly lists documentation URLs
User notes:
Backend and backend docs seem to be in a good state.
Let us focus on frontend for a bit.
Task 1:
There are UI elements which shift on mouseover. This is bad design.
Task 2:
The default page should show just the prompt in the most recent position in history. It currently does a draw from the pool, or possibly displays the most recent draw action. Drawing from the pool should only happen when requested by the user.
On the default page there should be some sort of indication of how full the pool is. A simple graphical element would be nice. It should only show one writing prompt.
Task 3:
Check whether the UI buttons to refill the pool and to draw from the pool have working functionality.
Task 4:
Change the default number drawn from the pool to 3.