Skip to content

coenttb/coenttb-com-server

Repository files navigation

coenttb-com-server

Swift 6.0 Platforms License Vapor 4

The open-source Swift server powering coenttb.com
Built entirely in Swift with type-safe HTML generation and inspired by Point-Free

Overview

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.

✨ Key Features

  • πŸš€ 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

Why Open Source?

🎯 Mission

Swift for web development is powerful but underexplored. By open-sourcing coenttb.com, I aim to:

  1. Demonstrate - Show how to structure a production Swift website elegantly
  2. Inspire - Encourage others to build web applications in Swift
  3. 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.

Quick Start

Prerequisites

  • Swift 5.10+ (Full Swift 6 support)
  • macOS 14+ or Linux
  • PostgreSQL 14+
  • Xcode 15+ (for macOS development)

Installation

  1. Clone the repository

    git clone https://github.com/coenttb/coenttb-com-server
    cd coenttb-com-server
  2. Configure environment

    cp .env.example .env.development
  3. Setup PostgreSQL

    # Example DATABASE_URL format:
    # postgres://username:password@localhost:5432/database_name
    
    # For local development:
    postgres://admin:@localhost:5432/coenttb-development
  4. Run the server

    swift run Server
    # Or in Xcode: Select the 'Server' scheme and run

    Visit http://localhost:8080 to see your site!

Architecture

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)
        }
    }
}

Ecosystem

πŸ—οΈ The coenttb Stack

This server is built on a comprehensive Swift web development stack:

Core Libraries

Extended Functionality

Point-Free Foundations

Additional Tools

Features Demonstrated

  • πŸ“ 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

Contributing

Contributions are welcome! This project serves as both a production website and a learning resource for the Swift web community.

Ways to Contribute

  1. Report Issues - Found a bug? Let me know!
  2. Suggest Features - Ideas for improvements
  3. Submit PRs - Bug fixes and enhancements
  4. Share Knowledge - Blog about your experience

Support

Acknowledgements

This project relies on and is inspired by the excellent work at Point-Free by Brandon Williams and Stephen Celis.

License

This project is available under dual licensing:

Open Source License

GNU Affero General Public License v3.0 (AGPL-3.0)
Free for open source projects. See LICENSE for details.

Commercial License

For proprietary/commercial use without AGPL restrictions.
Contact info@coenttb.com for licensing options.

Content License


Made with ❀️ by coenttb
Building the future of Swift on the server

Sponsor this project

 

Languages