Sign inSign up

dturkuler/hddata_api

By dturkuler

β€’Updated 4 months ago

Image
0

2.0K

dturkuler/hddata_api repository overview

⁠Human Design Database & Analysis Tool

A powerful relational database and automation engine for Human Design analysis. This project maps raw astronomical coordinates from specialized APIs to a deep internal database of Human Design definitions, generating comprehensive, multi-layered reports for developers and wellness practitioners.

Instead of just calculating planetary positions, hddata_api provides the semantic layerβ€”explaining the meaning, biology, and mechanics behind every activation in a Human Design chart.

β πŸš€ Core Functionalities

  • Semantic Mapping: Bridges raw birth data (Gates, Lines, etc.) with thousands of high-quality definitions for Centers, Channels, Authorities, and more.
  • Dual-Content Strategy: Native support for toggling between Standard (Technical) and Simple (No-Jargon) content via separate database schemas.
  • Selective Reporting: Generate highly targeted reports by choosing specific sections (e.g., only Variables or only Centers) via CLI flags or API parameters.
  • Advanced Mechanics: Access deeper data layers like Bases, Tones, and Colors for clinical or professional-grade analysis.
  • Multi-Database Support: Parity between PostgreSQL (production) and SQLite (local/embedded development).
  • Automation Suite: Unified CLI tool (run_hd.js) and Fastify-powered Web API for seamless integration.

⁠🧬 Supported Human Design Elements

This API provides a deep knowledge base for the following HD mechanics:

⁠1. Foundation & Personality
  • The 5 Types: Manifestor, Generator, Manifesting Generator, Projector, Reflector.
  • Authorities: Emotional, Sacral, Splenic, Ego, G-Center, Mental, and Lunar.
  • 12 Profiles: Complete analysis for all profile codes (e.g., 1/3, 4/6, 2/4).
  • Incarnation Crosses: High-level life purpose summaries based on Sun/Earth positions.
⁠2. Circuitry & Energy Centers
  • 9 Centers: Detailed functions and descriptions (Head to Root).
  • 36 Channels: Full mapping of channel types, circuits, and design purposes.
  • 64 Gates: Summary, biology, and associated deities for every gate.
  • 384 Lines: High-resolution descriptions for every line activation.
⁠3. PHS & Variables (Four Transformations)
  • Digestion (Internal): Dietary regimes and metabolic focus.
  • Environment (External): Ideal physical landscape and surroundings.
  • Perspective (View): How the personality is designed to perceive the world.
  • Motivation (Mind): The underlying drive for mental activity.
⁠4. Advanced Mechanics
  • Sub-structure: Detailed data for Bases, Tones, and Colors.
  • Dream Rave: Analysis of the design during sleep states.
  • Global Cycles: Long-term environmental and evolutionary themes.

⁠🌐 Web API (v0.4.0+)

The project includes a built-in Fastify-powered API for programmatic access to Human Design analysis.

⁠Features
  • Fastify Framework: High-performance, low-overhead Node.js server.
  • OpenAPI / Swagger: Interactive documentation automatically hosted at /docs.
  • Validation: Strict JSON Schema validation for all birth parameters.
  • Selective Reporting: Request specific chart sections to optimize payload size.
  • Authentication: Secured via API Token or Bearer Token.
⁠Getting Started
  1. Start the API Server:

    node src/server.js
    

    By default, the server runs on http://localhost:3000.

  2. Access Interactive Docs: Open http://localhost:3000/docs⁠ in your browser to view the Swagger UI and test endpoints directly.

⁠Main Endpoints
EndpointMethodDescription
/healthGETCheck API and Database connectivity.
/calculate-reportGETGenerate HD reports (JSON or Markdown).

Example Request: GET /calculate-report?year=1990&month=5&day=15&hour=10&minute=30&place=London&json=true&sections=Type,Authority

β πŸ› οΈ Tech Stack

  • Runtime: Node.js (v22+)
  • Databases: PostgreSQL, SQLite (better-sqlite3)
  • API Interactions: Axios
  • Testing: Jest

⁠🚦 Getting Started

⁠Prerequisites
  • Node.js: v18 or higher (v22+ recommended)
  • Database:
    • PostgreSQL: A running instance (default config points to 192.168.100.200:5434 but is configurable via .env).
    • SQLite: No external setup required; database file is created locally.
  • API Token (External): A valid token for the external HD API (hd.3362173.xyz).
  • API Token (Internal): You must define HDDATA_API_TOKEN to secure your self-hosted API.
⁠Installation
  1. Clone the repository:

    git clone <repository-url>
    cd hddata_api
    
  2. Install dependencies:

    npm install
    
  3. Configure Environment: Create a .env file in the root directory. You can use any provided example file as a template.

    # Database Configuration
    DB_TYPE=postgres          # Options: 'postgres' or 'sqlite'
    DB_HOST=192.168.100.200
    DB_PORT=5434
    DB_USER=postgres
    DB_PASSWORD=your_password
    DB_NAME=hdesign
    DB_SQLITE_PATH=./hd_data.sqlite # Optional, defaults to ./hd_data.sqlite
    
    # API Configuration
    HD_API_URL=https://hd.3362173.xyz/...
    HD_API_TOKEN=your_external_api_token
    
    # Security (New in v0.5.0)
    HDDATA_API_TOKEN=your_internal_secret_token
    
β πŸ—„οΈ Database Setup

For PostgreSQL: Run the schema creation script in your DB client (e.g., db/tablecreation.sql) and then populate data using node scripts/import_data.js (if available).

For SQLite: The application supports migration or initial setup. Check scripts/migrate_pg_to_sqlite.js if you are moving from Postgres.

⁠🐳 Docker Deployment

You can run the API using Docker and Docker Compose. This ensures a consistent environment and easy persistence management.

⁠Prerequisites
  • Docker
  • Docker Compose
⁠Quick Start
  1. Configure Environment: Ensure your .env file is set up (see .env.example or documentation).

  2. Build and Run:

    docker-compose up -d --build
    

    The API will be available at http://localhost:3000 (or API_PORT defined in .env: defaults to 9022 if using the provided config).

  3. Persistence: The SQLite database is persisted in ./hd_data.sqlite on your host machine.

  4. Stop:

    docker-compose down
    

β πŸƒ Usage

The main entry point is src/run_hd.js.

⁠Generate a Report

To generate a Human Design report for a specific birth event:

node src/run_hd.js <year> <month> <day> <hour> <minute> "<place>" [options]

Parameters:

  • year, month, day: Birth date (e.g., 1985 10 25)
  • hour, minute: Birth time in 24h format (e.g., 14 30)
  • place: City and Country (e.g., "New York, USA")

Options:

  • --simple: Generate a simplified report using simple schema logic.
  • --json: Generate a structured JSON file instead of a Markdown report.
  • --sections=<list>: Filter report elements by providing a comma-separated list of sections. Possible values: General, Definition, Type, Authority, Profile, Centers, Channels, Variables, Activations, Bases, Tones, Colors.
node src/run_hd.js 1985 10 25 14 30 "New York, USA" --json

This will generate a file named response_New_York,_USA_1985.json in the current directory.

⁠Selective Analysis

You can generate highly targeted reports by specifying sections:

node src/run_hd.js 1985 10 25 14 30 "New York, USA" --sections=General,Centers

Or include advanced mechanics in a JSON output:

node src/run_hd.js 1985 10 25 14 30 "New York, USA" --json --sections=Activations,Bases,Tones

⁠πŸ§ͺ Testing

Run the test suite using Jest.

  • Standard Test (Postgres):
    npm test
    
  • Test with specific DB type:
    npm run test:pg      # Force Postgres
    npm run test:sqlite  # Force SQLite
    

β πŸ“š Documentation

  • API Specification: See docs/openapi.yaml for API details if you are interacting with the backend service directly.
  • Changelog: See CHANGELOG.md for version history.

⁠🀝 Contributing

Contributions are welcome! Please ensure you:

  1. Add tests for any new features.
  2. Update documentation as needed.
  3. Follow the existing code style.

β πŸ“„ License

[License Type] - See LICENSE file for details.

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog⁠, and this project adheres to Semantic Versioning⁠.

⁠[0.9.1] - 2026-05-30

⁠Fixed
  • Database Deduplication: Removed 3x duplicate rows in public_centers, 11x duplicates in public_circuits, and 18x duplicates in simple_circuits from both PostgreSQL and SQLite databases.
  • Constraints Reinforcement: Added PRIMARY KEY and UNIQUE(name) constraints to these tables in both database engines to prevent future duplication.
  • JSON Dumps regenerated: Regenerated the database dumps with clean, unique records.
  • Verification Tests: Added a test suite to verify database integrity and uniqueness constraints.

⁠[0.9.0] - 2026-01-23

⁠Added
  • V2 Calculate Endpoint: Introduced a raw proxy endpoint /v2/calculate with full upstream parity.
  • Improved Proxying: Added support for include/exclude dot-notation filtering by forwarding parameters to the upstream Hologenetic API.
  • Fastify Schema: Implemented strict request validation for the new V2 endpoint.

⁠[0.8.0] - 2026-01-22

⁠Added
  • Release Automation: Completed full release workflow (version bump, Git tag, GitHub release, Docker image push).
  • Documentation Updated: Added release notes for 0.8.0.
  • Prompt Enhancements: Updated incarnationcrossv2 protocol for automated report generation.
⁠Added
  • DB-Driven Incarnation Cross: Successfully migrated all Incarnation Cross descriptions from hardcoded logic to the relational database, enabling easier updates and better maintainability.
  • V2 Reporting Enhancements: Improved the formatting and conditional display of advanced Human Design mechanics (Bases, Tones, Colors) in V2 reports.

⁠[0.6.0] - 2026-01-22

⁠Added
  • API V2 Migration (Strict): Introduced a new strictly parsed V2 API under /v2/calculate-report.
  • Enrichment Service: Added V2Enrichment to provide deep database mapping for V2 responses, including Type, Authority, Profile, and Variable descriptions.
  • Improved Filtering: Implemented robust include/exclude logic in V2 routes, allowing granular control over report sections.
  • Simplified Mode (V2): Extended "Simple" mode support to the V2 API, enabling user-friendly terminology across all report formats.
  • Robust Markdown Generator: Refactored V2Markdown to be fully conditional, ensuring it can generate reports for any combination of requested sections without crashing.
⁠Fixed
  • Variable Exposure: Fixed an issue where variables were only included if the general section was requested. Variable data is now accessible at the top level and correctly enriched.
  • Reporting Defaults: Standardized default behavior across V2 endpoints to favor JSON output while maintaining easy Markdown access.

⁠[0.5.0] - 2026-01-18

⁠Added
  • API Authentication: Implemented secure API token validation for all endpoints using HDDATA_API_TOKEN.
  • Middleware: Added auth middleware supporting X-API-Tokens header and Authorization: Bearer.
  • Swagger Updates: Configured Swagger UI to support authentication and exposed an "Authorize" button.
  • Environment: Added HDDATA_API_TOKEN to environment configuration and Docker Compose.

⁠[0.4.1] - 2026-01-18

⁠Fixed
  • Validation Rules: Updated ValidationService to support standard authority names (e.g., "Sacral Authority", "Emotional Authority") returned by external APIs.
  • Swagger Documentation: Fixed /health endpoint examples and resolved servers configuration issue that pointed Swagger functionality to localhost.
  • Logic Mapping: Removed deprecated hardcoded remapping for "Solar Plexus" in run_hd.js.
  • Test Suite: Updated all test data and mocks to align with the new, strict validation rules.

⁠[0.4.0] - 2026-01-18

⁠Added
  • Web API: Launched a Fastify-powered REST API (src/server.js) compliant with OpenAPI 3.0.
  • Reporting Endpoint: Added GET /calculate-report with full parity to the CLI, supporting JSON/Markdown output and selective sections.
  • Health Check: Added GET /health for monitoring service and database connectivity.
  • Interactive Documentation: Integrated Swagger UI served at /docs.
  • API Testing: Added comprehensive integration tests (tests/api/) for all new endpoints.

⁠[0.3.0] - 2026-01-18

⁠Added
  • Selective Report Elements: Introduced the --sections CLI flag allowing users to include only specific parts of the report (e.g., General, Centers, Activations).
  • Advanced Mechanics Support: Integrated data gathering and reporting for Bases, Tones, and Colors within planetary activations.
  • Selective Section Tests: Added tests/cli_selective.test.js to verify filtering logic across all output formats.
⁠Changed
  • JSON Schema Optimization: Refactored JSON output to be strictly exclusive; excluded sections are now entirely omitted from the output object for a cleaner developer experience.
  • Redundancy Reduction: Trimmed the general section to basic metadata, removing duplicated fields (variables, centers, etc.) that have their own top-level sections.
  • Dynamic Activation Loading: Planetary activations are now automatically included if any sub-mechanic (Base/Tone/Color) is requested.

⁠[0.2.0] - 2026-01-18

⁠Added
  • JSON Report Support: Added a new --json flag to src/run_hd.js to generate reports in a structured JSON format, facilitating future API integrations.
  • New Integration Tests: Introduced tests/cli_json.test.js and tests/parity/json_structure.test.js to ensure the correctness of JSON output and CLI flag behavior.
  • Exclusive Output Logic: The system now supports exclusive output, generating either a .md or .json file based on the provided flags.
⁠Changed
  • Data Gathering Refactor: Decoupled data gathering logic from report formatting into a reusable prepareChartData function.
  • Numeric Normalization: Ensured consistent JSON output by normalizing percentage fields (prevalence_percent, population_percent) as numeric values across all database drivers.
  • Parity Enhancements: Updated database parity tests to include strict JSON comparison and snapshots.

⁠[0.1.0] - 2026-01-18

⁠Added
  • Logic Validation: Introduced ValidationService to enforce strict Human Design rules (Gates, Lines, Colors, Tones, Bases, etc.) at runtime.
  • Detailed Logging: Added verbose console warnings for HD logic violations to assist development.
  • Reporting IDs: Enhanced Markdown reports with stable HTML IDs (e.g., id="hd-general") for easier programmatic parsing and testing.
  • Baseline Snapshots: Integrated Jest snapshots into parity tests to ensure byte-perfect consistency across database drivers.
⁠Changed
  • Report Generation: Integrated real-time validation into src/run_hd.js. The system now rejects invalid astronomical data with descriptive HD Logic Violation errors.
  • Synonym Support: Expanded validation logic to support common HD terminology synonyms (e.g., "Solar Plexus" as an Authority).

⁠[0.0.9] - 2026-01-18

⁠Changed
  • Documentation: Completely rewrote README.md to accurately reflect the project features, updated tech stack (SQLite support), and included comprehensive usage instructions.

⁠[0.0.8] - 2026-01-18

⁠Changed
  • Release Automation: Fully integrated gh CLI for automated GitHub Release creation with attached release notes.

⁠[0.0.7] - 2026-01-18

⁠Changed
  • Release Process: Improved release.md SOP to include explicit steps for documentation updates and GitHub Release drafting.

⁠[0.0.6] - 2026-01-18

⁠Added
  • Multi-Database Support: Implemented DBService to support both PostgreSQL and SQLite.
  • Migration Tool: Added scripts/migrate_pg_to_sqlite.js to migrate data from Postgres to SQLite.
  • Parity Testing: Integration tests ensure identical output regardless of the database backend.
⁠Fixed
  • Corrected Type Name: Updated "Manifest Generator" to "Manifesting Generator" in data/hddata/types.json.

⁠[0.0.5] - 2026-01-18

⁠Fixed
  • Testing Configuration: Resolved Jest configuration issues to ensure stable test execution.
  • Dependencies: Reinstalled and verified jest dependencies.

⁠[0.0.4] - 2026-01-18

⁠Added
  • Jest Testing Framework: Replaced manual verification scripts with a comprehensive Jest test suite (npm test).
  • New Tests: Added config, db_connection, schema, data, app, and report test suites.
  • Application Logic Tests: Added integration tests for fetchChartData and generateReport.
⁠Changed
  • Refactoring: Updated src/run_hd.js and src/generate_report.js to export functions for testing while maintaining CLI usability.
  • Cleanup: Removed _willdeleted directory and obsolete scripts (import_*, inspect_*).
  • Dependencies: Added jest to devDependencies.
⁠Fixed
  • Public Schema Query: Corrected logic in run_hd.js to properly handle 'Generator' type in the public schema without incorrect mapping.

⁠[0.0.3] - 2026-01-18

⁠Changed
  • Refactored project structure into specialized directories (src, tests, db, scripts, data) for better maintainability.
  • Updated npm test scripts to point to the new tests/ directory.

⁠[0.0.2] - 2026-01-18

⁠Changed
  • Major upgrade to Release SOP (release.md) with visual workflows and automated steps.
  • Updated package.json with metadata and test scripts.
  • Initialized GitHub repository structure.

⁠[0.0.1] - 2026-01-18

⁠Added
  • Initial release of the Human Design Database & Analysis Tool.

Tag summary

Content type

Image

Digest

sha256:4eaca75cb…

Size

71.8 MB

Last updated

4 months ago

docker pull dturkuler/hddata_api