RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Fredoline Eruo
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /Courses
  5. /Python for AI — Zero to Useful
  6. /Ch. 30
Python for AI — Zero to Useful

30. Project Structure for AI

Chapter 30 of 36 · 15 min
KEY INSIGHT

Choose a structure and commit to it. The `src/` layout + `scripts/` + `tests/` + `config/` pattern works for most AI tools. Separate configuration from code—configuration changes without deployments.

Well-organized projects survive maintenance. You—not the code—will return to a project months later and need to understand what's where.

A practical structure for AI utilities:

ai_data_pipeline/
├── pyproject.toml
├── src/
│   └── pipeline/
│       ├── __init__.py
│       ├── ingest.py        # Data loading
│       ├── transform.py     # Preprocessing
│       ├── embed.py         # Embedding generation
│       └── store.py         # Vector storage
├── scripts/
│   └── batch_ingest.py      # Entry points
├── tests/
│   ├── test_transform.py
│   └── test_embed.py
├── data/
│   ├── raw/
│   └── processed/
├── output/
│   └── logs/
├── config/
│   ├── development.yaml
│   └── production.yaml
└── .env.example

The src/ layout is now standard—using it means you pip install -e . the package (editable install) and import pipeline works even in development. It also prevents accidental relative imports.

Config files live separately from code. YAML is common:

# config/production.yaml
model:
  provider: openai
  model_name: gpt-4
  temperature: 0.3

vector_store:
  index_name: production_index
  dimension: 1536

processing:
  batch_size: 100
  max_retries: 3
  retry_delay: 2

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

EXERCISE

Create this directory structure for a fictional "sentiment_analyzer" project. Include a minimal src/sentiment_analyzer/__init__.py that defines a SentimentAnalyzer class. Create a scripts/analyze.py entry point that imports from the package. Set up pyproject.toml with editable install.

← Chapter 29
Dependency Management
Chapter 31 →
Building a CLI Tool