MaxSvargal

MaxSvargal

Foundry - The Anti-Entropy Development Environment for Platforms and AI-Driven Engineering

For the past two years, I’ve been obsessed with a technical problem: **How do we effectively use LLMs to engineer, manage, and scale complex distributed systems without them collapsing into unmaintainable, hallucinated legacy code?**

If you’ve used AI coding assistants, you know the reality. They act like eager junior developers. You ask for a feature, and they start inventing new ways to mix concrete. They hallucinate, ignore your project’s architectural constraints, leads to fragile abstractions, and silently introduce massive technical debt.

To solve this, I realized we needed to fundamentally change the surface area the AI interacts with. I needed a declarative language where structure imparts determinism, because LLMs are designed for structured data and understand intent far better when following a constrained, predictable path.

This realization sparked a two-year research and engineering journey that spanned multiple languages, architectures, and paradigms. Today, I am thrilled to open-source the culmination of that journey: **Foundry**.

### The Two-Year Journey: From Rust to Go to Elixir

**Generation 1: The Rust Era (ArchitectLM/cascade)**

I started by building a high-performance, edge-compatible declarative workflow engine in Rust. It used a YAML DSL, WASM-based plugins for isolation, and Content-Addressed Storage (CAS) for immutable deployments. It was incredibly fast and safe. However, as the need for dynamic business rules grew, I hit a wall. Extending it required high entry threshold, complex integrations, and the boilerplate of maintaining a custom DSL became a bottleneck.

**Generation 2: The Go Era (Cascade Platform)**

To reduce code complexity, I pivoted to an “Application-as-Data” paradigm in Go. The idea was to stop reinvent backend entirely. The platform integrated heavy enterprise tools: Temporal for stateful workflows, SpiceDB for ReBAC authorization, and Flowable for business rules. While the architecture was incredibly powerful, the infrastructural complexity was overwhelming. Managing distributed caches, sagas, backpressure, and state machines across multiple external services is an ambitious task that takes years to perfect.

**The Epiphany: Elixir and the Ash Framework**

I needed something highly integrated, high-level, scalable and declarative out of the box. I needed a mature compiler, proper AST manipulation, and meta-programming to reduce complexity.

After testing LLM efficiency across various languages, **Elixir emerged as the clear winner.**

Elixir’s predictable structure, immutability, and OTP foundation natively solved the distributed system problems I was trying to wire together in Go. But the real magic was the **Ash Framework**. It shrinks the codebase drastically, requiring significantly fewer tokens to write and maintain, which is the holy grail for LLM context windows. It scales automatically, eliminating the need to manually orchestrate low-level abstractions.

### Enter Foundry: The Operating System for Complex Domains

**Foundry** is a governed development environment for complex domain platforms built on Elixir and Ash.

With Foundry, the paradigm shifts entirely. The AI doesn’t mix concrete anymore. It simply follow a gold standard, reaches into the Foundry library, pulls out a pre-cast, mathematically proven abstraction (like `ash_idempotency`, `ash_reactor` or `ash_state_machine`), and bolts it together. It also add some annotations to link with business intend that specification holds.

Foundry’s core philosophy is simple: **Your codebase is the spec, the spec is always true, and the copilot never loses context.**

#### 1. An Anti-Entropy System

The real competition in software engineering isn’t other tools; it’s the natural entropy of complex systems. Documentation drifts from code. Intent diverges from implementation.

Foundry fights entropy at every level:

- **The Spec-Kit** encodes business intent.

- **The Linter** makes that intent executable.

- **The System Map** makes architectural drift visible instantly.

- **Tests are displayed on the System Map** provides easier review.

- **The Copilot** operates strictly within these encoded constraints.

#### 2. AI That Understands Your Architecture

Unlike generic AI assistants that rely on file context and hallucinate dependencies and implicit relationships, Foundry’s Copilot uses structured retrieval over live DSL introspection and knows the entire compact map of the system. It knows your current stack and dependency versions, your project’s invariants, and your compliance obligations, it has references to a gold standard like `ash_hq` and `foundry_hq` before it generates a single line of code. Using AST-safe generation (via Igniter), it doesn’t just guess text, it safely modifies your system’s syntax tree in a safe way.

#### 3. Two Speeds: From Startup to Regulated Enterprise

Foundry adapts to your risk tolerance:

- **Execution-Led:** Minimal ceremony. Fast iteration. Auto-applied structural changes. The Copilot generates executable BDD scenarios directly from your PR descriptions. Reversibility is a first-class primitive, allowing you to semantically undo complex domain changes instantly.

- **Enterprise:** Full governance. Changes require proposals, ADRs (Architecture Decision Records), and compliance-linked flags. Scenarios and property tests are generated directly from regulatory and business requirements.

#### 4. The Living System Map

In traditional systems, architecture diagrams (C4, ERDs) are out of date the minute you commit code. Foundry generates a live, interactive System Map generated directly from the compiler’s metadata (using `spark_meta`). It extracts the resources, relationships, state machines, links, state machine lifecycles, authorization matrices and compliance tags, and renders an interactive graph. It has an “Engineer View” for the technical team and a “Domain View” for the business experts. If a developer removes a compliance tag, the map updates instantly. Drift is technically impossible because it is generated directly from the compiler.

It also provides a visual representation of code changes as well as full test tracing directly on the system map.

### Who is Foundry For?

Foundry is built for domains where rules matter enormously, where changing one rule cascades through the system, and where audit trails are mandatory.

If you are building platforms in **Healthcare, FinTech, Insurance, Legal Tech, Logistics, or EdTech**, Foundry provides the governance and architectural safety you need, without sacrificing development velocity.

### Why This Matters

Every engineering team maintaining a complex platform experiences the same pain: the original architect leaves, a new engineer adds a delete action, the compliance test is skipped, and six months later, you have a critical incident.

Foundry prevents this. It encodes institutional knowledge as executable constraints. The linter catches violations at the moment of introduction. The proposal model makes architectural changes visible. The Copilot operates strictly within these encoded constraints.

**Stop fighting entropy. Let your code be the spec.**

### Explore the Open-Source Ecosystem

Foundry is fully open-source and modular. Explore the repositories that was created for Foundry to build the future of AI-driven, spec-first engineering:

- **[Foundry Homepage](https://foundry.definitivespec.org/)** Learn and download a desktop application (Linux and macOS).

- **[Foundry Studio Demo](https://studio.cloud.foundry.definitivespec.org/)** Try a real project online.

- **[Foundry Library]( GitHub - FoundryStack/foundry: Foundry is the governed development environment for complex domain platforms. · GitHub ):** The core governed development environment.

- **[Foundry Studio]( GitHub - FoundryStack/foundry-studio · GitHub ):** The visual interface and living System Map.

- **[Spark Lint]( GitHub - FoundryStack/spark_lint: Lint rule runner for Elixir/Spark/Ash projects · GitHub ) & [Spark Meta]( GitHub - FoundryStack/spark_meta: Spark DSL walker and introspection library · GitHub ):** AST-aware linting and metadata extraction.

- **[Scenario Tracer]( GitHub - FoundryStack/scenario_tracer: ScenarioTracer wires together AST scanning, runtime trace collection, and report generation into a single Mix task abstraction · GitHub ) & [Ex Tracer]( GitHub - FoundryStack/ex_tracer: Scenario extraction primitives for Elixir test suites · GitHub ):** Executable specifications and deep observability.

- **[Phoenix LLM Chat]( GitHub - FoundryStack/phoenix_llm_chat: An extensible Phoenix LiveView chat component with streaming LLM support and session management · GitHub ):** The context-aware AI copilot interface.

- **[AshSDUI]( GitHub - FoundryStack/ash_sdui: Server-Driven UI for Phoenix LiveView applications backed by Ash resources · GitHub ):** Server-Driven UI for Phoenix LiveView applications backed by Ash resources.

- **[Demo Application]( GitHub - MaxSvargal/foundry-igaming: igaming fintech solution based on foundry · GitHub ):** Fintech solution based on foundry.

- **[Cascade on Rust]( GitHub - ArchitectLM/cascade: Sophisticated data-driven workflow orchestration · GitHub ):** Sophisticated data-driven workflow orchestration.

- **[Cascade on Golang]( GitHub - MaxSvargal/cascade-platform-go: Full-stack "Application-as-Data", "AI-first" development platform · GitHub ):** Full-stack “Application-as-Data” development platform.

- **[DefinitiveSpec](https://definitivespec.org/):** Definitive Development Methodology for Specification-Driven Development.

Check out the code, read the docs, and let me know what you think! I am looking for partners to evolve the project.

Join us on Discord DefinitiveSpec Community @maxsvargal

_P.S. The project is in the preview stage and is not ready for production yet, but I hope that we will bring it to perfection through iterative attempts at implementing real projects._

Most Liked

jam

jam

Fwiw, I’d leave it as is. I think it’s cool and pretty unique.

Dmk

Dmk

Interesting idea. Will have to check it out when I have a bit of time.

The website hero is sweet though!

jam

jam

This sounds interesting. Would be great if you can make it work with Hologram.

Where Next?

Popular in Announcing Top

martinthenth
Hello everybody :wave: Recently, some of my colleagues talked about database ids and uuids and their problems, and I remembered the pain...
New
ityonemo
Currently just starting out on a new mini-project - getting zig NIFs to run in elixir. https://github.com/ityonemo/zigler The idea here...
New
josevalim
Hi everyone, We would like to announce that Plataformatec is working on a new MySQL driver called MyXQL. Our goal is to eventually integ...
New
tmbb
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps: bureaucrat - which contains a bunch ...
New
bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
384 14136 119
New
mindok
What is ContEx? A pure Elixir server-side data plotting/charting library outputting SVG. It has nice barcharts in particular and works g...
New
Jskalc
Hi! Today, after a couple weeks of development I’ve released v0.1 of LiveVue. It’s a seamless integration of Vue and Phoenix LiveView, i...
New
Hal9000
Here is my first stab at this. README pasted below. https://github.com/Hal9000/elixir_random Comments and critiques are welcome. Thank...
New
michalmuskala
Hello everybody. I have just released Jason - a new JSON library. You might be wondering, why do we need a new library? The primary foc...
New
markmark206
simple_feature_flags is a tiny package that lets you turn features on or off based on which environment (e.g. localhost, staging, product...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43487 311
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 127089 1222
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement