Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
1a2aef9
Feature/remove direct redis dependency (#1)
crimson-knight Jul 25, 2025
a0baf27
Remove CLI functionality from Amber framework (#2)
crimson-knight Jul 25, 2025
803004d
Remove deprecated YAML.mapping and replace with YAML::Serializable (#3)
crimson-knight Jul 25, 2025
9b19b14
Feature/remove unnecessary dependencies (#4)
crimson-knight Jul 25, 2025
84c09b6
Feature/add schema based params (#5)
crimson-knight Jul 29, 2025
2b9f9e0
Internalize amber_router and optimize routing engine
crimson-knight Feb 13, 2026
64aa62b
Add built-in markdown renderer with GFM extensions
crimson-knight Feb 13, 2026
554cd2f
Clean up artifacts and remove compiled_license dependency
crimson-knight Feb 13, 2026
2a0bf91
Internalize backtracer shard into Amber source tree
crimson-knight Feb 13, 2026
7c47b6a
Internalize exception_page and remove both it and backtracer from sha…
crimson-knight Feb 13, 2026
25e83a8
Merge branch 'feature/markdown-renderer'
crimson-knight Feb 14, 2026
bbe4752
Remove kilt and slang, use ECR directly for template rendering
crimson-knight Feb 14, 2026
111907b
Add action helpers: forms, URLs, assets, text, numbers
crimson-knight Feb 14, 2026
bfd0fec
Add built-in background job processing system
crimson-knight Feb 14, 2026
e25bed1
Add built-in mailer with SMTP and memory adapters
crimson-knight Feb 14, 2026
2810138
Add built-in testing framework for Amber applications
crimson-knight Feb 14, 2026
caf6835
Merge branch 'feature/background-jobs'
crimson-knight Feb 14, 2026
fd8ccb5
Merge branch 'feature/testing-framework'
crimson-knight Feb 14, 2026
b8421b3
Merge branch 'feature/action-helpers'
crimson-knight Feb 14, 2026
6b0223b
Merge branch 'feature/mailer'
crimson-knight Feb 14, 2026
d2a428e
Add markdown follow-up features: bare URL autolinks, footnotes, TOC, …
crimson-knight Feb 14, 2026
11669c9
Modernize WebSocket system with decoders, error handling, presence, a…
crimson-knight Feb 14, 2026
c65f125
Merge branch 'feature/improve-websockets'
crimson-knight Feb 14, 2026
432e600
Improve session management security across the framework
crimson-knight Feb 14, 2026
2f6618d
Add typed configuration system with environment variable overrides
crimson-knight Feb 14, 2026
5cb08a9
Merge branch 'feature/configuration-overhaul'
crimson-knight Feb 14, 2026
370fc98
Add router enhancements: named routes, constraints, API versioning, a…
crimson-knight Feb 14, 2026
6a94768
Merge branch 'feature/improve-router'
crimson-knight Feb 14, 2026
7ec881a
Add Amber V2 documentation and migration guide
crimson-knight Feb 14, 2026
14e2ce2
Document native app usage pattern (Amber without HTTP server)
crimson-knight Mar 3, 2026
2cf2d03
[Docs] Add process manager testing, feature story mapping, and native…
crimson-knight Mar 4, 2026
5eb296e
Add ecosystem agent, Crystal language skill, and update existing agents
crimson-knight Mar 23, 2026
510afcd
Track existing Amber V2 skills for shards-alpha distribution
crimson-knight Mar 23, 2026
79a8873
Remove internal agent config, planning docs, and local-path artifacts
crimson-knight Jun 10, 2026
da890c4
Fix public-facing references: migration guide and README
crimson-knight Jun 10, 2026
7388324
Add CHANGELOG.md for 2.0.0-dev
crimson-knight Jun 10, 2026
7d1b922
Fix docs/getting-started.md: update branch reference to v2-dev
crimson-knight Jun 10, 2026
d80f042
Fix Accept-header parsing to comply with RFC 7231
crimson-knight Jun 10, 2026
7a36325
Add parsed_uri helper so both port() and url() handle absolute-URI re…
crimson-knight Jun 10, 2026
d62bff8
Rescue OpenSSL::SSL::Error in WebSocket beat() to prevent heartbeat c…
crimson-knight Jun 10, 2026
bb7b869
Fix suite-abort and 5 named-route failures on Crystal 1.20
crimson-knight Jun 10, 2026
07142cc
Apply crystal tool format across the codebase
crimson-knight Jun 10, 2026
5d4244a
Add GitHub Actions CI workflow for v2-dev branch
crimson-knight Jun 10, 2026
0c1a7b9
Make README capability list honest and remove broken image reference
crimson-knight Jun 10, 2026
3e48d3a
Restore check_alive! in beat()
crimson-knight Jun 10, 2026
49ac82a
Run CI specs in defined order
crimson-knight Jun 10, 2026
c50ab73
Draw request_helpers spec routes in before_all, not at file load
crimson-knight Jun 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
push:
branches:
- v2-dev
pull_request:
branches:
- master
- v2-dev

jobs:
test:
name: Crystal ${{ matrix.crystal }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
crystal: [latest]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Crystal
uses: oprypin/install-crystal@v1
with:
crystal: ${{ matrix.crystal }}

- name: Install dependencies
run: shards install

- name: Run specs
# Defined order for now: the suite has pre-existing order-dependent
# specs (respond_with + others fail under --order random regardless of
# recent changes). Tracked as a cleanup task before switching to random.
run: crystal spec

- name: Check formatting
run: crystal tool format --check
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/doc/
/docs/
/bin/
/.shards/
/.vscode/
Expand All @@ -10,7 +9,7 @@ lib/
/tmp
shard.lock
.crystal-version
package-lock.json
node_modules
/myapp
cli.dwarf
*.dwarf
*.bak
*.png
4 changes: 2 additions & 2 deletions Backers.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
As of 2019-05-30, Amber is graciously supported by:
As of 2025-07-25, Amber is graciously supported by:

Universal Layer - https://ulayer.net/
AgentC Consulting - https://agentc.consulting
188 changes: 188 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
# Changelog

## 2.0.0-dev (unreleased)

This release represents a major architectural revision of the Amber framework.
The primary goals were to remove all runtime dependencies, modernize the
Crystal language patterns in use, and add first-class support for background
jobs, email, and typed configuration. The CLI has been extracted to a separate
repository.

### Breaking Changes

#### CLI removed from framework

The `amber` CLI tool — generators, scaffolding, database commands, `amber
watch`, `amber routes`, `amber encrypt`, `amber exec` — has been removed from
this repository. Amber V2 is a library shard, not a CLI tool.

A replacement CLI is maintained as a separate project:
https://github.com/amberframework/amber_cli

#### Zero runtime dependencies

All runtime shards have been removed from `shard.yml`. The following were
either dropped or internalized:

| Dependency | Disposition |
|---|---|
| `redis` / `crystal-redis` | Replaced by adapter pattern; memory adapter is default |
| `amber_router` | Internalized into `src/amber/router/engine/` |
| `backtracer` | Internalized into `src/amber/` |
| `exception_page` | Internalized into `src/amber/` |
| `kilt` | Removed; ECR only |
| `slang` | Removed; ECR only |
| `pg` / `mysql` / `sqlite3` | Removed; add the driver you need at app level |
| `compiled_license` | Removed |
| `micrate` | Removed; handle migrations at app level |

The only remaining dependency is `ameba` (development only) for linting.

#### Template engine: ECR only

Kilt and Slang have been removed. Templates must use Crystal's built-in ECR
(Embedded Crystal). Rename `.slang` files to `.ecr` and convert syntax
accordingly. See [docs/migration-guide.md](docs/migration-guide.md) for a
conversion table.

#### YAML.mapping replaced with YAML::Serializable

The deprecated `YAML.mapping` macro no longer works in Crystal 1.x. All
framework internals have been updated to `include YAML::Serializable`. Any
application code using `YAML.mapping` must be updated; the change is
mechanical (see migration guide).

#### Configuration restructured

The flat YAML configuration format has been replaced with typed, sectioned
configuration structs. Sections: `server`, `database`, `session`, `logging`,
`jobs`, `mailer`. Every property can be overridden with an environment variable
using the `AMBER_{SECTION}_{KEY}` naming convention (e.g.,
`AMBER_SERVER_PORT=8080`, `AMBER_DATABASE_URL=postgres://...`).

The `Amber::Server.configure` block no longer accepts a block parameter;
properties are set directly inside the block.

#### Session defaults changed

Default session store changed from `redis` to `signed_cookie`. Default adapter
is `memory` (no external service required). The `expires` field is an integer
(seconds).

### New Features

#### Schema API

A type-safe request validation and coercion layer. Define a schema class with
typed fields and validators (required, length, format, range, pattern, enum).
Parsers handle JSON, multipart, query string, and XML bodies. Existing
`params["key"]` usage continues to work unchanged via `SchemaParamsWrapper`;
the Schema API is opt-in per action.

See [docs/guides/schema-api.md](docs/guides/schema-api.md).

#### Typed configuration with environment variable overrides

`Amber::Configuration::AppConfig` holds all framework settings as typed Crystal
structs. Any field can be overridden at runtime via environment variables
following the `AMBER_{SECTION}_{KEY}` pattern without changing YAML files.
Custom configuration sections can be registered in the same registry.

See [docs/guides/configuration.md](docs/guides/configuration.md).

#### Built-in background jobs

A work-stealing job queue that runs inside idle web workers — no separate
process required. Includes retry logic and a pluggable adapter interface (memory
adapter ships by default). Redis and other backends can be added via custom
adapters.

See [docs/guides/background-jobs.md](docs/guides/background-jobs.md).

#### Built-in mailer

Fluent API for composing and sending email. Ships with an SMTP adapter and a
memory adapter for testing. The memory adapter records sent mail so tests can
assert on it without a real mail server.

See [docs/guides/mailer.md](docs/guides/mailer.md).

#### WebSocket modernization

- Message decoders: plug in a decoder to parse incoming frames into typed
messages before they reach your channel handler
- Presence tracking: built-in presence API that tracks which users are
connected and broadcasts join/leave events
- Connection recovery: automatic reconnect with exponential backoff and
last-message-id replay
- Improved error handling and channel lifecycle callbacks

See [docs/guides/websockets.md](docs/guides/websockets.md).

#### Named routes, constraints, and API versioning

- `route_url(:route_name, param: value)` — generate URLs by name rather than
hardcoded strings
- Route constraints: host, subdomain, format, and custom lambda constraints
- API versioning middleware (`ApiVersion` pipe) with header- and
URL-segment-based version detection
- Route introspection: list all registered routes with names, methods, and
paths at runtime

See [docs/guides/routing.md](docs/guides/routing.md).

#### Built-in markdown renderer

A GFM-compatible Markdown renderer with autolinks, footnotes, table-of-contents
generation, and syntax highlighting hooks. No external dependency.

See [docs/guides/markdown.md](docs/guides/markdown.md).

#### Action helpers

Helper methods for views: form builders, URL helpers, asset helpers, text
formatting, and number formatting.

See [docs/guides/action-helpers.md](docs/guides/action-helpers.md).

#### Built-in test framework

`Amber::Testing::ContextBuilder` simulates HTTP requests against your
controllers without starting a real server. Includes WebSocket test helpers and
assertion methods for response status, headers, body content, and redirects.

See [docs/guides/testing.md](docs/guides/testing.md).

#### Session security improvements

`MessageEncryptor` and `MessageVerifier` updated to SHA-256. SameSite cookie
attribute support. Key rotation support. Session regeneration on privilege
escalation.

### Adapter Pattern

Sessions, PubSub, jobs, and mailer now all use a pluggable adapter interface.
The `AdapterFactory` allows registering custom backends at startup. This is the
supported path for adding Redis sessions, Redis pub/sub, or any other backend
without coupling the framework to a specific shard.

### Documentation

A full documentation suite has been added under `docs/`:

- [Migration guide](docs/migration-guide.md) — complete V1 to V2 upgrade instructions
- [Schema API guide](docs/guides/schema-api.md)
- [Configuration guide](docs/guides/configuration.md)
- [Routing guide](docs/guides/routing.md) (named routes, constraints, API versioning)
- [WebSocket guide](docs/guides/websockets.md)
- [Background jobs guide](docs/guides/background-jobs.md)
- [Mailer guide](docs/guides/mailer.md)
- [Testing guide](docs/guides/testing.md)
- [Markdown guide](docs/guides/markdown.md)
- [Action helpers guide](docs/guides/action-helpers.md)
- [LSP setup guide](docs/guides/lsp-setup.md) (Claude Code integration)

---

For changes prior to V2, see the git log at
https://github.com/amberframework/amber/commits/master
120 changes: 120 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# CLAUDE.md

## Project Overview

Amber V2 is a web application framework written in Crystal. It provides an efficient, cohesive framework that embraces Crystal's language philosophies with near-zero runtime dependencies.

**Version**: 2.0.0-dev
**Crystal**: >= 1.0.0, < 2.0
**License**: MIT
**Dependencies**: ameba (dev only) — framework is entirely self-contained at runtime

## Development Commands

```bash
# Install dependencies (ameba only)
shards install

# Run all tests and checks (recommended)
./bin/amber_spec

# Individual commands
crystal spec # Run test suite
crystal spec spec/amber/controller/base_spec.cr # Single file
crystal tool format --check # Check formatting
crystal tool format # Auto-format
./bin/ameba # Run linter
crystal docs # Generate API docs → docs/
```

## Architecture Overview

### Core Subsystems

1. **Controllers** (`src/amber/controller/`): Base controller with before/after filters, rendering, redirects, CSRF helpers, route helpers, responders, i18n

2. **Router** (`src/amber/router/`): HTTP routing with params, cookies, sessions, flash messages, file uploads. V2 adds named routes, constraints (host, subdomain, format, custom), and API versioning

3. **Router Engine** (`src/amber/router/engine/`): Internalized radix-tree router (formerly amber_router shard). Segment-based matching with fixed, variable, and glob segments

4. **Middleware Pipes** (`src/amber/pipes/`): Pipeline-based HTTP request processing — CSRF, Session, Flash, Logger, CORS, Static, Error, ClientIp, ApiVersion, PoweredByAmber

5. **WebSockets** (`src/amber/websockets/`): Channel-based real-time communication with presence tracking, message decoders, connection recovery, and adapter-backed PubSub

6. **Configuration** (`src/amber/configuration/`): Typed configuration structs with YAML loading, environment variable overrides (`AMBER_` prefix), validation, and custom registry

7. **Schema API** (`src/amber/schema/`): Request validation and type coercion. Define schemas with field types, validators (required, length, format, range, pattern, enum), and parsers (JSON, multipart, query, XML)

8. **Jobs** (`src/amber/jobs/`): Background job processing with work-stealing pattern — idle web instances pick up queued jobs. Retry logic, queue adapters

9. **Mailer** (`src/amber/mailer/`): Email composition with fluent API, SMTP adapter, memory adapter for testing

10. **Testing** (`src/amber/testing/`): ContextBuilder for request simulation, assertions, WebSocket test helpers

11. **Adapters** (`src/amber/adapters/`): Pluggable backends for sessions (Memory, with adapter interface for Redis/others) and PubSub (Memory, with adapter interface). Factory pattern for runtime selection

12. **Markdown** (`src/amber/markdown/`): GFM-compatible renderer with autolinks, footnotes, table of contents, syntax highlighting

13. **Session Security** (`src/amber/support/`): MessageEncryptor and MessageVerifier with SHA256, SameSite cookies, key rotation, session regeneration

14. **DSL** (`src/amber/dsl/`): Macros for server configuration, router definition, pipeline composition, and callback registration

### Template Engine

ECR (Embedded Crystal) only — part of Crystal stdlib. Kilt/Slang/Liquid have been removed.

### Key Design Patterns

- **Adapter Pattern**: Sessions, PubSub, jobs, and mailer use adapters for different backends
- **Pipeline Pattern**: HTTP requests flow through configurable middleware pipes
- **DSL Approach**: Router and server configuration use Crystal macros for clean syntax
- **Work-Stealing**: Background jobs distributed across idle web instances
- **Convention over Configuration**: Sensible defaults with typed overrides

### Using Amber Without HTTP Server (Native Apps)

Amber can be used as a pattern library for native desktop/mobile apps without starting the HTTP server. This is useful when you want Amber's configuration, controllers-as-event-handlers, and process managers but use a native event loop instead.

**Settings API:**
```crystal
require "amber"

# Correct: access settings directly
Amber.settings.name = "My Native App"
puts Amber.env # => "development"

# WRONG: Amber::Server.configure creates an HTTP server instance
# Amber::Server.configure { |s| s.name = "..." } # Don't do this

# WRONG: Amber::Server.settings doesn't exist
# Amber::Server.settings.name # NoMethodError
```

**Key point:** `Amber.settings` returns `Amber::Environment::Settings` and can be used standalone. `Amber::Server.configure` yields settings but also instantiates `Amber::Server.instance` which initializes HTTP-related adapters.

### External Dependencies

- **Grant ORM**: Separate shard — ActiveRecord-style ORM for V2 (publishing to the amberframework org soon)
- **CLI**: Separate project (`amber_cli`) — not part of this repo
- **Asset Pipeline**: Separate project (`amberframework/asset_pipeline`) — not part of this repo

## Key File Paths

| Area | Path |
|------|------|
| Entry point | `src/amber.cr` |
| Configuration | `src/amber/configuration/` |
| Controllers | `src/amber/controller/` |
| Router + Engine | `src/amber/router/`, `src/amber/router/engine/` |
| Named Routes | `src/amber/router/named_routes.cr` |
| Constraints | `src/amber/router/constraints/` |
| Middleware | `src/amber/pipes/` |
| WebSockets | `src/amber/websockets/` |
| Schema API | `src/amber/schema/` |
| Jobs | `src/amber/jobs/` |
| Mailer | `src/amber/mailer/` |
| Testing | `src/amber/testing/` |
| Adapters | `src/amber/adapters/` |
| Markdown | `src/amber/markdown/` |
| Session Security | `src/amber/support/message_encryptor.cr`, `message_verifier.cr` |
| DSL | `src/amber/dsl/` |
Loading
Loading