This repository follows a monorepo structure for managing multiple FastAPI microservices with a shared common utilities library. Each service can be developed, built, and deployed independently to Google Cloud Run using GitHub Actions.
/
├── .github/
│ └── workflows/ # GitHub Actions CI/CD pipelines
│ └── deploy-service-a.yml # Deployment workflow for Gemini Pro API
│ └── deploy-service-b.yml # Deployment workflow for Med-Gemma API
│
├── common/ # Shared code used by all services
│ ├── common_utils/ # Package: common-utils
│ │ ├── __init__.py
│ │ └── helpers.py # Example: get_timestamp() helper
│ └── setup.py # Makes 'common-utils' installable
│
├── gemini-pro-api/ # Service A: Gemini Pro API
│ ├── main.py # FastAPI app entrypoint
│ ├── requirements.txt # Includes -e ../common
│ └── Dockerfile # Builds image and installs common package
│
└── med-gemma-api/ # Service B: Med-Gemma API
├── main.py # FastAPI app entrypoint
├── requirements.txt # Includes -e ../common
└── Dockerfile # Builds image and installs common package
-
Contains
common-utilspackage. -
Installed in development using:
pip install -e common
-
In Docker builds, installed with:
pip install /app/common
- Gemini Pro API (Service A) →
gemini-pro-api/ - Med-Gemma API (Service B) →
med-gemma-api/ - Each has its own requirements.txt and Dockerfile.
- Both services can be deployed independently to Cloud Run.
-
Located in
.github/workflows/. -
Workflows are path-aware:
deploy-service-a.ymlruns ifgemini-pro-api/**ORcommon/**changes.deploy-service-b.ymlruns ifmed-gemma-api/**ORcommon/**changes.
-
Workflow steps:
- Checkout repository.
- Authenticate with Google Cloud using
GCP_CREDENTIALS. - Build Docker image (context = repo root, so
common/is included). - Push image to Google Artifact Registry.
- Deploy image to Cloud Run (
service-a-instanceorservice-b-instance).
Each workflow uses GitHub secrets:
GCP_PROJECT_ID→ Your GCP project ID.GCP_CREDENTIALS→ JSON key of a service account with deploy permissions.GCP_REGION→ Deployment region (e.g.us-central1).
-
Services run with Uvicorn on port 8080:
uvicorn main:app --host 0.0.0.0 --port 8080
-
Cloud Run automatically maps external requests to this port.
graph TD
%% Shared Common Code
subgraph SUDSS-APIS
B[gemini-pro-api/ <br> Service A]
C[med-gemma-api/ <br> Service B]
D[future-service-1/]
E[future-service-2/]
end
%% GitHub Branches
subgraph GitHub["GitHub Branches"]
F[develop]
G[main]
end
%% Current Service Workflow Paths
B -->|PR Merge| F
C -->|PR Merge| F
D -->|PR Merge| F
E -->|PR Merge| F
F -->|CI/CD Workflow| H[Cloud Run: Staging Deployment]
F -->|PR Merge| G
G -->|CI/CD Workflow| I[VM: Production Deployment]
%% Deployment Targets
subgraph Deployment["Deployment Targets"]
H
I
end
- Monorepo structure keeps shared code and multiple services in sync.
- Common utilities are reusable across services.
- Independent deployments: changes to one service (or shared code) trigger only the relevant workflow.
- Google Cloud Run hosts each service separately with containerized builds.