- Introduce the project and requirements.
- Create a new Python project.
- Build a fake-data generator API with inline code documentation.
- Add unit tests to verify behavior.
- Produce API documentation so others can use the tool.
- Demonstrate how AI pair-programming fits into the workflow.
Do not use, copy, or expose any real customer PII in development, test environments, or CI logs. This project provides safe, realistic mock data so teams can validate behavior without risking compliance violations.

- Goal: Create an API that returns realistic mock user data in multiple formats (JSON, CSV, downloadable text files).
- Stack: FastAPI (Python), pytest (unit testing), and standard libraries for serialization.
- Outputs: Configurable fake records for frontend, batch processing, and download pipelines.
- Preserves privacy and regulatory compliance.
- Allows deterministic testing by using optional seeding for reproducible results.
- Makes it easy for teams to integrate mock data into automated tests and examples.
- A small FastAPI service with an endpoint such as
POST /api/v1/getfakedatathat accepts a JSON payload describing the count and format. - Format options:
json,csv,text(downloadable). - Inline code documentation and OpenAPI (automatic) documentation for discoverability.
Example unit test
- This test demonstrates patching the data fetcher and verifying the endpoint response.
- Use FastAPI’s dependency injection to separate data generation from request handling; this makes testing and mocking straightforward.
- Support a
seedparameter to produce repeatable pseudo-random datasets for CI tests. - Keep fake data schema consistent (field names, types) so downstream systems can rely on stable shapes.
- For large exports, stream CSV to avoid memory pressure.
- Unit tests: use
pytest+TestClientfrom FastAPI / Starlette; patch data generation functions to focus tests on routing and serialization. - Integration tests: run the real generator with a fixed seed and validate schema and sample values.
- API docs: FastAPI exposes OpenAPI documentation at
/docsand/redoc; add clear example payloads and response models. - CI: include tests and basic linting steps to ensure the fake-data generator remains reliable as it evolves.
- FastAPI docs: https://fastapi.tiangolo.com/
- Pytest: https://docs.pytest.org/
- GitHub Copilot: https://docs.github.com/en/copilot
Using generated mock data helps maintain privacy while enabling realistic testing scenarios. Consider adding configuration options to control randomness and reproducibility (for example, using a seed).