Skip to content

Feat/nginx service#73

Merged
NotYuSheng merged 12 commits into
devfrom
feat/nginx_service
Jun 26, 2025
Merged

Feat/nginx service#73
NotYuSheng merged 12 commits into
devfrom
feat/nginx_service

Conversation

@MingJ7

@MingJ7 MingJ7 commented Jun 24, 2025

Copy link
Copy Markdown
Collaborator

Summary

Fixes #71
This pull request adds a nginx container to the compose stack to act as gateway to the pdf processor, pdf extractor and chat services.

Changes Made

  • A new folder containing the nginx docker configuration has been made
  • Services (PDF processor, PDF extractor and chat) communicating through the nginx gateway have a root_path added to enable simple reverse proxy

Context / Rationale

This feature will allow for separation between frontend and backend. Allowing for changes in the backend architecture to be made without having to impact the frontend.


Related Docs or References


FastAPI Application Checklist

  • /health endpoint is implemented and returns 200 OK after relevant path (/processor, /extractor, .chat)
  • API schema (OpenAPI) is exposed and browsable at /docs or /redoc after relevant path (/processor, /extractor, .chat)

General Checklist

  • I have tested these changes locally
  • I have updated relevant documentation or added comments where needed
  • I have linked relevant issues and tagged reviewers
  • I have followed coding conventions and naming standards

@MingJ7 MingJ7 requested a review from NotYuSheng as a code owner June 24, 2025 08:56

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @MingJ7, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces an Nginx service into the Docker Compose stack, establishing it as a central gateway for the existing PDF processor, PDF extractor, and chat services. This change aims to enhance the separation between the frontend and backend, providing a unified and stable entry point for client applications and enabling greater flexibility for future backend architectural adjustments.

Highlights

  • New Nginx Gateway Service: A new nginx_service has been introduced into the docker-compose.yml file. This service is configured to build from a new nginx_service directory, expose port 80, and depend on the pdf_extraction, pdf_processor_service, and chat_service.
  • FastAPI Root Path Configuration: The FastAPI applications in chat_service/main.py, pdf_extraction_service/main.py, and pdf_processor_service/main.py have been updated to include a root_path parameter during their initialization (e.g., /chat, /extractor, /processor). This is crucial for these services to correctly handle requests when proxied by Nginx.
  • Nginx Configuration for Reverse Proxying: New Nginx configuration files (nginx_service/Dockerfile, nginx_service/example.env, nginx_service/nginx.conf.template) have been added. The nginx.conf.template sets up Nginx to act as a reverse proxy, routing requests to /processor/, /extractor/, and /chat/ paths to their respective backend services using environment variables for their URLs.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an Nginx service to act as a reverse proxy gateway for the backend services. The changes are well-structured, including a new Nginx configuration, Dockerfile, and updates to the FastAPI applications to work behind the proxy. I suggest enhancing the service startup order in docker-compose.yml with health checks, removing now-unnecessary exposed ports from backend services to improve security, improving the Nginx configuration to forward essential client information to the backend services, and a minor change to improve configuration consistency. Overall, this is a great addition that will improve the architecture.

Comment thread docker-compose.yml
Comment thread docker-compose.yml
Comment thread nginx_service/example.env
Comment thread nginx_service/nginx.conf.template Outdated
Comment thread nginx_service/nginx.conf.template Outdated
Comment thread nginx_service/nginx.conf.template
@MingJ7

MingJ7 commented Jun 25, 2025

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an Nginx service as a reverse proxy for the backend services. The changes in the FastAPI services to support this with root_path are correct. There's a critical issue in how requests are proxied, which would prevent the services from receiving requests correctly. A refactoring is suggested to improve the maintainability of the Nginx configuration file.

Comment thread nginx_service/nginx.conf.template
@MingJ7

MingJ7 commented Jun 25, 2025

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an Nginx container to act as a gateway for the backend services. I suggest adding the env_file to the pdf_extraction_service definition, adding healthchecks to the backend services, pinning the version of the base image in the Nginx Dockerfile, and simplifying the rewrite directives in the Nginx configuration. Also, rename the FastAPI app instances to better reflect the service they belong to.

Comment thread docker-compose.yml
Comment thread docker-compose.yml
Comment thread nginx_service/Dockerfile Outdated
Comment thread nginx_service/nginx.conf.template Outdated
@MingJ7

MingJ7 commented Jun 25, 2025

Copy link
Copy Markdown
Collaborator Author

@NotYuSheng Please review.

@NotYuSheng

NotYuSheng commented Jun 25, 2025

Copy link
Copy Markdown
Owner

@NotYuSheng Please review.

Review complete, please adjust the comments and request again @MingJ7

@NotYuSheng NotYuSheng left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjust please

Comment thread docker-compose.yml Outdated
Comment thread nginx_service/Dockerfile Outdated
Comment thread nginx_service/nginx.conf.template
Comment thread docker-compose.yml
@MingJ7

MingJ7 commented Jun 26, 2025

Copy link
Copy Markdown
Collaborator Author

@NotYuSheng Adjustments have been done

@NotYuSheng

Copy link
Copy Markdown
Owner

Approved, nice work

@NotYuSheng NotYuSheng merged commit 0158553 into dev Jun 26, 2025
2 checks passed
@NotYuSheng NotYuSheng deleted the feat/nginx_service branch June 26, 2025 03:30
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.

[Sub-Issue] Nginx reverse proxy

2 participants