This project uses sensitive credentials that should NEVER be pushed to GitHub or any public repository.
Your .gitignore file protects:
- β
.env- Contains your actual API keys (NEVER committed) - β
.venv/- Python virtual environment - β
__pycache__/- Python bytecode - β
*.log- Log files
- β
.env.example- Template with placeholders only - β
Source code files (
*.py) - β
requirements.txt - β
README.md - β
Dockerfile,docker-compose.yml
Always run this before pushing to GitHub:
./check_secrets.shThis script checks for:
- API keys accidentally committed
- Real credentials in
.env.example - Missing
.gitignorefile
# Initialize git
git init
# Add remote (replace with your GitHub repo)
git remote add origin https://github.com/yourusername/upstox-chatbot.git# Run security check
./check_secrets.sh
# If check passes, add files
git add .
# Commit
git commit -m "Your commit message"
# Push
git push origin main# If you just committed but haven't pushed
git reset HEAD~1
git add .gitignore .env.example # Add only safe files
git commit -m "Initial commit"# Remove .env from git tracking
git rm --cached .env
# Commit the removal
git commit -m "Remove .env from tracking"
# Push
git push origin main --force- Revoke the exposed API keys immediately
- Generate new keys from provider dashboards
- Update your local
.envfile
For production deployments, use:
-
Environment Variables (Recommended)
export UPSTOX_API_KEY="your_key" export GOOGLE_API_KEY="your_key"
-
Secret Management Services
- AWS Secrets Manager
- Google Cloud Secret Manager
- Azure Key Vault
- HashiCorp Vault
-
Docker Secrets (for Docker deployments)
docker run --env-file .env.production your-image
When using Docker, never include .env in your image:
# β
Good - .dockerignore prevents this
COPY . /app
# β Bad - Never do this
COPY .env /app/.envUse environment variables or Docker secrets instead:
# Pass secrets at runtime
docker run -e UPSTOX_API_KEY=$UPSTOX_API_KEY your-imageRegularly rotate your keys:
-
Upstox API Keys
- Go to https://account.upstox.com/developer/apps
- Regenerate keys
- Update
.env - Restart services
-
Google Gemini API
- Go to https://makersuite.google.com/app/apikey
- Delete old key, create new
- Update
.env
-
Access Tokens
- Upstox tokens expire daily
- Re-run
python upstox_auth.pyto refresh
Before pushing code:
- Ran
./check_secrets.sh- all checks passed - Verified
.envis in.gitignore - Checked
.env.examplehas no real credentials - Reviewed
git status- no sensitive files staged - Confirmed no API keys in code comments
- Tested locally after pull to ensure
.envnot lost
Remember: The only secret you can share is .env.example with placeholders! π