KatInterview

Bootstrap a Reproducible Python Workspace and Starter Service

System DesignModel answer
MediumModel answerSystem Designpythontoolingvirtualenv

Last updated

Describe how to take a fresh machine to a pinned, secure, fast-feedback Python workspace and prove it works by scaffolding a small tested CLI and HTTP service.

You are handed a brand-new laptop and told you will be writing Python in a live, timed session where AI coding assistants are permitted. Walk through how you would get from nothing to a dependable working setup, and explain why you chose each tool.

Cover these five areas:

  1. Interpreter and isolation. Install a Python version manager and create an isolated, project-specific environment pinned to an exact interpreter version.
  2. Secrets. Describe how API keys and other credentials are supplied to the program without ending up in version control, logs, or AI prompts.
  3. Rapid feedback. Set up automatic formatting, linting, testing, and live reload so that each edit gives you feedback within seconds.
  4. Reproducibility. Make the setup repeatable for anyone who clones the project, using a dependency lockfile and a single command entry point (Makefile or scripts).
  5. Validation. Scaffold a tiny service that exposes the same logic through both a command-line interface and an HTTP endpoint, with tests, to confirm the whole toolchain works end to end.

For each decision, justify it against at least one alternative and point out the typical mistakes people make.

Hints

Hint 1

Pick one tool per concern: one for the interpreter version, one for package isolation, one for locking, one for lint/format, one for tests, and one front door for running commands.

Hint 2

Treat secrets as configuration, not code: commit a template with placeholder names, ignore the real file, read values from the process environment, and fail immediately when a required one is absent.

Hint 3

Your scaffold should prove each layer: a pure function with unit tests, a CLI wrapper, an HTTP wrapper, and a check that the health endpoint never reveals the secret value.

Hint 4

Think about what breaks on a fresh clone: unpinned transitive dependencies, a missing interpreter version, Makefile tabs, shell init not reloaded, and the wrong pip being used.