Skip to content

wesleynw/splajompy

Repository files navigation

logo

Splajompy

API Build iOS Build

What is this?

Splajompy is rooted in the belief that mainstream social media has long stopped being an ideal place to connect with others online, and that an online space for connection shouldn't necessarily be a public town square, but rather a small, familiar group of people that slightly extends beyond the connections we have in real life.

Splajompy avoids the common social media designs that allow us to compare ourselves with others based on like or follower counts, which drive us towards treating posts as content, and instead nudges you to keep up with only people you know, or mutual friends.

Features:

  • posts, likes, comments, images in both posts and comments
  • profiles, bios, profile appearance customization
  • polls, customizable feeds
  • blocking, muting, following
  • tagging users, notifications

Originally written as a full-stack Typescript application, Splajompy now has an API written in Go and a mobile app written almost entirely in SwiftUI to feel as native as possible.

API Architecture

The API follows a domain-scoped architecture. Each domain (e.g. post, user, auth) lives in its own package under internal/ and owns its store, service, and handler.

Each domain handler implements the RouteRegistrar interface:

type RouteRegistrar interface {
    RegisterRoutes(public, withAuth func(string, func(http.ResponseWriter, *http.Request)))
}

The root handler in internal/handler holds a slice of RouteRegistrars and registers routes for each domain.

Stores are currently a thin layer over the database, but exist as a natural place to add caching per domain in the future.

Starting the API

You'll need to have a .env file in the api folder that includes a DB connection string, Resend API key, S3 API Key, and a few other things.

Start the API by running go run cmd/api/main.go from the api directory.

SQLC

The API uses SQLC to generate typed functions from database calls. Given a raw SQL query, you can have SQLC generate a function that can be called from a querier interface.

To do this, install SQLC locally, and run:

sqlc generate -f api/internal/db/sqlc.yaml

DB Migrations

Migrations are handled with golang-migrate. To make changes to the DB, follow the linked guide below. This usually involves writing up and down migrations, which you can first push to the development DB, and then to production when new API code is merged.

Database migrations in Go with golang-migrate

Testing

Run the test suite from the api directory:

go test ./...

Docker must be installed as tests spin up a Postgres container.

Linting

Go Code

Before pushing Go code changes, run golangci-lint to check for issues:

# install golangci-lint (if not already installed)
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

# Run linting from the api directory
cd api
golangci-lint run

Swift Code

Before pushing Swift code changes, run the following command to format your code:

xcrun swift-format --in-place --recursive .
# or shorthand:
xcrun swift-format -ri .

Swift linting is also enforced via a GitHub action that runs on pull requests.

Deployment

API code merged to the main branch is automatically deployed to the production API environment.

Merges that change any Swift code will also trigger a XCode Cloud build and release to an internal TestFlight group.

About

A small social media application for iOS.

Resources

License

Stars

Watchers

Forks

Contributors