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.
✨ 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
- 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
- Create Mock API:
poetry run ghost-your-be mock-api \
--schema schema.yml \
--port 8000
- 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 }
🔧 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)
- Query Parameters:
Data Generation
The tool supports various data types and faker providers:
vietnam_name: Vietnamese namesvietnam_phone: Vietnamese phone numbersvietnam_address: Vietnamese addresses- Custom faker providers can be added
🤝 Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Faker for data generation
- FastAPI for the mock API server
- SQLAlchemy for database operations
📞 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ghost_your_be-0.1.1.tar.gz.
File metadata
- Download URL: ghost_your_be-0.1.1.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.3 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c93926b76621a61c72cbef2f4aa4ab7d4a6ef2bb2d530b0999802e9971163b2
|
|
| MD5 |
8a34992c7bc09cb3d82cd9dab0f31d0e
|
|
| BLAKE2b-256 |
cb334e3edbfc766d9084460d67b15730d305ecdbbbe8cee5676dc46d54987ed8
|
File details
Details for the file ghost_your_be-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ghost_your_be-0.1.1-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.3 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae1ff013509ce68a0b450b5378feabe710123a49f5ea1d0d4acfbb4cfb70401a
|
|
| MD5 |
01b367d5905cc48cf2178a82adfde0de
|
|
| BLAKE2b-256 |
7b833f0eb39ed15459925eb73aa14a9deeed7bb89c996c272fb88e2d43194806
|