npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@gv-sh/specgen-server

v0.14.0

Published

SpecGen Server - API for Speculative Fiction Generator

Readme

SpecGen Server

Version

A Node.js/Express API for generating speculative fiction stories using AI. Manages fiction categories and their parameters, and provides endpoints for generating content through OpenAI integration.

Project Structure

SpecGen consists of three modules:

  • Server (This Repository): Backend API
  • Admin UI: Interface for managing categories and parameters
  • User UI: Interface for generating stories

Features

  • RESTful API for managing fiction categories and parameters
  • OpenAI integration for fiction and image generation
  • Configurable AI settings (models, parameters, prompts)
  • Swagger API documentation
  • JSON file-based data storage
  • Parameter validation and type handling

Quick Start

Prerequisites

  • Node.js (v14+)
  • npm
  • OpenAI API key

Installation

  1. Clone the repository

  2. Install dependencies:

    npm install
  3. Create a .env file:

 OPENAI_API_KEY=your_key_here
 PORT=3000
 NODE_ENV=development

Starting the Server

# Development mode with auto-restart
npm run dev

# Production mode
npm start

Initialize Sample Data (Optional)

npm run init-db

API Documentation

Access the Swagger UI documentation at http://localhost:3000/api-docs when the server is running.

API Specification

You can generate a static API specification file using:

npm run generate-api-spec

This will create an api-spec.json file in the root directory, which can be used by frontend applications for:

  • Type generation (with tools like openapi-typescript)
  • API client generation
  • Mock server setup
  • Documentation

Core Endpoints

Categories

  • GET /api/categories - List all categories
  • POST /api/categories - Create a category
  • GET /api/categories/:id - Get a category
  • PUT /api/categories/:id - Update a category
  • DELETE /api/categories/:id - Delete a category

Parameters

  • GET /api/parameters - List all parameters
  • POST /api/parameters - Create a parameter
  • GET /api/parameters/:id - Get a parameter
  • PUT /api/parameters/:id - Update a parameter
  • DELETE /api/parameters/:id - Delete a parameter

Generation

  • POST /api/generate - Generate fiction based on parameters

Settings

  • GET /api/settings - Get all application settings
  • PUT /api/settings - Update application settings
  • POST /api/settings/reset - Reset settings to defaults

Database Management

  • GET /api/database/download - Get database content
  • POST /api/database/restore - Restore database from file
  • POST /api/database/reset - Reset database to empty state

Content

  • GET /api/content - List all generated content
  • GET /api/content/:id - Get a specific generated content
  • PUT /api/content/:id - Update generated content
  • DELETE /api/content/:id - Delete generated content

Parameter Types

The system supports various parameter types for story configuration:

  • Dropdown: Selection from 4-12 values
  • Slider: Numeric value with min/max range
  • Toggle Switch: Boolean choice (yes/no)
  • Radio Buttons: Mutually exclusive options
  • Checkbox: Multiple selectable options

Settings Configuration

The application includes configurable settings for AI generation:

AI Models

  • Fiction generation model (default: gpt-4o-mini)
  • Image generation model (default: dall-e-3)

Fiction Parameters

  • Temperature (default: 0.8)
  • Maximum tokens (default: 1000)
  • Default story length (default: 500 words)
  • System prompt for AI

Image Parameters

  • Image size (default: 1024x1024)
  • Image quality (default: standard)
  • Default prompt suffix

Default Settings

  • Default content type (fiction or image)

See the settings documentation for more details on available configuration options and example values.

Development

Running Tests

npm test

Linting

npm run lint

Architecture

  • Controllers: Handle HTTP requests and responses
  • Services: Provide core business logic
  • Routes: Define API endpoints
  • Middleware: Process requests
  • Data: JSON-based storage

Deployment

For deployment on a Digital Ocean Ubuntu droplet, use the provided deployment scripts in the deploy directory:

  1. deploy.sh: Main deployment script for server setup and application installation
  2. nginx-specgen.conf: Nginx configuration for hosting all components
  3. ecosystem.config.js: PM2 configuration for process management

See the deployment guide for detailed instructions.

License

ISC