AI EngineeringInterview preparation
Foundation·Concept·2 min read

Virtual environments, pip, and project structure

Practice this question

Overview

  • A virtual environment isolates a project's Python packages.
  • pip installs packages into the selected environment.
  • Project structure separates API routes, business services, adapters, and tests so the AI code does not become one notebook-sized script.

Why this matters

AI libraries frequently require specific versions, and conflicts between projects can break environments.

An everyday example

Different kitchens keep their own ingredients and recipe versions.

A technical example

For a future Python project: python -m venv .venv, activate it, then python -m pip install fastapi pydantic httpx.

How it works

  1. Create environment
  2. Select interpreter
  3. Install pinned compatible packages
  4. Record dependencies
  5. Reproduce in CI and a container.

Architecture and flow

Dependency specification → isolated environment → application → reproducible deployment.

The insurance assistant example

The insurer's parsing worker has document/OCR packages; its Node API does not inherit those heavy dependencies.

When to use it

Every independently deployed Python application.

When to avoid it

Do not install arbitrary packages globally or rely on packages left over from a personal notebook session.

Interview answer

“I isolate Python dependencies, pin compatible versions, and structure services around contracts so experiments can become reproducible deployments.”

Benefits, trade-offs, and production considerations

  • A conceptual layout is app/api, app/services, app/adapters, app/schemas, and tests, configured through pyproject.toml.
  • This is a future-project example; no such folders are created by these notes.
  • Scan dependencies and never commit API keys into environment files.
Adapted from 13_AI.MD · “Virtual environments, pip, and project structure”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.