# Architecture

## Concepts

Squidex is implemented based on the following concepts:

### CQRS

CQRS stands for *Command Query Responsibility Segregation*. It's a pattern that was first described by Greg Young. At its heart is the idea that you can use a different model to update information, rather than the model you use to read information. Typically, you use event sourcing as the primarily source of truth for your data and then you subscribe to the events to create read models that can be used to query and fetch information about your entities.

Read more from [Martin Fowler](https://martinfowler.com/bliki/CQRS.html)

### Event Sourcing

We can query an application's state to find out the current state of the world, and this answers many questions. However there are times when we don't just want to see where we are, we also want to know how we got there.

Event Sourcing ensures that all changes to an application state are stored as a sequence of events. Not only are we able to query these events, but we can also use the event log to reconstruct past states and as a foundation to automatically adjust the state to cope with retroactive changes.

A traditional representation of database state can be entirely recreated by reprocessing this event log. Event sourcing's benefits include strong auditing, creation of historic state, and replaying of events for debugging and analysis. Event sourcing has been around for a while, but we think it is used much less than it should be.

Although this approach adds a lot of complexity to the system it also has a lot of advantages:

1. There's a history of all changes.
2. It's possible to consume the events to create custom storage, e.g. you can use the Elastic Search Stack for full text search or statistics.
3. Data is never deleted. Even when there are bigger bugs, it's possible to provide fixes that restore all lost content.
4. There's no need to worry about data migration when changing the read models with a new version; just run the event consumers from the beginning to populate the read store with the updated data.

## Frameworks and Tools

Squidex is based on the following frameworks and tools:

* ASP.NET Core for the backend.
* Angular for the Management UI
* MongoDB for the event Store and persistence
* Orleans as the backend technology.

Of course there are also dozens of external dependencies (because there's no need to reinvent the wheel!), but it would just be too much information to list them all here.

See slides about the current architecture (June 2019): <https://www.slideshare.net/secret/yUk1EmYlw8pLZF>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.squidex.io/id-01-getting-started/contributing-and-developing/overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
