Skip to main content

A powerful tool for generating mock data and APIs

Project description

Ghost Your BE 🚀

A powerful tool for generating mock data and APIs, designed to streamline frontend development and testing workflows.

Python Version License Code style: black

✨ Features

  • Schema-based Data Generation: Generate realistic mock data from YAML schema definitions
  • Database Integration: Direct data insertion into MySQL, MongoDB, and other databases
  • API Mocking: Create mock APIs for frontend development
  • API Comparison: Compare mock APIs with real endpoints
  • Smart Data Generation: Support for Vietnamese data types (names, addresses, phone numbers)
  • Flexible Output: Export data to JSON, CSV, or directly to databases

🚀 Quick Start

Installation

# Using Poetry (recommended)
poetry install

# Or using pip
pip install ghost-your-be

Basic Usage (if you not development, just remove "poetry run" before run command)

  1. Generate Data from Schema:
poetry run ghost-your-be generate \
  --schema schema.yml \
  --count 10 \
  --db-url mysql+pymysql://user:pass@localhost:3306/db \
  --table users \
  --drop-table
  1. Create Mock API:
poetry run ghost-your-be mock-api \
  --schema schema.yml \
  --port 8000
  1. Compare APIs:
poetry run ghost-your-be compare \
  --mock http://localhost:8000/mock/users \
  --real http://api.example.com/users

📝 Schema Definition

Create a schema.yml file to define your data structure:

tables:
  users:
    fields:
      id: { type: integer, primary_key: true }
      name: { type: string, faker: vietnam_name }
      phone: { type: string, faker: vietnam_phone }
      address: { type: string, faker: vietnam_address }

In addition, there are providers such as(add "vietnam" before "_".Example: vietmam_email - for email): _email, _motocycle, _car, _year, _month, _day, _date, _time, _password, _username, _age, _gender, _job, _salary, _comapny, _school

🔧 Configuration

Database URLs

  • MySQL:
mysql+pymysql://user:password@host:port/database
  • MongoDB:
mongodb://user:password@host:port/database

Command Line Options

Option Description Default
--schema Path to schema YAML file Required
--count Number of rows to generate 5
--db-url Database connection URL None
--table Table/collection name None
--output Output file (JSON/CSV) None
--drop-table Drop table before insert False

🛠️ Development

Prerequisites

  • Python 3.8+
  • Poetry (for dependency management)
  • MySQL/MongoDB (for database features)

Setup Development Environment

# Clone the repository
git clone https://github.com/yourusername/ghost-your-be.git
cd ghost-your-be

# Install dependencies
poetry install

# Activate virtual environment
poetry shell

Running Tests

poetry run pytest

📚 API Reference

Mock API Endpoints

  • GET /mock/{endpoint}: Generate mock data for specified endpoint
    • Query Parameters:
      • count: Number of records to generate (default: 5)

Data Generation

The tool supports various data types and faker providers:

  • vietnam_name: Vietnamese names
  • vietnam_phone: Vietnamese phone numbers
  • vietnam_address: Vietnamese addresses
  • Custom faker providers can be added

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📞 Support

For support, please open an issue in the GitHub repository or contact the maintainers.


Made with ❤️ by [Doi Tuyen]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ghost_your_be-0.1.5.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ghost_your_be-0.1.5-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file ghost_your_be-0.1.5.tar.gz.

File metadata

  • Download URL: ghost_your_be-0.1.5.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Windows/11

File hashes

Hashes for ghost_your_be-0.1.5.tar.gz
Algorithm Hash digest
SHA256 c928a7539437204be547827c0fe0ee062078d1eb3898e6958650229b4ab5beff
MD5 c2c533ccc58f3b27d321eba01d0d2704
BLAKE2b-256 fbcf135d8f1032862b3a86534bb2d2b3d003ed09de11a0a575c7966dadca388e

See more details on using hashes here.

File details

Details for the file ghost_your_be-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: ghost_your_be-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Windows/11

File hashes

Hashes for ghost_your_be-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 435c99eca26c31c323e099d02d74b9eb03ad5da76a125c1af4fc75417b3f4528
MD5 aa339bdaeda7ce4418d1997171f28819
BLAKE2b-256 8e442be499050beced1dd16bb7fcada82165cbd8e0c4319a403e9fcefc664838

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page