This project demonstrates the development and deployment of a cloud-native, serverless API designed to serve as a Generative AI-powered Network Log Analyzer. The core objective was to build an end-to-end, production-ready system that showcases expertise in modern software engineering and machine learning operations (MLOps).
The system architecture features a FastAPI backend that orchestrates the Gemini API via LangChain to process and summarize complex network logs. To ensure a robust and scalable solution, the application is containerized with Docker and deployed on Google Cloud Run, a serverless platform that aligns with cloud-native principles.
A key component of this project is the fully automated Continuous Integration (CI) pipeline, implemented with GitHub Actions. This workflow automatically runs linting and smoke tests, and publishes a Docker image to the GitHub Container Registry (GHCR) with every code change. Continuous Deployment (CD) to Cloud Run is a planned future enhancement.
This project goes beyond a simple proof of concept, serving as a comprehensive demonstration of skills in containerization, MLOps, CI/CD, and the application of Generative AI in a practical, real-world context.
Note: This repo currently implements a lightweight, serverless FastAPI service with modular plugins (connectors/detectors/analyzers). Spark/Flink are part of the future scale-out plan and are not implemented in this codebase yet.
- FastAPI API with
GET /,POST /ingest,POST /analyze,GET /plugins,GET /incidents,POST /search,GET /summary,GET /audit-trail - Modular plugin system via
ENABLED_CONNECTORS,ENABLED_DETECTORS,ENABLED_ANALYZERS - Plugin loading via
PLUGIN_MODULES(derived-image friendly) - Proactive detection (
error_spike) and incident store with attached analyzer outputs - Docker module sets (
MODULE_SET=minimal|full) for lightweight base images
graph TB
LogSources[" Log Sources<br/>(Network Devices, Apps, Firewalls)"]
Kafka[" Real-Time Ingestion<br/>(Apache Kafka) - Optional"]
FastAPI[" FastAPI /ingest"]
Enricher[" LogEnricher<br/>(PII redaction)"]
DeltaLake[" Storage<br/>(Delta Lake local)<br/>ACID-compliant"]
VectorDB[" Vector Database<br/>(Chroma local)<br/>Embeddings & Semantic Search"]
GenAI[" GenAI Analysis Engine<br/>(LangGraph + Gemini)"]
API[" API & Query Interface<br/>(FastAPI)"]
LogSources -->|Optional| Kafka
LogSources -->|Direct HTTP| FastAPI
Kafka -->|Stream data| FastAPI
FastAPI -->|Parse & filter| Enricher
Enricher -->|Store| DeltaLake
Enricher -->|Log embeddings| VectorDB
DeltaLake <-->|Queries| GenAI
VectorDB -->|Semantic search| GenAI
GenAI -->|Results & insights| API
(Note: See ARCHITECTURE.md for the planned future scale-out architecture featuring Spark/Flink and managed cloud services.)
- Modular DI: All core components (redactor, storage, vector store, engine) are injected via constructor with automatic null fallbacks.
- Scalable path: designed to scale out to Kafka + Spark/Flink for terabytes/day (future)
- Secure: PII masking, RBAC (via API Keys), and structured audit logging.
- Compliant: Append-only storage, audit trails, data lineage (banking/telecom)
- Intelligent: Natural language queries, anomaly detection, summarization via a LangGraph Agentic workflow.
- Serverless Ready: Designed for auto-scaling FastAPI on Cloud Run; minimal ops overhead
See ARCHITECTURE.md for detailed component responsibilities, data flow, scaling strategies, and security controls.
This project uses uv for lightning-fast dependency management.
uv sync
uv run python -m spacy download en_core_web_smCopy the example environment file and fill in your keys (a GEMINI_API_KEY is required for the LLM analyzer to work):
cp .env.example .envEnsure your .env has the necessary values:
GEMINI_API_KEY=your_key_here
LANGCHAIN_TRACING_V2=true
LANGCHAIN_API_KEY=your_langchain_api_key_here
KAFKA_BOOTSTRAP_SERVERS=localhost:9092
LOG_TOPIC=logs-raw
VECTOR_DB_TYPE=chroma
CHROMA_PATH=./data/chroma
DELTA_LAKE_PATH=./data/delta-lake
ENABLE_AUTH=false
API_KEYS_FILE=./api/api_keys.yamluv run uvicorn api.main:app --reloadThis project can be built as a single container image that clients can run locally and then deploy to Cloud Run.
The Dockerfile supports a module-set switch:
docker build -t genai-log-analyzer --build-arg MODULE_SET=minimal .MODULE_SET=minimal: boots the API with null fallbacks (no Kafka/vector/PII/LLM dependencies).MODULE_SET=full: includes the full dependency set.
The module-set requirements live under:
requirements/minimal.txtrequirements/full.txt
Modules are activated at runtime via env vars:
ENABLED_CONNECTORS:kafkaENABLED_DETECTORS:error_spikeENABLED_ANALYZERS:simple_summary
Plugin loading:
PLUGINS_DIR: directory added tosys.pathfor plugin modules (default:/app/plugins)PLUGIN_MODULES: comma-separated Python module names to import; each module may defineregister(registry)
Example (run detector + analyzer locally):
docker run -p 8001:8000 \
-e ENABLED_DETECTORS=error_spike \
-e ENABLED_ANALYZERS=simple_summary \
-e ERROR_SPIKE_THRESHOLD=5 \
genai-log-analyzerValidation endpoints:
GET /pluginsGET /incidents
The built-in error_spike detector raises an incident when it sees a spike of ERROR/CRITICAL logs.
Env vars:
ERROR_SPIKE_THRESHOLD: number of error events required to raise an incidentERROR_SPIKE_WINDOW_SECONDS: sliding window for counting errorsERROR_SPIKE_COOLDOWN_SECONDS: minimum seconds between incidents (dedup); set to0to disable cooldown
Analyzers run only when an incident is raised (to keep cost low). Enable them via ENABLED_ANALYZERS.
Built-ins:
simple_summary: lightweight deterministic summary (no external deps)gemini_triage: optional LLM triage output (requiresGEMINI_API_KEYand full deps)
Clients can extend the base image by building a derived image:
FROM genai-log-analyzer:latest
COPY client_plugins/ /app/plugins/
ENV PLUGIN_MODULES=client_plugin_entryThe module entry must expose a callable register(registry) function.
This repo includes an example plugin module you can load immediately:
plugins/example_client_module.py(registers analyzerclient_tag)
Run it locally:
docker run -p 8001:8000 \
-e ENABLED_DETECTORS=error_spike \
-e ENABLED_ANALYZERS=simple_summary,client_tag \
-e PLUGIN_MODULES=example_client_module \
-e ERROR_SPIKE_THRESHOLD=5 \
genai-log-analyzer- Local dev uses
pyproject.tomlviauv. - Docker builds use
requirements/<MODULE_SET>.txtto keep images lightweight.
The system uses a Profile-Driven Hybrid Redaction Engine. This allows it to adapt to different industries (Financial, Medical, etc.) without code changes.
Note
The included pii_profiles.yaml serves as a template and example. In a real production environment, this should be expanded with specialized patterns (SSNs, Passport IDs, etc.) relevant to the client's industry.
You can define entities, confidence thresholds, and custom Regex patterns in the profiles file:
profiles:
financial:
entities: ["CREDIT_CARD", "PHONE_NUMBER", "EMAIL_ADDRESS"]
custom_recognizers:
- name: "cc_pattern"
regex: "\\b(?:\\d[ -]*?){13,16}\\b"
score: 0.8Clients can inject their own PII rules at runtime using Docker volumes. No rebuilding required:
# docker-compose.yml example
services:
api:
volumes:
- ./my_custom_profiles.yaml:/app/processing/pii_profiles.yamlThe system includes an asynchronous Kafka consumer that processes logs at scale.
- Background Worker: Managed via FastAPI
lifespanevents. - Fail-Safe: The API remains operational even if the Kafka broker is offline (Graceful Degradation).
- Manual Ingestion: A
/ingestPOST endpoint is available for batch log uploads.
To test the consumer locally:
- Start Kafka via Docker:
docker compose up -d - Run the API (Consumer starts automatically):
uv run uvicorn api.main:app --reload
Run the included test suite to verify different profiles:
uv run test_redactor.py