Nen is a minimalist LLM framework built in Zig following the Nen way: statically typed, zero-allocation, and using the Nen ecosystem for maximum performance: designed for production-scale AI workflows.
- Just ~300 lines for the core framework (vs LangChain's 405K lines)
- Zero bloat, zero dependencies, zero vendor lock-in
- Everything you love: Agents, Workflows, RAG, and more
- Statically typed: Compile-time safety and optimization
- Zero-allocation: Static memory pools for predictable performance
- Nen ecosystem: Seamless integration with NenCache, NenDB, nen-io, nen-json
- Sub-microsecond latency: High-performance node execution
- High throughput: 1000+ flows per second
- Built-in caching: NenCache integration for performance
- Monitoring: Comprehensive metrics and observability
- Scalability: Handle millions of AI workflows
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Nen Core β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββ β
β β Agent β β Tool β β LLM β βMemoryβ β
β β Node β β Node β β Node β β Node β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββ β
β β Workflow β β RAG β β Condition β βParallelβ β
β β Node β β Node β β Node β β Node β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β Nen Ecosystem β
β Integration β
β β
β βββββββββββββ β
β β NenCache β β
β β Caching β β
β βββββββββββββ β
β β
β βββββββββββββ β
β β nen-io β β
β β Batching β β
β βββββββββββββ β
β β
β βββββββββββββ β
β β nen-json β β
β βSerializationβ β
β βββββββββββββ β
βββββββββββββββββββ
- Zig: 0.14.1 or later
- Memory: 4GB+ RAM (8GB+ recommended)
- Nen ecosystem: NenCache, nen-io, nen-json
# Clone the repository
git clone https://github.com/Nen-Co/nen.git
cd nen
# Build the project
zig build
# Run tests
zig build test
# Run examples
zig build basic-example
zig build agent-demo
zig build rag-demo
zig build workflow-demo
zig build nen-democonst std = @import("std");
const nen = @import("nen");
pub fn main() !void {
const allocator = std.heap.page_allocator;
// Create a simple agent flow
var flow = try nen.createAgentFlow(allocator, "Assistant",
"You are a helpful AI assistant.");
defer flow.deinit();
// Execute the flow
try flow.execute();
// Get execution statistics
const stats = flow.getStats();
std.debug.print("Success rate: {d:.1}%\n", .{stats.getSuccessRate() * 100.0});
}File: examples/basic_agent.zig
Command: zig build basic-example
Simple agent creation and execution.
File: examples/rag_demo.zig
Command: zig build rag-demo
Complete RAG workflow with query, retrieval, and generation.
File: examples/workflow_demo.zig
Command: zig build workflow-demo
Complex workflow orchestration with multiple steps.
File: examples/nen_demo.zig
Command: zig build nen-demo
Full showcase of all Nen capabilities.
The building blocks of Nen workflows:
- Agent Node: AI agents with instructions and tools
- Tool Node: Function execution and API calls
- LLM Node: Language model interactions
- Memory Node: Data storage and retrieval
- Workflow Node: Process orchestration
- RAG Node: Retrieval-augmented generation
- Condition Node: Conditional logic and branching
- Parallel Node: Parallel execution
- Stream Node: Streaming data processing
Workflow orchestration and execution:
- Dependency Management: Automatic node ordering
- Execution Engine: High-performance node execution
- Caching: Built-in NenCache integration
- Monitoring: Real-time metrics and observability
- Error Handling: Graceful failure and recovery
Flexible node and flow configuration:
- Timeouts: Configurable execution timeouts
- Retries: Automatic retry mechanisms
- Parallelism: Parallel execution support
- Caching: Per-node cache configuration
- Memory: Memory pool management
| Framework | Lines of Code | Size | Performance |
|---|---|---|---|
| Nen | ~300 | ~56KB | 1000+ flows/sec |
| LangChain | 405K | +166MB | ~100 flows/sec |
| CrewAI | 18K | +173MB | ~200 flows/sec |
| SmolAgent | 8K | +198MB | ~300 flows/sec |
| LangGraph | 37K | +51MB | ~150 flows/sec |
- Node Execution: Sub-microsecond latency
- Flow Throughput: 1000+ flows per second
- Memory Usage: Zero-allocation static pools
- Cache Hit Rate: 95%+ with NenCache integration
- Scalability: Linear scaling with additional resources
- High-performance caching: Sub-microsecond cache access
- Memory pools: Static allocation for zero overhead
- Multi-tier storage: GPU/CPU/NVMe/Disk optimization
- P2P sharing: Distributed caching between instances
- I/O optimization: Zero-allocation I/O patterns
- Batching: Efficient memory and network operations
- Streaming: High-performance data streaming
- Network operations: Optimized network communication
- Zero-allocation serialization: No dynamic memory allocation
- High-performance parsing: SIMD-optimized JSON handling
- Static memory pools: Predictable memory usage
- Type safety: Compile-time JSON validation
- Graph database acceleration: Cache graph queries
- LLM workload optimization: Store embeddings and tokens
- Distributed caching: P2P sharing between database instances
- High-throughput queries: 100K+ queries per second
# Build optimized version
zig build -Doptimize=ReleaseFast
# Configure environment
export NEN_CACHE_ENABLED=true
export NEN_MEMORY_POOLS=2GB
# Start service
./zig-out/bin/nen serveFROM ubuntu:22.04
RUN apt-get update && apt-get install -y build-essential curl
RUN curl -L https://ziglang.org/download/0.14.1/zig-linux-x86_64-0.14.1.tar.xz | tar -xJ -C /usr/local --strip-components=1
COPY . /app
WORKDIR /app
RUN zig build -Doptimize=ReleaseFast
EXPOSE 8080
CMD ["./zig-out/bin/nen", "serve"]apiVersion: apps/v1
kind: Deployment
metadata:
name: nen
spec:
replicas: 3
selector:
matchLabels:
app: nen
template:
metadata:
labels:
app: nen
spec:
containers:
- name: nen
image: nen:latest
ports:
- containerPort: 8080
resources:
requests:
memory: "4Gi"
cpu: "2"
limits:
memory: "8Gi"
cpu: "4"- Conversational AI: Chatbots and virtual assistants
- Task Automation: Automated workflow execution
- Decision Support: AI-powered decision making
- Content Generation: Automated content creation
- Document Q&A: Intelligent document search and answers
- Knowledge Bases: Corporate knowledge management
- Research Tools: Academic and scientific research
- Customer Support: Automated customer assistance
- Business Processes: Automated business workflows
- Data Pipelines: ETL and data processing
- DevOps Automation: CI/CD and deployment automation
- Quality Assurance: Automated testing and validation
- Real-time Systems: Low-latency AI applications
- High-throughput Processing: Batch AI processing
- Edge Computing: Resource-constrained environments
- Microservices: AI-powered microservice architectures
- Performance: Throughput, latency, success rate
- Memory: Pool utilization, allocation patterns
- Caching: Hit rate, cache efficiency
- Execution: Node completion, failure rates
# Check flow status
./zig-out/bin/nen --show-stats
./zig-out/bin/nen --show-memory
./zig-out/bin/nen --show-ecosystem
# Run performance tests
./zig-out/bin/nen --benchmark
./zig-out/bin/nen agent-demo
./zig-out/bin/nen rag-demo# Clone repository
git clone https://github.com/Nen-Co/nen.git
cd nen
# Install dependencies
# (Nen ecosystem libraries are included as submodules)
# Build project
zig build
# Run tests
zig build test
# Run specific examples
zig build basic-example
zig build agent-demo
zig build rag-demo
zig build workflow-demo
zig build nen-demo# Run all tests
zig build test
# Run performance benchmarks
zig build perf-bench
# Run specific integration tests
zig build nen-test
zig build agent-test
# Check code quality
zig build test --verbose- API Reference: Complete API documentation
- Architecture Guide: System design and architecture
- Performance Guide: Optimization and benchmarking
- Deployment Guide: Production deployment
- Examples: Comprehensive examples and tutorials
We welcome contributions! Please see our Contributing Guide for details.
- Performance Optimization: Improve throughput and reduce latency
- Node Types: Add new node types and capabilities
- LLM Integration: Add support for more LLM providers
- Monitoring: Enhance observability and metrics
- Documentation: Improve guides and examples
This project is licensed under the MIT License - see the LICENSE file for details.
- Zig Community: For the amazing programming language
- Nen Ecosystem Contributors: For building the foundation
- Pocket Flow Team: For inspiring the minimalist approach
- Open Source Community: For inspiration and collaboration
- GitHub Issues: Report bugs and request features
- Discussions: Join community discussions
- Documentation: Complete documentation
- Community: Nen ecosystem community
π Ready to build the future of AI workflows? Get started with Nen today!
The Nen ecosystem provides:
- Minimalist Design: Just ~300 lines for the core framework
- Zero Allocation: Static memory pools for predictable performance
- High Performance: 1000+ flows per second with sub-microsecond latency
- Production Ready: Comprehensive monitoring, caching, and deployment options
- Seamless Integration: Works perfectly with NenCache, NenDB, nen-io, and nen-json
Build AI workflows that scale to infinity with confidence! β¨
Nen is part of the larger Nen ecosystem, designed to work seamlessly with:
- nen-db: High-performance graph database
- nen-net: Zero-allocation networking
- nen-io: High-performance I/O operations
- nen-json: Fast JSON processing
- nen-cli: Unified command-line interface
Visit our comprehensive documentation at nen-co.github.io/docs