diff --git a/.github/workflows/api-checks.yml b/.github/workflows/api-checks.yml
new file mode 100644
index 0000000..70f4c49
--- /dev/null
+++ b/.github/workflows/api-checks.yml
@@ -0,0 +1,61 @@
+name: Build and check API
+
+on:
+ push:
+ branches: ["main"]
+ pull_request:
+ branches: ["main"]
+ workflow_dispatch:
+
+jobs:
+ check:
+ runs-on: ubuntu-22.04
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup Java
+ uses: actions/setup-java@v4
+ with:
+ distribution: "temurin"
+ java-version: 22
+
+ - name: Setup Gradle
+ uses: gradle/actions/setup-gradle@v3
+
+ - name: Compile assets
+ working-directory: api
+ shell: bash
+ run: ./compile-assets.main.kts
+
+ - name: Run checks
+ working-directory: api
+ run: ./gradlew build check shadowJar
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v3
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Set container vars
+ working-directory: api
+ shell: bash
+ run: |
+ echo "CONTAINER_TAG=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
+ echo "STATIC_ASSETS_PATH=build/static" >> $GITHUB_ENV
+ echo "TEMPLATE_ASSETS_PATH=build/templates" >> $GITHUB_ENV
+ echo "JAR_PATH=$(find app/build/libs/*-all.jar | head -n1)" >> $GITHUB_ENV
+
+ - name: Build container
+ uses: docker/build-push-action@v6
+ with:
+ push: false
+ context: "api"
+ platforms: "linux/amd64,linux/arm64"
+ build-args: |
+ jar=api/${{ env.JAR_PATH }}
+ static_assets=api/${{ env.STATIC_ASSETS_PATH }}
+ template_assets=api/${{ env.TEMPLATE_ASSETS_PATH }}
+ version="${{ env.CONTAINER_TAG }}
+ tags: github.com/lopcode/photo-fox:${{ env.CONTAINER_TAG }}
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..c319da3
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/api/.gitattributes b/api/.gitattributes
new file mode 100644
index 0000000..f91f646
--- /dev/null
+++ b/api/.gitattributes
@@ -0,0 +1,12 @@
+#
+# https://help.github.com/articles/dealing-with-line-endings/
+#
+# Linux start script should use lf
+/gradlew text eol=lf
+
+# These are Windows script files and should use crlf
+*.bat text eol=crlf
+
+# Binary files should be left untouched
+*.jar binary
+
diff --git a/api/.gitignore b/api/.gitignore
new file mode 100644
index 0000000..1b6985c
--- /dev/null
+++ b/api/.gitignore
@@ -0,0 +1,5 @@
+# Ignore Gradle project-specific cache directory
+.gradle
+
+# Ignore Gradle build output directory
+build
diff --git a/api/.run/Run server.run.xml b/api/.run/Run server.run.xml
new file mode 100644
index 0000000..d9e4a16
--- /dev/null
+++ b/api/.run/Run server.run.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/api/Dockerfile b/api/Dockerfile
new file mode 100644
index 0000000..66a3c53
--- /dev/null
+++ b/api/Dockerfile
@@ -0,0 +1,25 @@
+FROM eclipse-temurin:22@sha256:a0301bbe5818c2e79bf4385d94aa1c29caa1aba8a74bf10a86225922bfbdc4d6
+
+ARG jar
+ARG version="test"
+ARG static_assets
+ARG template_assets
+
+RUN mkdir /opt/app
+COPY $jar /opt/app/app.jar
+COPY $static_assets /opt/app/static/
+COPY $template_assets /opt/app/templates/
+
+ENV JAVA_OPTS=""
+
+LABEL org.opencontainers.image.source="https://github.com/lopcode/photo-fox"
+LABEL org.opencontainers.image.revision="$version"
+
+USER nobody
+WORKDIR /opt/app
+
+# sense checks
+RUN ls -al /opt/app
+RUN java -version
+
+ENTRYPOINT exec java ${JAVA_OPTS} -jar /opt/app/app.jar
\ No newline at end of file
diff --git a/api/app/.editorconfig b/api/app/.editorconfig
new file mode 100644
index 0000000..9a0f3b7
--- /dev/null
+++ b/api/app/.editorconfig
@@ -0,0 +1,5 @@
+[*.{kt,kts}]
+ktlint_standard_no-wildcard-imports = disabled
+ktlint_standard_multiline-expression-wrapping = disabled
+ktlint_standard_string-template-indent = disabled
+max_line_length = 120
\ No newline at end of file
diff --git a/api/app/build.gradle.kts b/api/app/build.gradle.kts
new file mode 100644
index 0000000..95bc608
--- /dev/null
+++ b/api/app/build.gradle.kts
@@ -0,0 +1,98 @@
+@file:Suppress("UnstableApiUsage")
+
+import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
+import org.gradle.api.tasks.testing.logging.TestExceptionFormat
+import org.gradle.api.tasks.testing.logging.TestLogEvent
+
+plugins {
+ kotlin("jvm") version "2.0.0"
+ kotlin("plugin.serialization") version "2.0.0"
+ id("io.ktor.plugin") version "3.0.0-beta-2"
+ id("com.github.johnrengelman.shadow") version "7.1.2"
+ id("org.jlleitschuh.gradle.ktlint") version "12.1.1"
+ application
+}
+
+repositories {
+ mavenCentral()
+}
+
+java {
+ toolchain {
+ languageVersion.set(JavaLanguageVersion.of(22))
+ }
+}
+
+testing {
+ suites {
+ val test by getting(JvmTestSuite::class) {
+ useKotlinTest("2.0.0")
+ testType = TestSuiteType.UNIT_TEST
+
+ dependencies {
+ implementation("io.ktor:ktor-server-test-host")
+ }
+ }
+
+ register("integrationTest") {
+ useKotlinTest("2.0.0")
+ testType = TestSuiteType.INTEGRATION_TEST
+
+ dependencies {
+ implementation(project())
+ }
+
+ targets {
+ all {
+ testTask.configure {
+ shouldRunAfter(test)
+ }
+ }
+ }
+ }
+ }
+}
+
+tasks.withType {
+ testLogging {
+ events = TestLogEvent.values().toSet() - TestLogEvent.STARTED
+ exceptionFormat = TestExceptionFormat.FULL
+ }
+ outputs.upToDateWhen { false }
+}
+
+tasks.named("check") {
+ dependsOn(testing.suites.named("test"))
+ dependsOn(testing.suites.named("integrationTest"))
+}
+
+tasks.withType {
+ mergeServiceFiles {
+ setPath("META-INF/services/org.flywaydb.core.extensibility.Plugin")
+ }
+}
+
+dependencies {
+ implementation("io.ktor:ktor-server-core")
+ implementation("io.ktor:ktor-server-netty")
+ implementation("io.ktor:ktor-server-call-logging")
+ implementation("io.ktor:ktor-server-call-id")
+ implementation("io.ktor:ktor-server-forwarded-header")
+ implementation("io.ktor:ktor-server-content-negotiation")
+ implementation("io.ktor:ktor-serialization-kotlinx-json")
+ implementation("io.ktor:ktor-server-mustache")
+ implementation("ch.qos.logback:logback-classic:1.5.6")
+ implementation("org.flywaydb:flyway-core:10.16.0")
+ implementation("org.flywaydb:flyway-database-postgresql:10.15.2")
+ implementation(platform("org.jdbi:jdbi3-bom:3.45.2"))
+ implementation("org.postgresql:postgresql:42.7.3")
+ implementation("org.jdbi:jdbi3-core")
+ implementation("org.jdbi:jdbi3-sqlobject")
+ implementation("org.jdbi:jdbi3-kotlin")
+ implementation("org.jdbi:jdbi3-kotlin-sqlobject")
+ implementation("net.logstash.logback:logstash-logback-encoder:7.4")
+}
+
+application {
+ mainClass = "com.photofox.MainKt"
+}
diff --git a/api/app/src/integrationTest/kotlin/com/photofox/SenseCheck.kt b/api/app/src/integrationTest/kotlin/com/photofox/SenseCheck.kt
new file mode 100644
index 0000000..306a4a2
--- /dev/null
+++ b/api/app/src/integrationTest/kotlin/com/photofox/SenseCheck.kt
@@ -0,0 +1,13 @@
+package com.photofox
+
+import kotlin.test.Test
+import kotlin.test.assertFalse
+import kotlin.test.assertTrue
+
+class SenseCheck {
+ @Test
+ fun `sense check`() {
+ assertTrue(true)
+ assertFalse(false)
+ }
+}
diff --git a/api/app/src/main/kotlin/com/photofox/Logger.kt b/api/app/src/main/kotlin/com/photofox/Logger.kt
new file mode 100644
index 0000000..ba6bbec
--- /dev/null
+++ b/api/app/src/main/kotlin/com/photofox/Logger.kt
@@ -0,0 +1,8 @@
+package com.photofox
+
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+inline fun logger(): Logger {
+ return LoggerFactory.getLogger(T::class.java)
+}
diff --git a/api/app/src/main/kotlin/com/photofox/Main.kt b/api/app/src/main/kotlin/com/photofox/Main.kt
new file mode 100644
index 0000000..74364fb
--- /dev/null
+++ b/api/app/src/main/kotlin/com/photofox/Main.kt
@@ -0,0 +1,150 @@
+package com.photofox
+
+import com.github.mustachejava.DefaultMustacheFactory
+import com.photofox.page.PageResponse
+import com.photofox.page.PageResponsePlugin
+import io.ktor.http.HttpHeaders
+import io.ktor.serialization.kotlinx.json.json
+import io.ktor.server.application.Application
+import io.ktor.server.application.install
+import io.ktor.server.engine.embeddedServer
+import io.ktor.server.http.content.staticFiles
+import io.ktor.server.mustache.Mustache
+import io.ktor.server.netty.Netty
+import io.ktor.server.plugins.callid.CallId
+import io.ktor.server.plugins.callid.callIdMdc
+import io.ktor.server.plugins.calllogging.CallLogging
+import io.ktor.server.plugins.calllogging.CallLoggingConfig
+import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
+import io.ktor.server.plugins.origin
+import io.ktor.server.request.host
+import io.ktor.server.request.httpMethod
+import io.ktor.server.request.path
+import io.ktor.server.request.port
+import io.ktor.server.request.uri
+import io.ktor.server.request.userAgent
+import io.ktor.server.response.respond
+import io.ktor.server.response.respondText
+import io.ktor.server.routing.RoutingCall
+import io.ktor.server.routing.get
+import io.ktor.server.routing.route
+import io.ktor.server.routing.routing
+import java.io.File
+import java.nio.file.Paths
+import java.util.UUID
+
+val logger = logger()
+
+fun main() {
+ logger.info("starting...")
+
+ val port = System.getenv()["APP_PORT"]?.toInt() ?: 8080
+ val host = System.getenv()["APP_HOST"] ?: "127.0.0.1"
+ embeddedServer(
+ Netty,
+ port = port,
+ host = host,
+ module = Application::module,
+ ).start(wait = true)
+
+ logger.info("stopped")
+}
+
+fun Application.module() {
+ configurePlugins()
+ configureRouting()
+}
+
+private fun Application.configurePlugins() {
+ install(CallId) {
+ header(HttpHeaders.XRequestId)
+ generate {
+ UUID.randomUUID().toString() // todo: uuidv7
+ }
+ }
+ install(CallLogging) {
+ disableDefaultColors()
+ setUpCallLoggingMDC()
+ }
+ install(ContentNegotiation) {
+ json()
+ }
+ install(Mustache) {
+ val templatesRoot = Paths.get("templates").toFile()
+ mustacheFactory = DefaultMustacheFactory(templatesRoot)
+ }
+ install(PageResponsePlugin)
+}
+
+private fun CallLoggingConfig.setUpCallLoggingMDC() {
+ mdc("http.method") {
+ it.request.httpMethod.value
+ }
+ mdc("http.url") {
+ it.request.uri
+ }
+ mdc("http.useragent") {
+ it.request.userAgent()
+ }
+ mdc("http.url_details.host") {
+ it.request.host()
+ }
+ mdc("http.url_details.port") {
+ it.request.port().toString()
+ }
+ mdc("http.url_details.path") {
+ it.request.path()
+ }
+ mdc("http.status_code") {
+ it.response.status()?.value?.toString()
+ }
+ mdc("network.client.network_ip") {
+ it.request.origin.remoteHost
+ }
+ mdc("network.client.ip") {
+ it.request.origin.remoteHost
+ }
+ callIdMdc("http.request_id")
+}
+
+private fun Application.configureRouting() {
+ val webPathPrefix = System.getenv()["WEB_PATH_PREFIX"] ?: "web"
+ routing {
+ route("/api") {
+ get("/health") {
+ call.respondText("🦊📸")
+ }
+ }
+ route("/$webPathPrefix") {
+ get("/") {
+ call.respondPage("index")
+ }
+ staticFiles("/static", File("static"))
+ }
+ }
+}
+
+suspend fun RoutingCall.respondPage(
+ pageTemplateName: String,
+ viewModel: ViewModel,
+) {
+ return this.respond(
+ PageResponse(
+ makePageTemplatePath(pageTemplateName),
+ viewModel,
+ ),
+ )
+}
+
+suspend fun RoutingCall.respondPage(pageTemplateName: String) {
+ return this.respond(
+ PageResponse(
+ makePageTemplatePath(pageTemplateName),
+ Unit,
+ ),
+ )
+}
+
+private fun makePageTemplatePath(pageTemplateName: String): String {
+ return "page/$pageTemplateName.mustache"
+}
diff --git a/api/app/src/main/kotlin/com/photofox/MigrationRunner.kt b/api/app/src/main/kotlin/com/photofox/MigrationRunner.kt
new file mode 100644
index 0000000..a93c1fb
--- /dev/null
+++ b/api/app/src/main/kotlin/com/photofox/MigrationRunner.kt
@@ -0,0 +1,22 @@
+package com.photofox
+
+import org.flywaydb.core.Flyway
+import javax.sql.DataSource
+
+object MigrationRunner {
+ private val logger = logger()
+
+ fun run(dataSource: DataSource) {
+ logger.info("running migrations...")
+
+ val flyway = Flyway.configure()
+ .dataSource(dataSource)
+ .baselineOnMigrate(true)
+ .validateMigrationNaming(true)
+ .load()
+
+ flyway.migrate()
+
+ logger.info("done")
+ }
+}
diff --git a/api/app/src/main/kotlin/com/photofox/page/PageResponse.kt b/api/app/src/main/kotlin/com/photofox/page/PageResponse.kt
new file mode 100644
index 0000000..e88477a
--- /dev/null
+++ b/api/app/src/main/kotlin/com/photofox/page/PageResponse.kt
@@ -0,0 +1,6 @@
+package com.photofox.page
+
+data class PageResponse(
+ val templatePath: String,
+ val viewModel: ViewModel,
+)
diff --git a/api/app/src/main/kotlin/com/photofox/page/PageResponsePlugin.kt b/api/app/src/main/kotlin/com/photofox/page/PageResponsePlugin.kt
new file mode 100644
index 0000000..b0ebe77
--- /dev/null
+++ b/api/app/src/main/kotlin/com/photofox/page/PageResponsePlugin.kt
@@ -0,0 +1,38 @@
+package com.photofox.page
+
+import io.ktor.http.CacheControl
+import io.ktor.server.application.ApplicationCallPipeline
+import io.ktor.server.application.BaseApplicationPlugin
+import io.ktor.server.mustache.MustacheContent
+import io.ktor.server.response.ApplicationSendPipeline
+import io.ktor.server.response.cacheControl
+import io.ktor.util.AttributeKey
+
+/**
+ * Provides a way to set cache control hints on template responses (which shouldn't be cached)
+ */
+class PageResponsePlugin {
+ companion object Plugin : BaseApplicationPlugin {
+ override val key = AttributeKey("PageResponse")
+
+ override fun install(
+ pipeline: ApplicationCallPipeline,
+ configure: Any.() -> Unit,
+ ): Plugin {
+ pipeline.sendPipeline.intercept(ApplicationSendPipeline.Before) { value ->
+ if (value is PageResponse<*>) {
+ context.response.cacheControl(
+ CacheControl.MaxAge(
+ maxAgeSeconds = 0,
+ visibility = CacheControl.Visibility.Private,
+ mustRevalidate = true,
+ ),
+ )
+ val response = MustacheContent(value.templatePath, value.viewModel)
+ proceedWith(response)
+ }
+ }
+ return this
+ }
+ }
+}
diff --git a/api/app/src/main/kotlin/com/photofox/processed/.gitkeep b/api/app/src/main/kotlin/com/photofox/processed/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/api/app/src/main/resources/db/migration/V1__test.sql b/api/app/src/main/resources/db/migration/V1__test.sql
new file mode 100644
index 0000000..d0147c8
--- /dev/null
+++ b/api/app/src/main/resources/db/migration/V1__test.sql
@@ -0,0 +1,5 @@
+CREATE TABLE test
+(
+ id uuid primary key,
+ text text not null
+);
\ No newline at end of file
diff --git a/api/app/src/main/resources/logback.xml b/api/app/src/main/resources/logback.xml
new file mode 100644
index 0000000..b66aee9
--- /dev/null
+++ b/api/app/src/main/resources/logback.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/api/app/src/test/kotlin/SenseCheck.kt b/api/app/src/test/kotlin/SenseCheck.kt
new file mode 100644
index 0000000..397b9d6
--- /dev/null
+++ b/api/app/src/test/kotlin/SenseCheck.kt
@@ -0,0 +1,11 @@
+import kotlin.test.Test
+import kotlin.test.assertFalse
+import kotlin.test.assertTrue
+
+class SenseCheck {
+ @Test
+ fun `sense check`() {
+ assertTrue(true)
+ assertFalse(false)
+ }
+}
diff --git a/api/build_docker_image.sh b/api/build_docker_image.sh
new file mode 100755
index 0000000..7d56b6e
--- /dev/null
+++ b/api/build_docker_image.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+set -eou pipefail
+
+CONTAINER_TAG="${CONTAINER_TAG:-test}"
+
+./gradlew clean check shadowJar
+./compile-assets.main.kts
+
+JAR=$(find app/build/libs/*-all.jar | head -n1)
+
+docker build \
+ --build-arg jar="$JAR" \
+ --build-arg static_assets="build/static" \
+ --build-arg template_assets="build/templates" \
+ --build-arg version="$CONTAINER_TAG" \
+ -t "ghcr.io/lopcode/photo-fox:$CONTAINER_TAG" \
+ .
\ No newline at end of file
diff --git a/api/compile-assets.main.kts b/api/compile-assets.main.kts
new file mode 100755
index 0000000..0e9e108
--- /dev/null
+++ b/api/compile-assets.main.kts
@@ -0,0 +1,138 @@
+#!/usr/bin/env kotlin
+
+@file:CompilerOptions("-jvm-target", "1.8")
+
+import java.io.File
+import java.io.IOException
+import java.nio.file.Files
+import java.nio.file.NoSuchFileException
+import java.nio.file.StandardCopyOption
+import java.nio.file.Path
+import java.nio.file.Paths
+import java.security.MessageDigest
+import java.util.stream.Collectors
+import kotlin.system.exitProcess
+
+fun ByteArray.toHexRepresentation(): String {
+ return joinToString("") { "%02x".format(it) }
+}
+
+fun ByteArray.sha256(): String {
+ val messageDigest = MessageDigest.getInstance("SHA-256")
+ messageDigest.update(this)
+ val digest = messageDigest.digest()
+ return digest.toHexRepresentation()
+}
+
+fun walkFilesInPath(path: String): List {
+ if (!Files.exists(Paths.get(path))) {
+ return listOf()
+ }
+ return try {
+ Files.walk(Paths.get(path))
+ .filter { !Files.isHidden(it) }
+ .filter { Files.isRegularFile(it) }
+ .collect(Collectors.toList())
+ } catch (exception: IOException) {
+ println("$path folder not accessible (does it exist?)")
+ exitProcess(1)
+ }
+}
+
+fun deleteFilesInPath(path: Path) {
+ try {
+ Files.walk(path)
+ .map { it.toFile() }
+ .sorted(Comparator.reverseOrder())
+ .forEach(File::delete)
+ } catch (exception: NoSuchFileException) {
+ return
+ } catch (exception: IOException) {
+ println("failed to delete files in $path $exception")
+ exitProcess(1)
+ }
+}
+
+val files = walkFilesInPath("static")
+val buildPath = Paths.get("build")
+val staticBuildPath = buildPath.resolve("static")
+val templateBuildPath = buildPath.resolve("templates")
+deleteFilesInPath(staticBuildPath)
+deleteFilesInPath(templateBuildPath)
+Files.createDirectories(staticBuildPath)
+Files.createDirectories(templateBuildPath)
+
+data class Candidate(
+ val original: Path,
+ val checksummed: Path
+)
+
+val staticCandidates = files.mapNotNull {
+ val checksum = it.toFile().readBytes().sha256().take(6)
+ if (checksum.length < 6) {
+ println("bad checksum: $checksum $it")
+ return@mapNotNull null
+ }
+ val path = it.toString()
+ val lastPeriodIndex = path.lastIndexOf(".")
+ if (lastPeriodIndex <= 0 || lastPeriodIndex > path.length - 1) {
+ println("unexpected file extension: $it")
+ return@mapNotNull null
+ }
+
+ val builder = StringBuilder(path)
+ builder.insert(lastPeriodIndex + 1, "${checksum}.")
+ val checksummedFilename = builder.toString()
+ val candidate = Paths.get(checksummedFilename)
+
+ return@mapNotNull Candidate(
+ it,
+ candidate
+ )
+}
+
+if (staticCandidates.isEmpty()) {
+ println("nothing to do")
+ exitProcess(0)
+}
+
+staticCandidates.forEach {
+ val replacementChecksumFile = buildPath.resolve(it.checksummed)
+ val backupFile = buildPath.resolve(it.original)
+ println("copying ${it.original}")
+ Files.createDirectories(backupFile.parent)
+ Files.copy(it.original, backupFile, StandardCopyOption.REPLACE_EXISTING)
+ Files.copy(it.original, replacementChecksumFile, StandardCopyOption.REPLACE_EXISTING)
+}
+
+val originalTemplatePaths = walkFilesInPath("templates")
+originalTemplatePaths.forEach {
+ println("copying template: $it")
+ val replacementTemplateFile = buildPath.resolve(it)
+ Files.createDirectories(replacementTemplateFile.parent)
+ Files.copy(it, replacementTemplateFile, StandardCopyOption.REPLACE_EXISTING)
+}
+val templatePaths = walkFilesInPath("build/templates")
+val cssPaths = walkFilesInPath("build/static/css")
+val jsPaths = walkFilesInPath("build/static/js")
+val codePaths = walkFilesInPath("app/src/main/kotlin/com/photofox/processed")
+
+val pathsToProcess = templatePaths + cssPaths + jsPaths + codePaths
+pathsToProcess.forEach {
+ println("found file to process: $it")
+}
+
+pathsToProcess.forEach { path ->
+ val file = path.toFile()
+ var fileText = file.readText(Charsets.UTF_8)
+
+ staticCandidates.forEach { candidate ->
+ val originalPath = "/${candidate.original.toString().removePrefix("/")}"
+ val checksummedPath = "/${candidate.checksummed.toString().removePrefix("/")}"
+
+ fileText = fileText.replace(originalPath, checksummedPath)
+ }
+
+ file.writeText(fileText)
+ println("processed $path")
+}
\ No newline at end of file
diff --git a/api/gradle.properties b/api/gradle.properties
new file mode 100644
index 0000000..18f452c
--- /dev/null
+++ b/api/gradle.properties
@@ -0,0 +1,6 @@
+# This file was generated by the Gradle 'init' task.
+# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
+
+org.gradle.parallel=true
+org.gradle.caching=true
+
diff --git a/api/gradle/wrapper/gradle-wrapper.jar b/api/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..2c35211
Binary files /dev/null and b/api/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/api/gradle/wrapper/gradle-wrapper.properties b/api/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..09523c0
--- /dev/null
+++ b/api/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/api/gradlew b/api/gradlew
new file mode 100755
index 0000000..f5feea6
--- /dev/null
+++ b/api/gradlew
@@ -0,0 +1,252 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
+' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/api/gradlew.bat b/api/gradlew.bat
new file mode 100644
index 0000000..9d21a21
--- /dev/null
+++ b/api/gradlew.bat
@@ -0,0 +1,94 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/api/settings.gradle.kts b/api/settings.gradle.kts
new file mode 100644
index 0000000..976a288
--- /dev/null
+++ b/api/settings.gradle.kts
@@ -0,0 +1,15 @@
+/*
+ * This file was generated by the Gradle 'init' task.
+ *
+ * The settings file is used to specify which projects to include in your build.
+ * For more detailed information on multi-project builds, please refer to https://docs.gradle.org/8.9/userguide/multi_project_builds.html in the Gradle documentation.
+ * This project uses @Incubating APIs which are subject to change.
+ */
+
+plugins {
+ // Apply the foojay-resolver plugin to allow automatic download of JDKs
+ id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
+}
+
+rootProject.name = "photo-fox-api"
+include("app")
diff --git a/api/static/css/normalize.css b/api/static/css/normalize.css
new file mode 100644
index 0000000..6d1403e
--- /dev/null
+++ b/api/static/css/normalize.css
@@ -0,0 +1,349 @@
+/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
+
+/* Document
+ ========================================================================== */
+
+/**
+ * 1. Correct the line height in all browsers.
+ * 2. Prevent adjustments of font size after orientation changes in iOS.
+ */
+
+html {
+ line-height: 1.15; /* 1 */
+ -webkit-text-size-adjust: 100%; /* 2 */
+}
+
+/* Sections
+ ========================================================================== */
+
+/**
+ * Remove the margin in all browsers.
+ */
+
+body {
+ margin: 0;
+}
+
+/**
+ * Render the `main` element consistently in IE.
+ */
+
+main {
+ display: block;
+}
+
+/**
+ * Correct the font size and margin on `h1` elements within `section` and
+ * `article` contexts in Chrome, Firefox, and Safari.
+ */
+
+h1 {
+ font-size: 2em;
+ margin: 0.67em 0;
+}
+
+/* Grouping content
+ ========================================================================== */
+
+/**
+ * 1. Add the correct box sizing in Firefox.
+ * 2. Show the overflow in Edge and IE.
+ */
+
+hr {
+ box-sizing: content-box; /* 1 */
+ height: 0; /* 1 */
+ overflow: visible; /* 2 */
+}
+
+/**
+ * 1. Correct the inheritance and scaling of font size in all browsers.
+ * 2. Correct the odd `em` font sizing in all browsers.
+ */
+
+pre {
+ font-family: monospace, monospace; /* 1 */
+ font-size: 1em; /* 2 */
+}
+
+/* Text-level semantics
+ ========================================================================== */
+
+/**
+ * Remove the gray background on active links in IE 10.
+ */
+
+a {
+ background-color: transparent;
+}
+
+/**
+ * 1. Remove the bottom border in Chrome 57-
+ * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
+ */
+
+abbr[title] {
+ border-bottom: none; /* 1 */
+ text-decoration: underline; /* 2 */
+ text-decoration: underline dotted; /* 2 */
+}
+
+/**
+ * Add the correct font weight in Chrome, Edge, and Safari.
+ */
+
+b,
+strong {
+ font-weight: bolder;
+}
+
+/**
+ * 1. Correct the inheritance and scaling of font size in all browsers.
+ * 2. Correct the odd `em` font sizing in all browsers.
+ */
+
+code,
+kbd,
+samp {
+ font-family: monospace, monospace; /* 1 */
+ font-size: 1em; /* 2 */
+}
+
+/**
+ * Add the correct font size in all browsers.
+ */
+
+small {
+ font-size: 80%;
+}
+
+/**
+ * Prevent `sub` and `sup` elements from affecting the line height in
+ * all browsers.
+ */
+
+sub,
+sup {
+ font-size: 75%;
+ line-height: 0;
+ position: relative;
+ vertical-align: baseline;
+}
+
+sub {
+ bottom: -0.25em;
+}
+
+sup {
+ top: -0.5em;
+}
+
+/* Embedded content
+ ========================================================================== */
+
+/**
+ * Remove the border on images inside links in IE 10.
+ */
+
+img {
+ border-style: none;
+}
+
+/* Forms
+ ========================================================================== */
+
+/**
+ * 1. Change the font styles in all browsers.
+ * 2. Remove the margin in Firefox and Safari.
+ */
+
+button,
+input,
+optgroup,
+select,
+textarea {
+ font-family: inherit; /* 1 */
+ font-size: 100%; /* 1 */
+ line-height: 1.15; /* 1 */
+ margin: 0; /* 2 */
+}
+
+/**
+ * Show the overflow in IE.
+ * 1. Show the overflow in Edge.
+ */
+
+button,
+input { /* 1 */
+ overflow: visible;
+}
+
+/**
+ * Remove the inheritance of text transform in Edge, Firefox, and IE.
+ * 1. Remove the inheritance of text transform in Firefox.
+ */
+
+button,
+select { /* 1 */
+ text-transform: none;
+}
+
+/**
+ * Correct the inability to style clickable types in iOS and Safari.
+ */
+
+button,
+[type="button"],
+[type="reset"],
+[type="submit"] {
+ -webkit-appearance: button;
+}
+
+/**
+ * Remove the inner border and padding in Firefox.
+ */
+
+button::-moz-focus-inner,
+[type="button"]::-moz-focus-inner,
+[type="reset"]::-moz-focus-inner,
+[type="submit"]::-moz-focus-inner {
+ border-style: none;
+ padding: 0;
+}
+
+/**
+ * Restore the focus styles unset by the previous rule.
+ */
+
+button:-moz-focusring,
+[type="button"]:-moz-focusring,
+[type="reset"]:-moz-focusring,
+[type="submit"]:-moz-focusring {
+ outline: 1px dotted ButtonText;
+}
+
+/**
+ * Correct the padding in Firefox.
+ */
+
+fieldset {
+ padding: 0.35em 0.75em 0.625em;
+}
+
+/**
+ * 1. Correct the text wrapping in Edge and IE.
+ * 2. Correct the color inheritance from `fieldset` elements in IE.
+ * 3. Remove the padding so developers are not caught out when they zero out
+ * `fieldset` elements in all browsers.
+ */
+
+legend {
+ box-sizing: border-box; /* 1 */
+ color: inherit; /* 2 */
+ display: table; /* 1 */
+ max-width: 100%; /* 1 */
+ padding: 0; /* 3 */
+ white-space: normal; /* 1 */
+}
+
+/**
+ * Add the correct vertical alignment in Chrome, Firefox, and Opera.
+ */
+
+progress {
+ vertical-align: baseline;
+}
+
+/**
+ * Remove the default vertical scrollbar in IE 10+.
+ */
+
+textarea {
+ overflow: auto;
+}
+
+/**
+ * 1. Add the correct box sizing in IE 10.
+ * 2. Remove the padding in IE 10.
+ */
+
+[type="checkbox"],
+[type="radio"] {
+ box-sizing: border-box; /* 1 */
+ padding: 0; /* 2 */
+}
+
+/**
+ * Correct the cursor style of increment and decrement buttons in Chrome.
+ */
+
+[type="number"]::-webkit-inner-spin-button,
+[type="number"]::-webkit-outer-spin-button {
+ height: auto;
+}
+
+/**
+ * 1. Correct the odd appearance in Chrome and Safari.
+ * 2. Correct the outline style in Safari.
+ */
+
+[type="search"] {
+ -webkit-appearance: textfield; /* 1 */
+ outline-offset: -2px; /* 2 */
+}
+
+/**
+ * Remove the inner padding in Chrome and Safari on macOS.
+ */
+
+[type="search"]::-webkit-search-decoration {
+ -webkit-appearance: none;
+}
+
+/**
+ * 1. Correct the inability to style clickable types in iOS and Safari.
+ * 2. Change font properties to `inherit` in Safari.
+ */
+
+::-webkit-file-upload-button {
+ -webkit-appearance: button; /* 1 */
+ font: inherit; /* 2 */
+}
+
+/* Interactive
+ ========================================================================== */
+
+/*
+ * Add the correct display in Edge, IE 10+, and Firefox.
+ */
+
+details {
+ display: block;
+}
+
+/*
+ * Add the correct display in all browsers.
+ */
+
+summary {
+ display: list-item;
+}
+
+/* Misc
+ ========================================================================== */
+
+/**
+ * Add the correct display in IE 10+.
+ */
+
+template {
+ display: none;
+}
+
+/**
+ * Add the correct display in IE 10.
+ */
+
+[hidden] {
+ display: none;
+}
diff --git a/api/static/css/style.css b/api/static/css/style.css
new file mode 100644
index 0000000..e822f97
--- /dev/null
+++ b/api/static/css/style.css
@@ -0,0 +1 @@
+@import "normalize.css";
\ No newline at end of file
diff --git a/api/templates/page/index.mustache b/api/templates/page/index.mustache
new file mode 100644
index 0000000..0aafdaa
--- /dev/null
+++ b/api/templates/page/index.mustache
@@ -0,0 +1,11 @@
+
+
+
+
+
+ photo fox
+
+
+ hello, photo fox 🦊📸
+
+
\ No newline at end of file