Skip to content

Containerized

You can import the story-schematics service as a container.

INFO

This service requires an instance of JSON Keys to run.

yaml
# https://github.com/containers/podman-compose
services:
  json-keys-postgres:
    image: ghcr.io/a-novel/service-json-keys/database:v1.2.5
    networks:
      - api
    environment:
      POSTGRES_PASSWORD: postgres
      POSTGRES_USER: postgres
      POSTGRES_DB: json-keys
      POSTGRES_HOST_AUTH_METHOD: scram-sha-256
      POSTGRES_INITDB_ARGS: --auth=scram-sha-256
    volumes:
      - json-keys-postgres-data:/var/lib/postgresql/data/

  story-schematics-postgres:
    image: ghcr.io/a-novel/service-story-schematics/database:v1.0.3
    networks:
      - api
    environment:
      POSTGRES_PASSWORD: postgres
      POSTGRES_USER: postgres
      POSTGRES_DB: story-schematics
      POSTGRES_HOST_AUTH_METHOD: scram-sha-256
      POSTGRES_INITDB_ARGS: --auth=scram-sha-256
    volumes:
      - json-keys-postgres-data:/var/lib/postgresql/data/

  json-keys-service:
    image: ghcr.io/a-novel/service-json-keys/standalone:v1.2.5
    depends_on:
      json-keys-postgres:
        condition: service_healthy
    environment:
      POSTGRES_DSN: postgres://postgres:postgres@json-keys-postgres:5432/json-keys?sslmode=disable
      APP_MASTER_KEY: fec0681a2f57242211c559ca347721766f8a3acd8ed2e63b36b3768051c702ca
    networks:
      - api

  story-schematics-postgres-migrations:
    image: ghcr.io/a-novel/service-story-schematics/jobs/migrations:v1.0.3
    depends_on:
      story-schematics-postgres:
        condition: service_healthy
    networks:
      - api
    environment:
      POSTGRES_DSN: postgres://postgres:postgres@story-schematics-postgres:5432/json-keys?sslmode=disable

  story-schematics-service:
    image: ghcr.io/a-novel/service-story-schematics/api:v1.0.3
    depends_on:
      story-schematics-postgres:
        condition: service_healthy
      story-schematics-postgres-migrations:
        condition: service_completed_successfully
    environment:
      POSTGRES_DSN: postgres://postgres:postgres@story-schematics-postgres:5432/story-schematics?sslmode=disable
      JSON_KEYS_SERVICE_URL: http://json-keys-service:8080
      OPENAI_TOKEN: [your_groq_token]
    networks:
      - api

networks:
  api: {}

volumes:
  json-keys-postgres-data:
  story-schematics-postgres-data:

Standalone image (local)

For local development or CI purposes, you can also load a standalone version that runs all the necessary jobs before starting the service.

WARNING

The standalone image takes longer to boot, and it is not suited for production use.

yaml
# https://github.com/containers/podman-compose
services:
  json-keys-postgres:
    image: ghcr.io/a-novel/service-json-keys/database:v1.2.5
    networks:
      - api
    environment:
      POSTGRES_PASSWORD: postgres
      POSTGRES_USER: postgres
      POSTGRES_DB: json-keys
      POSTGRES_HOST_AUTH_METHOD: scram-sha-256
      POSTGRES_INITDB_ARGS: --auth=scram-sha-256
    volumes:
      - json-keys-postgres-data:/var/lib/postgresql/data/

  story-schematics-postgres:
    image: ghcr.io/a-novel/service-story-schematics/database:v1.0.3
    networks:
      - api
    environment:
      POSTGRES_PASSWORD: postgres
      POSTGRES_USER: postgres
      POSTGRES_DB: story-schematics
      POSTGRES_HOST_AUTH_METHOD: scram-sha-256
      POSTGRES_INITDB_ARGS: --auth=scram-sha-256
    volumes:
      - json-keys-postgres-data:/var/lib/postgresql/data/

  json-keys-service:
    image: ghcr.io/a-novel/service-json-keys/standalone:v1.2.5
    depends_on:
      json-keys-postgres:
        condition: service_healthy
    environment:
      POSTGRES_DSN: postgres://postgres:postgres@json-keys-postgres:5432/json-keys?sslmode=disable
      APP_MASTER_KEY: fec0681a2f57242211c559ca347721766f8a3acd8ed2e63b36b3768051c702ca
    networks:
      - api

  story-schematics-service:
    image: ghcr.io/a-novel/service-story-schematics/standalone:v1.0.3
    depends_on:
      story-schematics-postgres:
        condition: service_healthy
    environment:
      POSTGRES_DSN: postgres://postgres:postgres@story-schematics-postgres:5432/story-schematics?sslmode=disable
      JSON_KEYS_SERVICE_URL: http://json-keys-service:8080
      OPENAI_TOKEN: [your_groq_token]
    networks:
      - api

networks:
  api: {}

volumes:
  json-keys-postgres-data:
  story-schematics-postgres-data:

Configuration

Configuration is done through environment variables.

Required variables

You must provide the following variables for the service to run correctly.

VariableDescription
POSTGRES_DSNConnection string to the Postgres database.
JSON_KEYS_SERVICE_URLURL to the JSON Keys service, used for key management.
OPENAI_TOKENToken to authenticate with the Groq API.

Optional variables

Generic configuration.

VariableDescriptionDefault
APP_NAMEName of the application, used for tracing.story-schematics-service
ENVProvide information on the current environment.

API configuration.

VariableDescriptionDefault
API_PORTPort to run the API on.8080
API_MAX_REQUEST_SIZEMaximum request size for the API.
Provided as a number of bytes.
2MB
API_TIMEOUT_READRead timeout for the API.
Provided as a duration string.
5s
API_TIMEOUT_READ_HEADERHeader read timeout for the API.
Provided as a duration string.
3s
API_TIMEOUT_WRITEWrite timeout for the API.
Provided as a duration string.
10s
API_TIMEOUT_IDLEIdle timeout for the API.
Provided as a duration string.
30s
APITimeoutRequestRequest timeout for the API.
Provided as a duration string.
15s
API_CORS_ALLOWED_ORIGINSCORS allowed origins for the API.
Provided as a list of values separated by commas.
*
API_CORS_ALLOWED_HEADERSCORS allowed headers for the API.
Provided as a list of values separated by commas.
*
API_CORS_ALLOW_CREDENTIALSWhether to allow credentials in CORS requests.false
API_CORS_MAX_AGECORS max age for the API.
Provided as a number of seconds.
3600

Tracing configuration.

VariableDescriptionDefault
GCLOUD_PROJECT_IDA Google Cloud Platform project ID. Note this activate Google Cloud tracing.
PRETTY_CONSOLEWhen using local (default) tracing, set it to false to turn off colors in the console. Ineffective if GCLOUD_PROJECT_ID is settrue

We use Groq for AI processing. Their platform is based of OpenAI's API, so you can interchange them with an actual OpenAI token, or any other OpenAI-compatible API.

VariableDescriptionDefault
OPENAI_BASE_URLChange this URL to use a different OpenAI-compatible API."https://api.groq.com/openai/v1"
OPENAI_MODELSelect the AI model to use for chat completions. Available options may depend on your provider"meta-llama/llama-4-maverick-17b-128e-instruct"