Skip to content

Code cleanup: lazy clients, lifespan, schemas split, tests and CI - #5

Merged
matuck40 merged 2 commits into
readme-rewritefrom
code-cleanup
Sep 9, 2026
Merged

matuck40 merged 2 commits into
readme-rewritefrom
code-cleanup

Conversation

@matuck40

@matuck40 matuck40 commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Stacked on #4 (base is readme-rewrite; GitHub retargets to main once #4 merges).

What changed

  • OpenAI clients created on first use; embeddings loaded in the FastAPI lifespan. Importing the app no longer needs a key.
  • app/schemas.py (Pydantic) separated from app/models.py (ORM). .dict() → .model_dump(), sqlalchemy.orm.declarative_base, naive-UTC helper instead of datetime.utcnow.
  • DatabaseService: context-managed sessions; get_db() (closed the session before returning it) and three unused methods removed. load_knowledge_base and chunk_text removed.
  • app/__init__.py loads .env, so alembic/env.py now uses DATABASE_URL; init_db.py removed (single path to create the schema).
  • tests/ (13 tests: chunking, ranking, cache, endpoints with fakes), pyproject.toml with ruff config, requirements-dev.txt, .github/workflows/tests.yml.
  • README updated to match.

Verification (local, Python 3.14)

ruff check .   -> All checks passed
pytest -q      -> 13 passed in 0.47s
alembic upgrade head --sql  -> emits the migration reading DATABASE_URL from .env

🤖 Generated with Claude Code

https://claude.ai/code/session_01QVi7kKzGQhgPKX8sDzTu6i

matuck40 and others added 2 commits September 8, 2026 13:08
… and CI

- OpenAI clients are created on first use; embeddings load in the FastAPI lifespan
- Pydantic schemas moved to app/schemas.py; app/models.py keeps only the ORM
- DatabaseService uses context-managed sessions; unused methods and
  load_knowledge_base/chunk_text removed
- alembic/env.py reads DATABASE_URL (app/__init__.py loads .env); init_db.py removed
- .model_dump(), sqlalchemy.orm.declarative_base, timezone-aware UTC helper
- tests/ with fakes for OpenAI and the database; ruff config; GitHub Actions workflow
- README updated to match

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QVi7kKzGQhgPKX8sDzTu6i
@matuck40
matuck40 merged commit ac7e560 into readme-rewrite Sep 9, 2026
6 checks passed
@matuck40
matuck40 deleted the code-cleanup branch September 9, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant