0% found this document useful (0 votes)
2 views3 pages

Hello Backend Engineers

The document outlines the task of deploying a FastAPI application with a CI/CD pipeline using a provided template repository. Key requirements include implementing a specific API endpoint, setting up testing and deployment pipelines, and configuring Nginx as a reverse proxy. Submissions must include the base URL of the deployed application and the GitHub repository URL by the deadline of February 12, 2025.

Uploaded by

jay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Hello Backend Engineers

The document outlines the task of deploying a FastAPI application with a CI/CD pipeline using a provided template repository. Key requirements include implementing a specific API endpoint, setting up testing and deployment pipelines, and configuring Nginx as a reverse proxy. Submissions must include the base URL of the deployed application and the GitHub repository URL by the deadline of February 12, 2025.

Uploaded by

jay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Hello Backend Engineers....

Stage 2: Deploy a FastAPI Application


with CI/CD PipelineResources
●​ FastAPI Book Project Template:
https://github.com/hng12-devbotops/fastapi-book-project
●​ Use this repository as the starting point for your project.
●​ FastAPI Documentation: https://fastapi.tiangolo.com/
●​ Refer to the official FastAPI documentation for implementation details.
●​ Nginx Documentation: https://nginx.org/en/docs/
●​ Learn how to configure Nginx as a reverse proxy for your FastAPI application.
●​ GitHub Actions Documentation: https://docs.github.com/en/actions
●​ Use this to set up your CI/CD pipelines.

Task Description
Your task is to deploy a FastAPI application with a Continuous Integration (CI) and Continuous
Deployment (CD) pipeline. You will use an existing template repository, add a missing endpoint,
set up a test pipeline, and configure the deployment process. Your application should be served
using Nginx.Get Started

1.​ Use the FastAPI Book Project Template:


2.​ Fork the FastAPI Book Project Template repository. This will serve as the starting point
for your project.
3.​ Run the Project Locally:
4.​ Follow the steps in the repository's README.md to set up and run the project locally.
This will help you understand the existing codebase and prepare for the tasks ahead.

Requirements
1. Implement the Missing Endpoint

●​ Endpoint: /api/v1/books/{book_id}
●​ Functionality:
○​ Retrieve a book by its ID.
○​ Return a JSON response containing the book details.
○​ If the book does not exist, return a 404 Not Found response.
●​ Constraints:
○​ Do not delete any books from the database.
○​ Do not modify main.py.

2. Set Up the CI Pipeline

●​ Trigger: The workflow should run on pull requests to the main branch.
●​ Job Name: test
●​ Actions:
○​ Run pytest to execute the existing tests.
○​ Fail if there are issues in the application.
○​ Succeed if the application passes all tests.

3. Set Up the Deployment Pipeline

●​ Trigger: The workflow should run on merging a pull request to the main branch.
●​ Job Name: deploy
●​ Actions:
○​ Automatically update the deployed api with the latest changes.

4. Serve the Application Over Nginx

●​ Configuration:
○​ Use Nginx as a reverse proxy for the FastAPI application.
○​ Ensure API requests are correctly handled by the FastAPI backend.

5. Repository Access Requirement

●​ Collaborator: Invite the hng12-devbotops GitHub account as a collaborator to your


repository before submission.

API Specification
Endpoint

●​ Method: GET
●​ URL: /api/v1/books/{book_id}
●​ Parameters: book_id (integer)

Response Formats

●​ 200 OK: Returns JSON with the book details.


●​ 404 Not Found: Returns an error if the book does not exist.
●​ {
●​ "detail": "Book not found"
●​ }
●​

Acceptance Criteria
Functionality

●​ The API must:


○​ Retrieve a book by its ID.
○​ Return the correct JSON response.
○​ Handle invalid book IDs with a 404 Not Found response
CI/CD Setup

●​ The CI pipeline must:


○​ Run pytest on pull requests to the main branch.
○​ Fail if tests do not pass.
●​ The CD pipeline must:
○​ Automatically deploy the application on merging to the main branch.

Deployment

●​ The application must:


○​ Be publicly accessible.
○​ Be served using Nginx as a reverse proxy.

Documentation

●​ The repository must:


○​ Include a well-structured README.md.
○​ Provide setup and deployment instructions.

Submission Mode

●​ Double-check all requirements and acceptance criteria.


●​ Test your API thoroughly before submission.
●​ Thoroughly review your work to ensure accuracy, functionality, and adherence to the
specified guidelines before you submit it.

Submit your solution in your stage two slack channel #stage-two-backend using the
/submit command.Provide the following:

1.​ The base URL of your deployed application (without any paths or endpoints).
2.​ Your GitHub repository URL (without .git at the end).

Submission Deadline
The deadline for submissions is 12th February 2025, 11:59 PM WAT (GMT +1). Late
submissions will not be entertained.Additional Notes

●​ Evaluation Criteria:
○​ Correctness of the API implementation.
○​ Proper setup of CI/CD pipelines.
○​ Successful deployment and Nginx integration.
●​ Retry Policy: If you fail all 3 attempts, you’ll get another chance in HNG13.

You might also like