gitingest icon indicating copy to clipboard operation
gitingest copied to clipboard

refactor: Migrate the backend to a REST api

Open ix-56h opened this issue 6 months ago • 3 comments

Describe the issue

The current backend is a bit messy and serves the ingest response with a fully generated HTML response. This is an issue for agent compatibility and this can slow us a lot for future features.

We need a REST api ready for a future proof frontend.

Only 1 endpoint needed : GET /api/ingest

This can then be used as a reference for future endpoints as for #318 .

ix-56h avatar Jun 30 '25 22:06 ix-56h

I'm currently working on a refactor of the backend and make the frontend works with the changes.

After talking about it with @cyclotruc , we need a REST api and start thinking about the future.

So, here's the changes i'm thinking about :

Breaking changes

  • GET & POST /api needs to be the entry point of our backend API, it's currently deprecated and doesn't serves any purpose so it's going to be removed
  • GET / the "index" endpoint needs to render only the needed HTML
  • GET /{full_path:path} will follow the same pattern than GET / endpoint (our index, app entrypoint)
  • POST / will be removed
  • POST /{full_path:path} will be removed
  • GET /download/{ingest_id} will be removed, the download feature will be implemented on the frontend side

New endpoints

  • POST /api/ingest is going to be our main endpoint, both GET /{full_path:path} and GET / are going to use it to request ingest, the response will be a JSON formated object.

Generated openapi and Swagger UI

  • All useless endpoints will be removed from the openapi generated file. Only /api/ingest and API related endpoints will be described.
  • The GET /docs endpoint, automatically generated by FastAPI, will have a new look, integrating the swagger ui to the style of gitingest.

It's a lot of work, and I intend to make it happen, but the frontend is going to be cumbersome. My goal is to get the backend ready for an entirely new front-end approach, the templating style has its limits and it's going to give us a lot of problems in the future.

ix-56h avatar Jun 30 '25 22:06 ix-56h

The WIP is available on #346 I'm not familiar with the github workflow, so I'm a bit surprised that the PR was created even without any action on my part.

ix-56h avatar Jul 01 '25 00:07 ix-56h

@ix-56h No worries! Thanks for the PR, let's continue discussing over there

cyclotruc avatar Jul 01 '25 00:07 cyclotruc