# aibangjuxin/knowledge architecture

> Architecture diagram of the GitHub repository aibangjuxin/knowledge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aibangjuxin/knowledge
- Repository: https://github.com/aibangjuxin/knowledge

## Overview

##### Project type and purpose
- This is not a single deployable application but a **personal knowledge‐base** repository combined with a handful of small, demonstrator microservices (e.g. `api-service`) and code snippets.
- Its primary purpose is to store and organize your technical notes, scripts, demo apps, and reference architecture pieces for GCP/K8S/API Gateway patterns, plus one Python “api-service” microservice.

##### File structure
- Top‐level folders are organized by topic/domain (gcp/, k8s/, linux/, java/, nginx/, safe/, pipeline/, etc.).
- A small runnable component lives under `api-service/` (Dockerfile, Python main.py, K8s manifest).
- Markdown files are purely documentation; no monolithic codebase or UI front end.
- No build scripts or server code outside `api-service`.

##### Key insights from README
- Network flow template:
Client → Nginx → Kong Gateway (GW) → Kong Runtime (RT) → External API
- Core stack: GCP (GKE, BigQuery, Firestore, Secret Manager), Kubernetes, Kong, CI/CD pipelines, Airflow/Harbor.
- Responsibilities: build/optimize API platform, auto-release pipelines, API quota in Firestore, secure networking.

a. **Main components**
- Developer Workstation (VSCode, Neovim) + Git Repo
- CI/CD Pipeline (e.g. GitHub Actions, Cloud Build, Airflow)
- Container Registry (GAR / Harbor)
- GKE Cluster
- Ingress layer: NGINX Ingress or Google Load Balancer + Kong Gateway (control plane + data plane)
- Microservice(s): `api-service` pods
- Data stores: Firestore (API Quota), BigQuery (analytics), Cloud Storage (buckets)
- Security services: Secret Manager, Cloud Armor, internal DNS whitelist
- External APIs

b. **Relationships & data flow**
1. Developer pushes Markdown, Python code → Git
2. CI/CD picks up commit → builds Docker image → pushes to GAR → optionally scans image → deploys to GKE via kubectl/apply
3. GKE Ingress (GCLB or NGINX) routes HTTP(S) → Kong Gateway control plane routes to data plane → `api-service` pods
4. `api-service` interacts with Firestore (quota), BigQuery (logs/analytics), Cloud Storage
5. Cloud Armor protects ingress; Secret Manager supplies credentials to pods; Cloud DNS enforces white-list

c. **Architectural patterns**
- **Microservices**: single‐responsibility service for API platform
- **Infrastructure as Code**: deployment.yaml, Helm or kubectl manifests
- **GitOps/CICD**: git→build→deploy flow
- **API Gateway**: Kong for routing, security, rate-limiting
- **Zero-trust**: Secret Manager & DNS whitelist

d. **Key technologies**
- GKE (K8S)
- Kong Gateway (CP & DP)
- NGINX or GCLB Ingress
- Python + FastAPI/Flask (`api-service/main.py`)
- Docker & GAR
- Terraform or kubectl YAML (not in this repo, but implied by deployment.yaml)
- Firestore, BigQuery, Cloud Storage
- Cloud Armor, Secret Manager, Cloud DNS

##### Elements
- **Labels**: “Developer”, “CI/CD”, “Container Registry”, “GKE Cluster”, “Ingress (NGINX/GCLB)”, “Kong CP/DP”, “api-service Pod”, “Firestore”, “BigQuery”, “Cloud Storage”, “External API.”
- Grey documents for knowledge repo

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer and Repository
    subgraph "Developer & Repository"
        direction TB
        Dev["Developer Workstation"]:::compute
        Repo["Git Repository"]:::doc
    end

    Dev -->|"push code/markdown"| Repo

    %% CI/CD and Registry
    subgraph "CI/CD & Registry"
        direction TB
        CICD["CI/CD Pipeline"]:::compute
        Registry["Container Registry (GAR/Harbor)"]:::compute
    end

    Repo -->|"trigger build"| CICD
    CICD -->|"build image & push"| Registry

    click CICD "https://github.com/aibangjuxin/knowledge/tree/main/pipeline/"
    click Registry "https://github.com/aibangjuxin/knowledge/blob/main/gcp/gcr.md"

    %% GKE Cluster
    subgraph "GKE Cluster" 
        direction TB
        Ingress["Ingress (NGINX/GCLB)"]:::compute
        KongCP["Kong Control Plane"]:::compute
        KongDP["Kong Data Plane"]:::compute
        APIService["api-service Pod"]:::compute
    end

    Registry -->|"deploy image"| Ingress
    Ingress --> KongCP
    KongCP --> KongDP
    KongDP --> APIService

    click Ingress "https://github.com/aibangjuxin/knowledge/tree/main/nginx/"
    click KongCP "https://github.com/aibangjuxin/knowledge/blob/main/kong/cp-vs-dp.md"
    click KongDP "https://github.com/aibangjuxin/knowledge/tree/main/kong/"
    click APIService "https://github.com/aibangjuxin/knowledge/blob/main/api-service/main.py"

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        Firestore["Firestore (API Quota)"]:::data
        BigQuery["BigQuery (Analytics)"]:::data
        Storage["Cloud Storage"]:::data
    end

    APIService -->|"read/write quota"| Firestore
    APIService -->|"log analytics"| BigQuery
    APIService -->|"store blobs"| Storage

    click Firestore "https://github.com/aibangjuxin/knowledge/tree/main/gcp/firestore/"
    click BigQuery "https://github.com/aibangjuxin/knowledge/tree/main/gcp/bigquery/"
    click Storage "https://github.com/aibangjuxin/knowledge/tree/main/gcp/buckets/"

    %% Security Services
    subgraph "Security Services"
        direction TB
        Secrets["Secret Manager"]:::security
        Armor["Cloud Armor"]:::security
        DNS["Cloud DNS Whitelist"]:::security
    end

    Ingress --> Armor
    APIService --> Secrets
    Ingress --> DNS

    click Secrets "https://github.com/aibangjuxin/knowledge/tree/main/gcp/secret-manage/"
    click Armor "https://github.com/aibangjuxin/knowledge/tree/main/gcp/cloud-armor/"
    click DNS "https://github.com/aibangjuxin/knowledge/tree/main/dns/"

    %% External APIs
    ExternalAPI["External API"]:::external
    APIService -->|"outbound calls"| ExternalAPI

    classDef compute fill:#cce5ff,stroke:#004085,color:#004085;
    classDef data fill:#d4edda,stroke:#155724,color:#155724;
    classDef security fill:#fff3cd,stroke:#856404,color:#856404;
    classDef doc fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef external fill:#f8d7da,stroke:#721c24,color:#721c24;

    %% Knowledge Base Documentation
    subgraph "Personal Knowledge Base"
        direction TB
        KB["Documentation Repository"]:::doc
    end

    Dev -->|"edit docs"| KB
    click KB "https://github.com/aibangjuxin/knowledge/tree/main//"
```
