# sergimporto/personallibrary architecture

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

- Interactive diagram: https://gitdiagram.com/sergimporto/personallibrary
- Repository: https://github.com/sergimporto/personallibrary

## Overview

##### Project type and purpose
- This is a full-stack mobile application (“PersonalLibrary”) consisting of:
- An Android client app (Kotlin + Jetpack/AndroidX)
- A backend microservice (Python, likely Flask or FastAPI)
- A PostgreSQL database
- Kubernetes-based infrastructure (Docker, Helm charts)
- Observability stack (Prometheus & Grafana)
- CI/CD pipeline (CircleCI)
- Purpose: allow users to search books (via Google Books API), save them into a personal library, and manage them via the mobile app with data persisted on a backend.

##### File structure
- Top-level directories:
- “app” – Android application code (Activities, ViewModels, Retrofit client, UI, resources)
- “Backend API” – Kubernetes manifests, Helm charts, Dockerfile & Py code (main.py, requirements.txt) for the Python API service
- Infra-as-code artifacts: IngressController.yaml, namespace.yaml, ConfigMaps, PVC/PV, Service definitions, Helm charts under milibrary-charts for API, Postgres, and grafana-prometheus monitoring.
- CI/CD: .circleci/config.yml drives build/test/deploy.
- Build tools: Gradle (Kotlin DSL) for Android, Helm for K8s charts.

##### Extract architecture insights from the README
- The README only states “# PersonalLibrary,” but file tree shows the components.

##### Detail
- Helm chart artifacts as part of deployment automation.
- CI/CD flow: code commit → CircleCI → Docker image → Helm upgrade.
- Health-check endpoint and backup procedures (auto-start-library.sh, backup.yaml).

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Mobile App Layer
  subgraph "Mobile App (UI Layer)"
    style MobileApp fill:#D0E8FF,stroke:#02457A,stroke-width:1px
    AndroidClient["Android Client App"]:::UI
    Gradle["build.gradle.kts"]:::UI
    Manifest["AndroidManifest.xml"]:::UI
    UIVM["UI & ViewModels"]:::UI
    Retrofit["Retrofit Client"]:::UI
    GBService["GoogleBooksService"]:::UI
  end

  %% External Service
  GoogleBooksAPI["Google Books API"]:::external

  %% CI/CD Pipeline
  subgraph "CI/CD Pipeline"
    CircleCI["CircleCI (config.yml)"]:::cicd
    CircleBackup["Config Backup"]:::cicd
  end

  %% Kubernetes Cluster
  subgraph "Kubernetes Cluster"
    direction TB
    Ingress["Ingress Controller"]:::infra
    Namespace["Namespace"]:::infra

    subgraph "API Deployment"
      APIPod["API Pod (Python)"]:::API
      APIService["API Service (ClusterIP)"]:::API
    end

    subgraph "Postgres Deployment"
      PGPod["Postgres Pod"]:::data
      PGService["Postgres Service"]:::data
    end

    subgraph "Monitoring Pods"
      PromPod["Prometheus"]:::monitoring
      GrafPod["Grafana"]:::monitoring
    end
  end

  %% Helm Charts
  subgraph "Helm Charts (IaC)"
    APIChart["milibrary-api Chart"]:::infra
    PGChart["milibrary-postgres Chart"]:::infra
    MonChart["monitoring-stack Chart"]:::infra
  end

  %% Postgres Manifests
  subgraph "Postgres Manifests"
    PGConfig["ConfigMap"]:::infra
    PGDeployment["Deployment"]:::infra
    PGPV["PersistentVolume"]:::infra
    PGPVC["PersistentVolumeClaim"]:::infra
    PGSecret["Secret"]:::infra
    PGServiceCluster["Service (ClusterIP)"]:::infra
    PGServiceNode["Service (NodePort)"]:::infra
  end

  %% Backup & Startup Scripts
  subgraph "Backup & Startup"
    AutoStart["auto-start-library.sh"]:::infra
    BackupYAML["backup.yaml"]:::infra
  end

  %% Backend API Python Code
  subgraph "Backend API Service (Python)"
    APIpyDir["api-python/"]:::API
    Dockerfile["Dockerfile"]:::API
    LocalDeploy["api-local-deploy.yaml"]:::API
  end

  %% Relationships
  AndroidClient -->|HTTPS/REST| APIService
  APIService -->|routes to| APIPod
  APIPod -->|SQL| PGPod
  APIPod -->|calls| GoogleBooksAPI
  Ingress -->|forwards HTTP| APIService

  CircleCI -->|builds & pushes image| APIChart
  CircleCI -->|triggers deploy| PGChart
  CircleCI -->|triggers deploy| MonChart
  APIChart -->|deploys| APIPod
  PGChart -->|deploys| PGPod
  MonChart -->|deploys| PromPod
  MonChart -->|deploys| GrafPod

  PromPod -->|scrapes metrics from| APIPod
  PromPod -->|scrapes metrics from| PGPod
  GrafPod -->|queries| PromPod

  %% Click Events
  click AndroidClient "https://github.com/sergimporto/personallibrary/tree/main/app/"
  click Gradle "https://github.com/sergimporto/personallibrary/blob/main/app/build.gradle.kts"
  click Manifest "https://github.com/sergimporto/personallibrary/blob/main/app/src/main/AndroidManifest.xml"
  click UIVM "https://github.com/sergimporto/personallibrary/tree/main/app/src/main/java/com/example/milibrary/"
  click Retrofit "https://github.com/sergimporto/personallibrary/blob/main/app/src/main/java/com/example/milibrary/RetrofitClient.kt"
  click GBService "https://github.com/sergimporto/personallibrary/blob/main/app/src/main/java/com/example/milibrary/GoogleBooksService.kt"
  click GoogleBooksAPI "https://github.com/sergimporto/personallibrary/blob/main/app/src/main/java/com/example/milibrary/GoogleBooksService.kt"
  click CircleCI "https://github.com/sergimporto/personallibrary/blob/main/.circleci/config.yml"
  click CircleBackup "https://github.com/sergimporto/personallibrary/blob/main/.circleci/config.yml.backup"
  click Ingress "https://github.com/sergimporto/personallibrary/blob/main/Backend API/IngressController.yaml"
  click Namespace "https://github.com/sergimporto/personallibrary/blob/main/Backend API/k8s-milabrary/namespace.yaml"
  click APIpyDir "https://github.com/sergimporto/personallibrary/tree/main/Backend API/k8s-milabrary/api-python/"
  click Dockerfile "https://github.com/sergimporto/personallibrary/tree/main/Backend API/k8s-milabrary/api-python/Dockerfile"
  click LocalDeploy "https://github.com/sergimporto/personallibrary/blob/main/Backend API/k8s-milabrary/api-python/api-local-deploy.yaml"
  click PGConfig "https://github.com/sergimporto/personallibrary/blob/main/Backend API/k8s-milabrary/postgres-configmap.yaml"
  click PGDeployment "https://github.com/sergimporto/personallibrary/blob/main/Backend API/k8s-milabrary/postgres-deployment.yaml"
  click PGPV "https://github.com/sergimporto/personallibrary/blob/main/Backend API/k8s-milabrary/postgres-pv.yaml"
  click PGPVC "https://github.com/sergimporto/personallibrary/blob/main/Backend API/k8s-milabrary/postgres-pvc.yaml"
  click PGSecret "https://github.com/sergimporto/personallibrary/blob/main/Backend API/k8s-milabrary/postgres-secret.yaml"
  click PGServiceCluster "https://github.com/sergimporto/personallibrary/blob/main/Backend API/k8s-milabrary/postgres-service.yaml"
  click PGServiceNode "https://github.com/sergimporto/personallibrary/blob/main/Backend API/k8s-milabrary/postgres-service-nodeport.yaml"
  click APIChart "https://github.com/sergimporto/personallibrary/tree/main/Backend API/milibrary-charts/milibrary-api/"
  click PGChart "https://github.com/sergimporto/personallibrary/tree/main/Backend API/milibrary-charts/milibrary-postgres/"
  click MonChart "https://github.com/sergimporto/personallibrary/tree/main/Backend API/milibrary-charts/grafana-prometheus/monitoring-stack/"
  click AutoStart "https://github.com/sergimporto/personallibrary/blob/main/Backend API/k8s-milabrary/auto-start-library.sh"
  click BackupYAML "https://github.com/sergimporto/personallibrary/blob/main/Backend API/k8s-milabrary/backup.yaml"

  %% Styles
  classDef UI fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1;
  classDef API fill:#C8E6C9,stroke:#2E7D32,color:#2E7D32;
  classDef data fill:#FFE0B2,stroke:#EF6C00,color:#E65100;
  classDef infra fill:#F5F5F5,stroke:#9E9E9E,color:#616161;
  classDef monitoring fill:#FFF9C4,stroke:#F9A825,color:#F57F17;
  classDef cicd fill:#E1BEE7,stroke:#6A1B9A,color:#4A148C;
  classDef external fill:#FFCDD2,stroke:#B71C1C,color:#B71C1C;
```
