Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: separate shared “core” code from FastAPI server modules #137

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

filipchristiansen
Copy link
Collaborator

Overview

This PR finishes our repository reorganization so that shared “core” logic resides in a core/ subpackage, the FastAPI app code is under server/, and the CLI remains in gitingest/. This clarifies which modules are CLI-specific vs. server-specific vs. general-purpose, and also preserves top-level exports for users who do import gitingest.

Key Changes

  1. core/

    • Moved the shared logic: config.py, exceptions.py, ignore_patterns.py, notebook_utils.py, query_ingestion.py, query_parser.py, repository_clone.py, repository_ingest.py, and utils.py.
    • core/__init__.py is no longer exporting public APIs directly, so it’s effectively internal.
  2. server/

    • Houses the FastAPI application: main.py, query_processor.py, server_utils.py, routers/, plus static/ and templates/.
    • References to static files and templates are updated to /server/static and /server/templates in main.py, Jinja code, and the routers, ensuring Docker can properly serve them.
  3. gitingest/

    • Retains the CLI code (cli.py).
    • Now includes the “top-level exports” in gitingest/__init__.py, so import gitingest still provides run_ingest_query, parse_query, clone_repo, and ingest.
  4. Tests

    • Updated test references from gitingest.* to core.* or server.* as appropriate.
  5. Docker Compatibility

    • Running docker build -t gitingest . then docker run -d --name gitingest -p 8000:8000 gitingest successfully serves the FastAPI app at http://localhost:8000/, loading static files and templates from server/.

Why These Changes?

  • Cleaner Separation: We now have a clearer boundary between the “core” modules, the FastAPI server, and the CLI.
  • Consistent Exports: Placing exports in gitingest/__init__.py ensures users can continue to do import gitingest for ingestion functions.
  • Correct File Serving: With static and templates inside server/, references needed updating so the app works both locally and in Docker.

Testing

  • Manually tested Docker flow: Built the image, ran the container, and verified that http://localhost:8000 shows the updated UI and loads images/styles.
  • Tried the UI with a few different repos to confirm the ingestion process works end-to-end.
  • Confirmed import gitingest still provides the same top-level functions (run_ingest_query, parse_query, etc.).

Context

Relates to #125.

Terminal CLI Note

The terminal CLI is still broken but has been addressed in this PR: #136.

@filipchristiansen filipchristiansen force-pushed the refactor/separate-core-and-server branch from 09bb338 to 62e7d53 Compare January 17, 2025 08:49
- Moved shared logic (config, exceptions, ignore_patterns, etc.) into `core/`.
- Created `server/` to host FastAPI modules, static files, and templates.
- Updated import paths for CLI and tests to reference `core.*` and `server.*`.
- Changed static references from `"/static"` to `"/server/static"` and templates from `"/templates"` to `"/server/templates"`.
- Adjusted references in `base.jinja`, `server/main.py`, `server/query_processor.py`, and routers to reflect the new server paths.
- Ensured Docker builds now correctly serve static and template files from `server/`.
@filipchristiansen filipchristiansen force-pushed the refactor/separate-core-and-server branch from 62e7d53 to dc98342 Compare January 17, 2025 16:29
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