How uber/needle works
Project type and purpose
• From the file tree and README, “Needle” is neither a front-end nor back-end web app but a Swift dependency-injection framework plus a code generator CLI.
• Two major deliverables:
– The runtime framework (NeedleFoundation under Sources/NeedleFoundation) that ships as a Carthage/SwiftPM/CocoaPods dependency.
– The code‐generation tool (Generator directory) which parses your Swift code, builds an internal dependency graph, and emits Swift files for compile‐time‐safe DI.
• Sample consumer apps under Sample/… demonstrate integration with MVC, MVVM, and pluginized architectures.
File structure
Top-level:
• CI / housekeeping (.github, Makefile, configs)
• Documentation (API.md, GENERATOR.md, WHY_DI.md, Documents/ko_KR)
• Generator project (Generator/…)
• Foundation runtime (Sources/NeedleFoundation/…)
• Tests for both runtime (Tests/NeedleFoundationTests) and framework‐specific test helpers (Tests/NeedleFoundationTestTests)
• Sample apps illustrating use cases (Sample/MVC, Sample/Pluginized, Sample/SwiftUI-MVVM)
Key architectural indicators:
• Generator/Sources/NeedleFramework/Parsing/* – parses Swift source into an AST.
• Generator/Sources/NeedleFramework/Models/* – transforms AST into an internal dependency‐graph model.
• Generator/Sources/NeedleFramework/Generating/* – serializes the graph into Swift code (providers, registrations).
• Sources/NeedleFoundation/Internal & Pluginized/Internal – runtime registries that hook into the generated code.
README for additional insights
• Calls out two steps: integrate the code generator, then write DI code using Foundation’s API.
• Highlights compile-time safety via code gen, and hierarchical component‐protocol pattern.
• Mentions external tools/libraries: SwiftSyntax / SourceKitten for parsing, Homebrew/Carthage/SwiftPM for distribution.
Elements
• Clear labels: e.g., “Parsing Module”, “Model Module”, “Serializer Module”, “Runtime Registry”
– Blue for generator‐time components
– Green for runtime framework
– Orange for client application
– Gray for external libraries/services
– Rectangles for modules
– Cloud/hexagon for third‐party dependencies