The open-source Swift server powering coenttb.com
Built entirely in Swift with type-safe HTML generation and inspired by Point-Free
coenttb-com-server is the complete source code for coenttb.com, a production Swift website built in the style of Point-Free and powered by Vapor & coenttb-web.
Read more about me in my introductory post on coenttb.com.
- π 100% Swift - Frontend to backend, all Swift
- π‘οΈ Type-safe HTML & CSS - Catch errors at compile time
- π§© Hypermodular architecture - Clean separation of concerns
- β‘ Server-side rendering - Fast, SEO-friendly pages
- π¨ Point-Free inspired - Functional, composable patterns
Swift for web development is powerful but underexplored. By open-sourcing coenttb.com, I aim to:
- Demonstrate - Show how to structure a production Swift website elegantly
- Inspire - Encourage others to build web applications in Swift
- Collaborate - Gather feedback to improve the Swift web ecosystem
This is a real production website serving real users - not just a demo. Learn from actual patterns used in production.
- Swift 5.10+ (Full Swift 6 support)
- macOS 14+ or Linux
- PostgreSQL 14+
- Xcode 15+ (for macOS development)
-
Clone the repository
git clone https://github.com/coenttb/coenttb-com-server cd coenttb-com-server
-
Configure environment
cp .env.example .env.development
-
Setup PostgreSQL
# Example DATABASE_URL format: # postgres://username:password@localhost:5432/database_name # For local development: postgres://admin:@localhost:5432/coenttb-development
-
Run the server
swift run Server # Or in Xcode: Select the 'Server' scheme and run
Visit
http://localhost:8080
to see your site!
This project demonstrates a modern, type-safe web architecture:
// Type-safe routing
@Dependency(\.coenttb.website.router) var router
app.mount(router, use: Route.response)
let home = router.url(for: .home)
let blog = router.url(for: .blog(.index))
let blogPost = router.url(for: .blog(.post(1)))
// Type-safe HTML generation
extension Blog.Post {
struct View: HTML {
let post: Blog.Post
var body: some HTML {
article {
h1 { post.title }
.fontSize(.rem(2.5))
div { post.content }
.lineHeight(1.6)
}
.maxWidth(.px(800))
.margin(.auto)
}
}
}
This server is built on a comprehensive Swift web development stack:
- swift-html - Type-safe HTML & CSS DSL
- swift-html-types - Domain accurate and type-safe HTML types
- swift-css-types - Domain accurate and type-safe CSS types
- swift-web - Web development fundamentals
- coenttb-html - HTML extensions, Markdown, Email, PDF
- coenttb-web - Advanced web utilities
- coenttb-server - Cross-platform server development tools
- coenttb-server-vapor - Vapor & Fluent integration
- pointfree-html - HTML rendering engine
- swift-translating - Cross-platform translations
- π Blog Engine - Markdown-based blog with syntax highlighting
- π§ Email System - Type-safe transactional emails
- π Internationalization - Multi-language support
- π¨ Dark Mode - Automatic theme switching
- π± Responsive Design - Mobile-first approach
- π Performance - Optimized for speed
Contributions are welcome! This project serves as both a production website and a learning resource for the Swift web community.
- Report Issues - Found a bug? Let me know!
- Suggest Features - Ideas for improvements
- Submit PRs - Bug fixes and enhancements
- Share Knowledge - Blog about your experience
- π Issue Tracker - Report bugs or request features
- π¬ Discussions - Ask questions and share ideas
- π§ Newsletter - Swift web development tips
- π¦ X (Twitter) - Follow for updates
- πΌ LinkedIn - Connect professionally
This project relies on and is inspired by the excellent work at Point-Free by Brandon Williams and Stephen Celis.
This project is available under dual licensing:
GNU Affero General Public License v3.0 (AGPL-3.0)
Free for open source projects. See LICENSE for details.
For proprietary/commercial use without AGPL restrictions.
Contact info@coenttb.com for licensing options.
- Paid content on coenttb.com - All rights reserved
- Free content (blog posts, docs) - CC BY-NC-SA 4.0
Made with β€οΈ by coenttb
Building the future of Swift on the server