# CI/CD Workflow & Deployment Pipeline

To ensure the high availability, security, and stability of the NextGPU Hub, all codebase changes and infrastructure updates pass through a rigorous, automated Continuous Integration and Continuous Deployment (CI/CD) pipeline. This flow is designed to catch vulnerabilities early, maintain high code quality, and provide seamless updates across both staging and production environments.

1. **Version Control and Peer Review:** The development lifecycle begins in GitHub, where all source code is version-controlled. Developers push feature branches or bug fixes to isolated branches. To maintain strict quality standards, direct commits to the main deployment branches are restricted. A commit is only merged into the deployment pipeline after passing a comprehensive peer review process, ensuring that architectural integrity and security guidelines are upheld before any automated testing begins.
2. **Environment Isolation (Staging vs. Production):** NextGPU utilizes a dual-environment deployment strategy to safeguard the end-user experience. Code merges first trigger the **Staging Pipeline**, deploying the application to an isolated replica of the production environment. This allows the team to validate new features, conduct integration testing, and ensure stability without impacting live users. Only after a build is verified as stable in staging is it authorized for the **Production Pipeline**.
3. **Automated Integration and Quality Gates:** Upon a successful merge to either the staging or production branches, **Jenkins** automatically orchestrates the build and integration process. The Jenkins pipeline is responsible for:
   * **Automated Testing:** Executing the comprehensive suite of unit and integration tests (utilizing Jest for the frontend and JUnit for the backend).
   * **Static Code Analysis:** Passing the codebase to **SonarQube** to evaluate test coverage, identify code smells, and scan for security vulnerabilities.
   * **Quality Enforcement:** If SonarQube identifies critical issues or if test coverage falls below the required threshold, the build fails automatically. Developers must resolve these identified issues and push the fixes before the pipeline can proceed, acting as an automated quality gate.
4. **Containerization and Server Deployment:** Once the code successfully passes all tests and SonarQube quality gates, the pipeline initiates the deployment phase.
   * **Docker Containerization:** All application components—including the Web DApp, core backend services, and utilities—are packaged into isolated Docker containers. This ensures parity between the development, staging, and production environments.
   * **AWS Infrastructure:** The containerized applications are then securely deployed to our **AWS (Amazon Web Services)** infrastructure.
   * **Backend Execution:** Within the AWS environment, the Java-based backend services are deployed onto robust **Apache Tomcat** servers, providing a high-performance, secure runtime for the control plane's core logic.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://whitepaper.nextgpu.ai/infrastructure-and-devops/ci-cd-workflow-and-deployment-pipeline.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
