← Back to all products
$29
Survey Engine
Create, deploy, and analyze surveys with branching logic in pure Python.
JSONMarkdownPython
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 10 files
survey-engine/
├── LICENSE
├── README.md
├── examples/
│ └── nps_survey.json
├── free-sample.zip
├── guide/
│ ├── 01_features.md
│ ├── 02_cli-reference.md
│ ├── 03_programmatic-usage.md
│ └── 04_file-structure.md
├── index.html
└── src/
└── survey_engine.py
📖 Documentation Preview README excerpt
Survey Engine
Create, deploy, and analyze surveys with branching logic — pure Python, zero dependencies.
Part of the [Form Forge](https://form-forge.codevault.dev) toolkit by CodeVault.
Features
- 10 question types: text, long_text, single_choice, multiple_choice, rating, scale, yes_no, email, number, date
- Branching logic: conditional jumps based on answers (equals, contains, greater_than, less_than operators)
- Interactive CLI runner: terminal-based survey experience with validation and branch navigation
- Response persistence: save/load responses as JSON files, one per respondent
- Built-in analytics: completion rate, per-question breakdowns, frequency analysis, statistical aggregates (mean, median, stdev)
- JSON-driven definitions: define surveys as JSON, load and run them programmatically
- Python 3.10+ stdlib only — no pip installs required
Quick Start
# Run the built-in demo survey
python src/survey_engine.py --demo
# Run a custom survey from JSON
python src/survey_engine.py --run examples/nps_survey.json
# Analyze collected responses
python src/survey_engine.py --analyze examples/nps_survey.json
CLI Reference
| Flag | Description |
|---|---|
--run FILE | Run a survey interactively from a JSON definition |
--analyze FILE | Analyze collected responses for a survey |
--responses-dir DIR | Directory containing response JSON files (default: responses/) |
--demo | Run a built-in demo NPS survey |
Survey JSON Format
{
"id": "customer-feedback",
"title": "Customer Feedback Survey",
"description": "Help us improve our product.",
"questions": [
{
"id": "q1",
"text": "How likely are you to recommend us? (0-10)",
"type": "scale",
"required": true,
"minValue": 0,
"maxValue": 10
},
{
"id": "q2",
"text": "What do you like most?",
"type": "single_choice",
"choices": ["Speed", "Simplicity", "Features", "Price"],
"branches": [
*... continues with setup instructions, usage examples, and more.*
📄 Code Sample .py preview
src/survey_engine.py
#!/usr/bin/env python3
"""
Survey Engine — Create, Deploy, and Analyze Surveys
====================================================
Build surveys with branching logic, collect responses as JSON,
and generate analytics reports. Supports conditional question
paths, skip logic, and piping (inserting previous answers).
Part of the Form Forge toolkit by DataNest.
License: MIT
"""
from __future__ import annotations
import argparse
import csv
import hashlib
import html
import json
import logging
import os
import statistics
import sys
import time
from dataclasses import dataclass, field
from datetime import datetime, timezone
from enum import Enum
from pathlib import Path
from typing import Any
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
logger = logging.getLogger(__name__)
# ---------------------------------------------------------------------------
# Constants
# ---------------------------------------------------------------------------
RESPONSE_DIR = "responses"
REPORT_DIR = "reports"
class QuestionType(Enum):
"""Supported question types."""
TEXT = "text"
LONG_TEXT = "long_text"
SINGLE_CHOICE = "single_choice"
MULTIPLE_CHOICE = "multiple_choice"
RATING = "rating"
SCALE = "scale" # 1-10 Likert
YES_NO = "yes_no"
EMAIL = "email"
# ... 452 more lines ...