Skip to content

marcosfpina/pina

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Marcos Ferreira

Engineering Manager | Systems Architect | Security Engineering Leader

Email LinkedIn GitHub

Building production-grade AI infrastructure with security-first design.
25 repositories β€’ 50K+ lines across Python, Rust, Go, TypeScript β€’ 100% Nix-reproducible


🎯 Engineering Philosophy

Architecture is an asset. Code is a liability.

I architect systems that scale, teams that ship, and platforms that endure. My work spans:

  • AI/ML Infrastructure: RAG platforms, document intelligence, LLM orchestration with cost optimization
  • Security Engineering: Zero-trust gateways, threat hunting, DevSecOps pipelines with automated scanning
  • Distributed Systems: Event-driven microservices, durable workflows, comprehensive observability
  • Infrastructure as Code: 23/25 repos with Nix flakes for hermetic reproducibility and declarative deployments

I don't just "use" toolsβ€”I dissect and rebuild them. My focus is on hermetic infrastructure, durable execution, and defense-in-depth. I specialize in translating complex distributed patterns (Circuit Breakers, Event Sourcing, Vector Similarity) into production-grade implementations that survive crashes, resist attacks, and explain themselves.


πŸ—οΈ Flagship Projects

1. Cerebro β€” Enterprise Codebase Intelligence Platform

Reduced onboarding time by 50% with AST-powered RAG for 500K LOC repositories

Impact:

  • πŸš€ 50% reduction in developer onboarding time (semantic search vs. grep)
  • πŸ”’ Automated security audits detecting hardcoded secrets, unsafe patterns, and vulnerabilities
  • πŸ’° $100-300 GCP credit optimization via batch processing + circuit breakers for Vertex AI rate limits

Architecture: Dependency injection for LLM/vector store flexibility | Hybrid local (ChromaDB) β†’ cloud (Vertex AI) migration path | Polyglot AST analysis (Python, JS/TS, Rust, Go, C/C++) via Tree-Sitter | GitLab CI/CD 5-stage pipeline (validate β†’ test β†’ build β†’ deploy β†’ monitor)

Stack: Python 3.13 Vertex AI LangChain ChromaDB FastAPI GitLab CI/CD Nix

Key Technical Decision: Provider Abstraction Pattern
class RigorousRAGEngine:
    def __init__(
        self,
        llm_provider: Optional[LLMProvider] = None,
        vector_store_provider: Optional[VectorStoreProvider] = None,
    ):
        # Dependency injection enables testing + vendor flexibility
        if llm_provider is None:
            self.llm_provider = VertexAILLMProvider(...)
        else:
            self.llm_provider = llm_provider

Why this matters:

  • Testability via mock providers (unit tests without API costs)
  • Cloud vendor flexibility (Vertex AI β†’ OpenAI swap without core changes)
  • SOLID principles (Dependency Inversion for maintainability)
  • Developer experience focus with local CI pipeline (just ci-local)

Business Impact: Batch processing respects 250-doc/batch Vertex AI limits with real-time credit monitoring, preventing cost overruns during trial periods. Parallel query execution with VRAM awareness optimizes resource utilization.

Repository: cerebro | SLOC: 4,085 Python


2. Phantom β€” Production ML Document Intelligence Framework

12.6k SLOC ML framework with real-time VRAM throttling and 78% test coverage

Impact:

  • ⚑ 60,000 queries/min on FAISS vector search (P95: 1ms latency)
  • 🧠 Resource-aware inference with nvidia-smi polling and 512MB threshold throttling
  • βœ… 78% test coverage with production-grade CI/CD (Nix + Crane for incremental Rust builds)
  • πŸ”’ OpenSSF Security Scorecard 7.8/10 with pre-commit hooks (Bandit, detect-secrets)

Architecture: VRAM throttling state machine (Idle β†’ Monitoring β†’ Processing β†’ Throttled) | Polyglot design (Python ML + Rust Tauri desktop + FastAPI) | Nix + Crane for incremental builds | Local-first LLM inference with llama.cpp (no API dependencies)

Stack: Python 3.13 llama.cpp FAISS sentence-transformers Rust/Tauri FastAPI Nix+Crane

Key Technical Decision: Incremental Rust Builds with Crane
checks = {
  # Security audit against RustSec advisory database
  cortex-desktop-audit = craneLib.cargoAudit {
    inherit src advisory-db;
  };

  # Zero-tolerance linting (deny warnings)
  cortex-desktop-clippy = craneLib.cargoClippy (
    cargoClippyExtraArgs = "--all-features --workspace -- --deny warnings"
  );

  # Comprehensive test suite
  cortex-desktop-tests = craneLib.cargoNexttest (...)
}

Why this matters:

  • Crane enables incremental builds (faster CI than standard cargo build)
  • Automated security audits against RustSec advisory database in CI gates
  • Multi-language CI (Python + Rust) orchestrated in single Nix flake
  • 372-line Justfile for comprehensive developer tooling (vs. minimal automation)

Developer Experience: Engineers can run just ci-full locally to validate before pushing, with identical results to CI due to Nix hermetic environments.

Performance Benchmarks:

Operation Throughput Latency (P95)
Document Chunking 2,000 docs/min 45ms
LLM Classification (GPU) 28 docs/min 2.8s
Vector Embedding 333 docs/min 180ms
FAISS Search (10k docs) 60,000 queries/min 1ms

Repository: phantom | SLOC: 12,667 Python + Rust | Coverage: 78%


3. SecureLLM-Bridge β€” Zero-Trust Gateway for Enterprise LLM Orchestration

5-layer defense-in-depth architecture for multi-provider GenAI routing

Impact:

  • πŸ” Enterprise security with mTLS client certs, token-bucket rate limiting, and PII redaction pipeline
  • πŸ“Š Comprehensive audit trails with 90-day structured JSON logs and immutable retention policies
  • 🌐 Multi-provider support (DeepSeek, OpenAI, Anthropic, Ollama) via unified async trait abstraction
  • βš–οΈ Dual-licensed (MIT/Apache-2.0) for enterprise adoption and compliance requirements

Architecture: Cargo workspace (5 crates: core, security, providers, cli, api-server) | Provider trait abstraction with async-trait for health checks | 5-layer defense: mTLS β†’ Rate Limiting β†’ Input Validation β†’ Audit Logging β†’ Process Sandboxing

Stack: Rust 1.80+ Tokio rustls argon2 governor SQLite/Redis OpenTelemetry Nix

Security Architecture Deep Dive

Threat Model: Zero-trust LLM access for multi-tenant environments with untrusted users

Defense Layers:

  1. mTLS (Layer 1): Client certificate validation for mutual TLS authentication
  2. Rate Limiting (Layer 2): Token-bucket algorithm per tenant (configurable QPS)
  3. Input Validation (Layer 3): OWASP-compliant sanitization (XSS, SQL injection prevention)
  4. Audit Logging (Layer 4): Structured JSON logs with PII redaction regex pipeline
  5. Process Sandboxing (Layer 5): Runtime isolation for provider plugins

Compliance Readiness:

  • SOC 2 Type II ready with 90-day audit retention and immutable append-only logs
  • Integration with platform keyrings for secret management (avoiding plaintext credentials)
  • Planned features: VPC support, GitLab Secret Manager integration, SBOM generation
/// Unified provider abstraction for testability and vendor flexibility
#[async_trait]
pub trait LLMProvider {
    async fn send_request(&self, prompt: String) -> Result<String>;
    async fn health_check(&self) -> Result<()>;
    fn capabilities(&self) -> ProviderCapabilities;
}

Strategic Value: Designed before vendor solutions existed, demonstrating foresight in GenAI security challenges. The provider abstraction enables A/B testing across LLM vendors and cost optimization via dynamic routing.

Repository: securellm-bridge | SLOC: 4,744 Rust | License: MIT/Apache-2.0


4. Spider-Nix β€” Enterprise OSINT Platform with Production DevSecOps Pipeline

Automated security scanning (SAST, dependency audit, secret detection) running weekly

Impact:

  • πŸ›‘οΈ Multi-layer security pipeline with Bandit (SAST), Safety/pip-audit (CVE), Gitleaks (secrets)
  • πŸ§ͺ Matrix testing across Python 3.11-3.13 with coverage tracking and Codecov integration
  • πŸ•·οΈ 20 OSINT modules across 6 categories (DNS, WHOIS, port scanning, vulnerability assessment, integrations)
  • 🎭 Anti-detection engineering with canvas fingerprinting spoofing and WebGL manipulation

Architecture: Layered async design (httpx for speed, Playwright for JS-heavy sites) | 4 proxy rotation strategies (round-robin, random, weighted, health-based) | 63 test cases with comprehensive edge-case coverage | Weekly cron security monitoring (Mondays 00:00 UTC)

Stack: Python 3.13 httpx Playwright pytest-asyncio Ruff Bandit GitHub Actions Nix

CI/CD Excellence: Multi-Stage Security Pipeline

GitHub Actions Workflows:

  1. Lint (Ruff) - Fast fail on code quality violations
  2. Typecheck (mypy) - Static typing discipline enforcement
  3. Matrix Testing - Python 3.11/3.12/3.13 in parallel (compatibility validation)
  4. SAST (Bandit) - Python-specific vulnerability scanning
  5. Dependency Scanning (Safety + pip-audit) - CVE detection against NVD database
  6. Secret Scanning (Gitleaks) - Prevent credential leaks to git history
  7. Weekly Cron - Automated security monitoring (zero-day vulnerability detection)

Software Supply Chain Security:

# Example: Multi-scanner dependency audit
- name: Security Audit
  run: |
    safety check --json  # PyPI vulnerability database
    pip-audit --format json  # NVD CVE cross-reference
    bandit -r src/ --format json  # SAST for Python

Leadership Signal:

  • DevSecOps maturity with shift-left security (catching issues before production)
  • Proactive threat detection via weekly automated scans (not reactive)
  • Modern Python best practices (async/await, Pydantic validation, type hints throughout)

Repository: spider-nix | SLOC: 4,638 Python | Tests: 63 cases


5. SecureLLM-MCP β€” Production Model Context Protocol Server

Enterprise AI Gateway with custom semantic cache and circuit breaker patterns

Role: Architect & Lead Developer | Stack: TypeScript, SQLite (WAL), NixOS, Prometheus

A production-hardened implementation of the Model Context Protocol. Unlike standard wrappers, this server implements core distributed systems primitives from scratch.

Key Features:

  • Custom Semantic Cache Engine (src/middleware/semantic-cache.ts): Implemented vector similarity search using raw Float32Array operations and cosine similarity logic, bypassing heavy vector DB dependencies. Features a deterministic character-frequency fallback for CPU-only environments.
  • Resiliency Patterns: Built a stateful Circuit Breaker (src/middleware/circuit-breaker.ts) with half-open states and exponential backoff to protect downstream LLM providers from cascading failures.
  • Concurrency Control: Utilized Mutex locks for thread-safe SQLite statistics updates during high-throughput concurrent tool execution.

Impact: Reduced LLM tool execution costs by 50-70% via custom semantic caching logic, achieving sub-millisecond cache lookups with deterministic fallback for resource-constrained environments.

Repository: securellm-mcp


6. Neutron β€” Durable ML Orchestration with Temporal.io

Adaptive machine learning pipeline rejecting static DAGs for code-first durable workflows

Role: Systems Architect | Stack: Python, Temporal.io, Ray, DSPy

An adaptive machine learning pipeline that rejects static DAGs (Airflow) in favor of durable, code-first workflows.

Key Features:

  • Durable Execution: Leveraged temporalio decorators (@workflow.defn) to maintain pipeline state across worker crashes. The system can resume a multi-day training run exactly where it left off, persisting stack traces and local variables.
  • Agentic Optimization: Integrated DSPy adapters (dspy_adapter.py) to programmatically optimize prompt weights using a Bayesian signature optimizer, bridging the gap between "prompt engineering" and "software engineering".
  • Hybrid Compute: Orchestrates stateful actors on a Ray cluster for heavy GPU lifting while maintaining control flow in lightweight Temporal workers.

Impact: Maintains pipeline state across worker crashes, enabling multi-day training runs with exact resumption. Hybrid compute architecture optimizes cost by separating GPU-intensive operations from coordination logic.

Repository: neutron


πŸ”§ Infrastructure & Systems Engineering

NixOS-Hyperlab β€” Declarative Datacenter Infrastructure

226-module virtualization platform with 100% reproducible builds

A 226-module monorepo enforcing 100% reproducibility from the kernel up.

Key Features:

  • Layered OCI Builds: Replaced standard Docker builds with nix2container, implementing custom layering strategy separating runtime dependencies from application code, reducing CI/CD push times by ~80%
  • Modular Architecture: Decoupled module system (ai-stack.nix, gpu-compute.nix) allowing hot-swappable capability injection into host configurations
  • VFIO/IOMMU GPU Passthrough: Declarative KVM configuration for near-native GPU performance in Windows/macOS guests, managed entirely through Nix expressions

Impact: Accelerated OCI container builds from minutes to seconds using Nix store layer optimization. Achieved 100/100 security score on infrastructure audits through immutable root filesystems and declarative AppArmor profiles.

Stack: Nix QEMU/KVM VFIO nix2container Arion

Repository: nixos-hyperlab


Spectre β€” Event-Driven Microservices Framework

30+ typed NATS events with multi-repo architecture for team autonomy

Key Features:

  • Event Schema Versioning: 30+ typed event schemas with version control (e.g., llm.request.v1, system.metrics.v1, cost.incurred.v1)
  • Zero-Trust Gateway: Security-first design with secret rotation engine and audit trails
  • Observability Stack: TimescaleDB for time-series metrics + Neo4j for service dependency graphs
  • Multi-Repo Strategy: Separate repositories for domain services (core infra vs. 12 services) enabling team autonomy and blast radius reduction

Architecture: Rust core with polyglot domain services (Python/Go) | All services communicate via NATS message bus | Bounded contexts with clear ownership | Phase 0 foundation (greenfield architecture)

Stack: Rust NATS Tokio Axum TimescaleDB Neo4j Prometheus

Event-Driven Architecture Pattern
/// All events follow: <category>.<action>.v<version>
/// Examples:
/// - llm.request.v1 / llm.response.v1
/// - system.metrics.v1
/// - cost.incurred.v1 (FinOps tracking)
/// - governance.proposal.v1
pub enum EventType {
    SystemMetrics,
    LlmRequest,
    CostIncurred,
    GovernanceProposal,
}

Leadership Signal:

  • Team autonomy via separate repos (each service team owns release cadence)
  • Blast radius reduction (bug in one service β‰  fleet-wide deployment)
  • Type safety via Rust's compile-time event validation
  • Self-documenting architecture (event names describe system behavior)

Repository: spectre


Vmctl β€” CLI-First QEMU VM Manager

930 LOC direct QEMU interface - choosing simplicity over libvirt complexity

Philosophy: "Less is more" engineering judgment

Key Features:

  • Architectural Restraint: Chose NOT to use libvirt, recognizing abstraction layers can add more complexity than value for simple VM management
  • Dual Interface Design: CLI-first for power users + optional GTK4 GUI for discoverability
  • VirtioFS Support: Modern QEMU features for fast host-guest file sharing with performance optimization
  • TOML Configuration: Human-readable, version-controllable VM definitions

Leadership Signal: Demonstrates engineering judgment and total cost of ownership thinking. 930 LOC means this tool will still work in 5 years with minimal maintenance. Shows ability to resist over-engineering.

Stack: Go 1.22 QEMU GTK4 Nix

Repository: vmctl


πŸ›‘οΈ Security Research & Tooling

Phishyx β€” Email Threat Hunting Platform

CERT-Polska Artemis integration for enterprise malware analysis

Key Features:

  • DKIM/DMARC Verification: Email authentication protocol validation engine
  • Microsoft Graph API: Office 365/Exchange integration for enterprise email systems
  • Karton Distributed Processing: Scalable malware analysis via CERT-Polska's distributed task framework
  • YARA Pattern Matching: Signature-based detection with cryptographic hash verification (SHA256)

Architecture: FastAPI REST API | SQLAlchemy 2.0 async with dual driver support (PostgreSQL for production, SQLite for testing) | Designed for isolated VM deployment (security boundary enforcement)

Leadership Signal: Security research depth with awareness of professional malware analysis tooling (Artemis framework). Demonstrates ability to integrate with enterprise email systems and CERT-level workflows.

Stack: Python 3.11+ FastAPI SQLAlchemy Karton YARA Microsoft Graph API

Repository: phishyx


🧰 Developer Experience & Tooling

Arch-Analyzer β€” Architecture Documentation Automation

Generate architecture trees and dependency graphs from codebase structure

Philosophy: Documentation-as-code for maintaining accurate technical documentation

Key Features: Automated architecture tree generation | Dependency graph visualization | Nix-based reproducible analysis environment

Stack: Nix Python Bash

Repository: arch-analyzer


Phantom-Stack β€” Full-Stack AI Application Template

Complete AI/web stack with Python backend, Docker, GitLab CI integration

Key Features: End-to-end ownership from frontend to ML backend | Docker-based deployment | GitLab CI/CD automation | Production-ready template for rapid prototyping

Stack: Python FastAPI Docker GitLab CI Nix

Repository: phantom-stack


MLX-Coda β€” Code Generation Assistant

MLX-powered code assistance with modern web-based UI

Key Features: AI-augmented developer tooling | Modern web interface with Vite | MLX framework integration | Real-time code generation

Stack: JavaScript/Node MLX Vite Nix

Repository: mlx-coda


πŸ“ˆ Technology Landscape

Domain Technologies Featured Projects
AI/ML Vertex AI, llama.cpp, LangChain, FAISS, ChromaDB, DSPy, MLX Cerebro, Phantom, Neutron, MLX-Coda
Languages Python, Rust, Go, TypeScript, Nix 25/25 repositories
Infrastructure Nix, Docker, QEMU/KVM, Temporal.io, Ray NixOS-Hyperlab, Vmctl, Neutron
Security mTLS, YARA, Bandit, Gitleaks, Zero-Trust SecureLLM-Bridge, Spider-Nix, Phishyx
Distributed NATS, TimescaleDB, Neo4j, async/await Spectre, Phantom, Spider-Nix
CI/CD GitHub Actions, GitLab CI, Nix Flakes, Crane All projects (23/25 with flakes)

πŸ’Ό Portfolio Metrics

  • 25 Active Repositories (all with commits in last 3 months)
  • 50,000+ Lines of Code across Python (10 repos), Rust (5 repos), Go, TypeScript
  • 92% Documentation Rate (23/25 repos with comprehensive READMEs)
  • 100% Reproducibility (23/25 repos with Nix flakes for hermetic builds)
  • Production-Grade CI/CD (automated testing, security scanning, coverage tracking)

Representative Metrics:

  • πŸš€ 50% onboarding time reduction (Cerebro semantic search)
  • πŸ’° $100-300 GCP credit optimization (Cerebro batch processing)
  • ⚑ 60,000 queries/min FAISS search performance (Phantom)
  • βœ… 78% test coverage with production CI/CD (Phantom)
  • πŸ”’ OpenSSF Security Scorecard 7.8/10 (Phantom)
  • πŸ›‘οΈ 5-layer defense-in-depth security architecture (SecureLLM-Bridge)
  • πŸ§ͺ Matrix testing Python 3.11-3.13 (Spider-Nix)
  • πŸ“¦ 80% CI/CD acceleration via Nix layer optimization (NixOS-Hyperlab)

🀝 Connect


All projects built on NixOS for reproducible, declarative infrastructure. Open source with enterprise-grade engineering practices.

About

Declarative Infrastructure-as-Code (IaC) managing hardened systems. Features atomic rollbacks, SBOM generation for supply chain security, and reproducible development environments.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors