LangChain Minimal Project Structure
Simple chain/agent setup for quick prototyping. Ideal for learning LangChain and building simple LLM applications.
#langchain #python #llm #ai #minimal
Project Directory
myproject/
main.py
Chain definition and execution
Chain definition and execution
prompts.py
Prompt templates
Prompt templates
requirements.txt
.env.example
API keys template
API keys template
.gitignore
README.md
Why This Structure?
The simplest LangChain structure—a single main.py for chain logic and prompts.py for templates. Perfect for learning, quick experiments, and prototypes with one or two chains. No complex abstractions, just direct LLM interaction.
Key Directories
- main.py-Chain setup, model config, and execution logic
- prompts.py-PromptTemplate and ChatPromptTemplate definitions
- .env.example-
OPENAI_API_KEYand other provider keys
Getting Started
python -m venv venv && source venv/bin/activatepip install -r requirements.txtcp .env.example .env(add your API keys)python main.py
When To Use This
- Learning LangChain fundamentals
- Quick prototypes and experiments
- Single-chain applications
- Hackathons and demos
- Testing new LLM providers or models
When To Upgrade
- Adding retrieval/RAG capabilities
- Multiple chains or agents needed
- Need for conversation memory persistence
- Production deployment requirements
- Team collaboration on the codebase
Trade-offs
- No separation-All logic in few files, grows unwieldy
- No memory persistence-Conversation history lost on restart
- Limited testability-Add tests/ when complexity grows