Skip to content
IT Vizag
← Production Python

From script to project

Lesson 1 of 10 · 2 min read

Folder layout, pyproject.toml and a README.

🎬 Video version coming soon — read it now

A single script.py is fine for learning. Real work, the kind a team maintains for years, needs a project structure that others can understand, install and test.

A standard layout

feedback-api/
├── pyproject.toml        # project metadata and dependencies
├── README.md             # what it is and how to run it
├── .gitignore            # .venv, .env, __pycache__ ...
├── .env.example          # names of the settings needed, no real secrets
├── src/
│   └── feedback_api/
│       ├── __init__.py   # makes the folder a package
│       ├── main.py       # entry point
│       ├── models.py     # data classes
│       └── service.py    # the main logic
└── tests/
    └── test_service.py

Putting code in src/feedback_api/ (the "src layout") keeps tests honest: they run against the installed package, not loose files that happen to be in the current folder.

pyproject.toml

The modern single file that describes a Python project:

[project]
name = "feedback-api"
version = "0.1.0"
description = "Classifies customer feedback with AI"
requires-python = ">=3.11"
dependencies = [
    "fastapi>=0.115",
    "anthropic>=0.70",
]

[project.optional-dependencies]
dev = ["pytest", "ruff"]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

Install your own project in editable mode, so code changes apply without reinstalling:

python -m venv .venv
source .venv/bin/activate          # Windows: .venv\Scripts\activate
pip install -e ".[dev]"

Now from feedback_api.service import classify works from anywhere, including your tests.

A README that helps

Answer these, in this order:

  1. What it does, in one or two sentences
  2. How to install (the commands above)
  3. How to configure (which environment variables)
  4. How to run and how to test
  5. An example request or screenshot

A recruiter looking at your GitHub reads the README first, often only the README.

Separate concerns

  • Logic (service.py): pure functions that do the real work and are easy to test
  • Interfaces (main.py, the API, the CLI): thin layers that call the logic
  • Configuration: read from the environment in one place

When logic is free of input(), print and web code, the same function can serve a CLI, an API and a test.

Tip: Tools like uv can create this whole structure with uv init and manage the venv for you. Understand the pieces first; then use whatever tool your team prefers.

In one line

Organise real projects with a src/ package, tests/, pyproject.toml and a README, and keep the logic separate from the interfaces.

Saved on this device. Sign in to keep progress everywhere.

Share with a friend