https://github.com/mac9sb/fluent-gen
Generate Swift Fluent-ORM models dynamically
https://github.com/mac9sb/fluent-gen
fluent swift tooling utility
Last synced: 5 months ago
JSON representation
Generate Swift Fluent-ORM models dynamically
- Host: GitHub
- URL: https://github.com/mac9sb/fluent-gen
- Owner: mac9sb
- License: apache-2.0
- Created: 2026-01-09T11:09:15.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2026-01-26T02:26:38.000Z (5 months ago)
- Last Synced: 2026-01-26T09:14:58.912Z (5 months ago)
- Topics: fluent, swift, tooling, utility
- Language: Swift
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FluentGen
A Swift macro that automatically generates Fluent ORM model classes from simple domain model structs.
## Overview
FluentGen eliminates boilerplate by automatically generating Fluent database models from your domain structs:
- **Automatic Model Generation**: Convert structs to Fluent models
- **Type Safety**: Leverage Swift's type system
- **Reduced Boilerplate**: No manual model definitions needed
- **Migration Support**: Automatic schema generation
## Getting Started
### Installation
Add FluentGen to your `Package.swift`:
```swift
dependencies: [
.package(url: "https://github.com/mac9sb/fluent-gen", from: "1.0.0")
]
```
Then add it to your target:
```swift
.target(
name: "YourTarget",
dependencies: [
.product(name: "FluentGen", package: "fluent-gen")
]
)
```
### Usage
Apply the `@FluentModel` macro to your structs:
```swift
import FluentGen
@FluentModel
struct User {
var id: UUID?
var name: String
var email: String
}
```
FluentGen automatically generates the corresponding Fluent model with all necessary methods:
```swift
let user = UserModel(name: "John", email: "john@example.com")
try await user.save(on: database)
```
## Architecture
FluentGen uses Swift Macros to:
1. Analyze your struct definitions
2. Generate Fluent model classes
3. Create migration schemas
4. Provide type-safe database operations
## Development
To contribute to FluentGen:
1. Clone the repository
2. Build the project: `swift build`
3. Run tests: `swift test`
4. Build documentation: `swift package generate-documentation`
## License
See LICENSE file for details.