back to home

ZacSweers / metro

A multiplatform, compile-time dependency injection framework for Kotlin

View on GitHub
1,105 stars
86 forks
30 issues
KotlinShellJupyter Notebook

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing ZacSweers/metro in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/ZacSweers/metro)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

šŸš‡ Metro A compile-time dependency injection framework for Kotlin Multiplatform, powered by a Kotlin compiler plugin. --- What is Metro? Metro is a compile-time dependency injection framework that combines the best of Dagger, Anvil, and kotlin-inject into one cohesive solution. **Key Features:** • āœ… **Compile-time validation** – Catch dependency graph errors during compilation, not at runtime • 🧩 **FIR/IR code generation** – No KAPT or KSP required, just a Kotlin compiler plugin • šŸŽÆ **Kotlin-first API** – Inspired by kotlin-inject with top-level function injection and optional dependencies • šŸ—”ļø **Dagger-esque runtime** – Lean generated code with familiar patterns • āš’ļø **Anvil-style aggregation** – , , and more • 🌐 **Multiplatform** – Supports JVM, JS, WASM, and Native targets • šŸ’” **Helpful diagnostics** – Detailed error messages with actionable suggestions • šŸ”— **Advanced interop** – Migrate incrementally from Dagger, kotlin-inject, or Guice • āš”ļø **Fast** - At build time, at runtime --- Quick Start **1. Apply the Gradle plugin:** **2. Define a dependency graph:** **3. Create and use the graph:** --- Documentation šŸ“š **zacsweers.github.io/metro** | Topic | | |----------------------------------------------------------------------------------|------------------------------------------------| | Installation | Setup and configuration | | Dependency Graphs | Define and create graphs | | Provides | Provider functions and properties | | Injection Types | Constructor, assisted, and member injection | | Scopes | Scoping and lifecycle management | | Aggregation | Anvil-style contributions across modules | | Interop | Dagger, kotlin-inject, and Guice compatibility | | Performance | Build and runtime performance | | Compatibility | Supported Kotlin versions | | FAQ | Frequently asked questions | | API Docs | Generated KDocs | --- Supported Platforms Metro supports JVM, Android, JS, WASM, and Native targets. The compiler plugin works with all Kotlin Multiplatform project types. See the multiplatform docs for full details. --- License ------- Copyright (C) 2025 Zac Sweers Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.