This file is used for communication between Manager and Coding Agent.
Feature: cleanup-001, docker-001 Status: ✅ Completed Tests: Pass Notes: Both features completed successfully. API cleaned up and dockerized. YouTube tables preserved with correct row counts.
User Requirement:
- Remove TAQ, Curves, Futures, and ETS components from
youtube_finderdatabase and API code - Clean up the API to only support YouTube-related functionality
- Dockerize the cleaned-up API so it runs in Docker without requiring terminal to stay open
-
Database tables to remove (all empty, 0 rows):
ets_transactionstaq_datacurves_datafutures_data
-
Code files to remove:
api/routers/ets.pyapi/routers/taq.pyapi/routers/curves.pyapi/routers/futures.pyapi/models/ets.pyapi/models/taq.pyapi/models/curves.pyapi/models/futures.pyapi/schemas/ets.pyapi/schemas/taq.pyapi/schemas/curves.pyapi/schemas/futures.py
-
Files to modify:
api/main.py- Remove imports and router includesapi/models/__init__.py- Remove model exportstest/test_api.py- Remove ETS tests
- Verify current row counts in YouTube tables:
docker exec database-youtube-postgres psql -U postgres -d youtube_finder -c "SELECT 'videos' as table_name, COUNT(*) as row_count FROM videos UNION ALL SELECT 'video_labels', COUNT(*) FROM video_labels UNION ALL SELECT 'transcripts', COUNT(*) FROM transcripts;"
- Expected: videos (982), video_labels (774), transcripts (3)
- Document these counts for verification after cleanup
- Drop unused tables from
youtube_finderdatabase:docker exec database-youtube-postgres psql -U postgres -d youtube_finder -c "DROP TABLE IF EXISTS ets_transactions CASCADE;" docker exec database-youtube-postgres psql -U postgres -d youtube_finder -c "DROP TABLE IF EXISTS taq_data CASCADE;" docker exec database-youtube-postgres psql -U postgres -d youtube_finder -c "DROP TABLE IF EXISTS curves_data CASCADE;" docker exec database-youtube-postgres psql -U postgres -d youtube_finder -c "DROP TABLE IF EXISTS futures_data CASCADE;"
- Verify tables are dropped:
docker exec database-youtube-postgres psql -U postgres -d youtube_finder -c "\dt"
- Should only show YouTube-related tables: videos, video_labels, transcripts, video_notes, video_watch_positions, llm_responses
-
Delete router files:
api/routers/ets.pyapi/routers/taq.pyapi/routers/curves.pyapi/routers/futures.py
-
Delete model files:
api/models/ets.pyapi/models/taq.pyapi/models/curves.pyapi/models/futures.py
-
Delete schema files:
api/schemas/ets.pyapi/schemas/taq.pyapi/schemas/curves.pyapi/schemas/futures.py
-
Remove imports:
# REMOVE these lines: from api.routers import health, ets, taq, curves, futures from api.models import ETSTransaction, TAQData, CurvesData, FuturesData
-
Remove router includes:
# REMOVE these lines: app.include_router(ets.router) app.include_router(taq.router) app.include_router(curves.router) app.include_router(futures.router)
-
Keep only:
from api.routers import health app.include_router(health.router)
- Remove model exports for ETS, TAQ, Curves, Futures
- Keep only BaseModel if needed
- Remove all ETS-related tests
- Keep only health endpoint tests
- Update test summary to reflect removed tests
- Verify YouTube tables still exist and have correct row counts:
docker exec database-youtube-postgres psql -U postgres -d youtube_finder -c "SELECT 'videos' as table_name, COUNT(*) as row_count FROM videos UNION ALL SELECT 'video_labels', COUNT(*) FROM video_labels UNION ALL SELECT 'transcripts', COUNT(*) FROM transcripts;"
- Should match pre-cleanup counts: videos (982), video_labels (774), transcripts (3)
- Verify API still starts without errors:
python -m uvicorn api.main:app --reload --host 0.0.0.0 --port 8000
- Verify only health endpoint exists:
GET /health - Verify API docs at http://localhost:8000/docs shows only health endpoint
- Create
docker/Dockerfile.api:FROM python:3.11-slim WORKDIR /app # Install system dependencies (if needed for psycopg2) RUN apt-get update && apt-get install -y \ postgresql-client \ && rm -rf /var/lib/apt/lists/* # Copy requirements COPY utils/requirements.txt /app/requirements.txt # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY . /app # Expose API port EXPOSE 8000 # Run FastAPI with uvicorn CMD ["python", "-m", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000"]
- Update
api/config.pyto detect Docker environment:# In Settings class, update POSTGRES_HOST: POSTGRES_HOST: str = os.getenv("POSTGRES_HOST", "localhost") # Add property to detect Docker: @property def postgres_host(self) -> str: """Get PostgreSQL host - use 'postgres' in Docker, 'localhost' outside.""" if os.path.exists("/app") or os.getenv("DOCKER_ENV"): return os.getenv("POSTGRES_HOST", "postgres") return os.getenv("POSTGRES_HOST", "localhost") # Update database_url property to use postgres_host: @property def database_url(self) -> str: """Construct PostgreSQL database URL.""" host = self.postgres_host return ( f"postgresql://{self.POSTGRES_USER}:{self.POSTGRES_PASSWORD}" f"@{host}:{self.POSTGRES_PORT}/{self.POSTGRES_DB}" )
- Add API service to
docker/docker-compose.yml:api: build: context: .. dockerfile: docker/Dockerfile.api container_name: database-youtube-api environment: POSTGRES_USER: ${POSTGRES_USER:-postgres} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme} POSTGRES_DB: ${POSTGRES_DB:-youtube_finder} POSTGRES_HOST: postgres # Service name in Docker network POSTGRES_PORT: 5432 API_HOST: 0.0.0.0 API_PORT: 8000 DOCKER_ENV: "true" # Flag to detect Docker environment ports: - "${API_PORT:-8000}:8000" depends_on: postgres: condition: service_healthy restart: unless-stopped networks: - database-youtube-network
-
Build API image:
docker-compose -f docker/docker-compose.yml build api
-
Start all services:
docker-compose -f docker/docker-compose.yml up -d
-
Check API container logs:
docker logs database-youtube-api
-
Verify API is accessible:
curl http://localhost:8000/health # Or open in browser: http://localhost:8000/docs
-
Verify API docs show only health endpoint
- Verify YouTube tables still exist and have correct data:
docker exec database-youtube-postgres psql -U postgres -d youtube_finder -c "SELECT 'videos' as table_name, COUNT(*) as row_count FROM videos UNION ALL SELECT 'video_labels', COUNT(*) FROM video_labels UNION ALL SELECT 'transcripts', COUNT(*) FROM transcripts;"
- Should match pre-cleanup counts: videos (982), video_labels (774), transcripts (3)
- Update README.md to reflect cleaned-up API
- Document Docker deployment process
- Document that API now only provides health endpoint (YouTube tables managed by other processes)
- Database tables dropped: ets_transactions, taq_data, curves_data, futures_data
- Router files deleted: ets.py, taq.py, curves.py, futures.py
- Model files deleted: ets.py, taq.py, curves.py, futures.py
- Schema files deleted: ets.py, taq.py, curves.py, futures.py
- api/main.py updated (removed imports and router includes)
- api/models/init.py updated (removed model exports)
- test/test_api.py updated (removed ETS tests)
- YouTube tables still exist with correct row counts
- API starts without errors
- Only health endpoint available
- Dockerfile.api created and builds successfully
- API service added to docker-compose.yml
- api/config.py detects Docker environment correctly
- API container starts and connects to database
- API is accessible at http://localhost:8000
- Health endpoint works:
GET /health - API docs accessible at http://localhost:8000/docs
- API container restarts automatically if it crashes
- No terminal window needed to keep API running
- CRITICAL: YouTube-related tables still accessible (videos, video_labels, transcripts)
- CRITICAL: No data loss in existing tables (verify row counts match before/after)
- CRITICAL: Other processes can still connect to database (database port 5432 still exposed)
docker/Dockerfile.api- Dockerfile for API container
api/routers/ets.pyapi/routers/taq.pyapi/routers/curves.pyapi/routers/futures.pyapi/models/ets.pyapi/models/taq.pyapi/models/curves.pyapi/models/futures.pyapi/schemas/ets.pyapi/schemas/taq.pyapi/schemas/curves.pyapi/schemas/futures.py
docker/docker-compose.yml- Add API serviceapi/config.py- Add Docker environment detectionapi/main.py- Remove unused imports and routersapi/models/__init__.py- Remove unused model exportstest/test_api.py- Remove ETS testsREADME.md- Update documentation
- DO NOT modify YouTube-related tables - They are used by OTHER processes
- DO NOT drop YouTube-related tables - Only drop ETS, TAQ, Curves, Futures tables
- Verify row counts before and after - YouTube tables must remain unchanged
- Database port 5432 remains exposed - Other processes need access
- Backward compatibility - API should still work when run outside Docker (for development)
2025-01-23 - Clean Up API and Dockerize
- User decision: Remove TAQ, Curves, Futures, and ETS (all unused)
- Features: cleanup-001, docker-001
- Priority: HIGH
- Status: ✅ COMPLETED - Both features implemented and verified