File size: 4,536 Bytes
330b6e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# Makefile for Chat Agent Application

.PHONY: help install setup test clean run docker-build docker-run docker-dev migrate seed

# Default target
help:
	@echo "Available commands:"
	@echo "  install     - Install dependencies"
	@echo "  setup       - Set up development environment"
	@echo "  setup-prod  - Set up production environment"
	@echo "  test        - Run tests"
	@echo "  test-cov    - Run tests with coverage"
	@echo "  clean       - Clean up temporary files"
	@echo "  run         - Run development server"
	@echo "  run-prod    - Run production server"
	@echo "  migrate     - Run database migrations"
	@echo "  seed        - Seed database with sample data"
	@echo "  reset-db    - Reset database (development only)"
	@echo "  docker-build - Build Docker image"
	@echo "  docker-run  - Run with Docker Compose"
	@echo "  docker-dev  - Run development environment with Docker"
	@echo "  docker-stop - Stop Docker containers"
	@echo "  lint        - Run code linting"
	@echo "  format      - Format code"

# Installation and setup
install:
	pip install --upgrade pip
	pip install -r requirements.txt

setup:
	python scripts/setup_environment.py --environment development

setup-prod:
	python scripts/setup_environment.py --environment production

setup-test:
	python scripts/setup_environment.py --environment testing

# Testing
test:
	python -m pytest tests/ -v

test-cov:
	python -m pytest tests/ --cov=chat_agent --cov-report=html --cov-report=term

test-integration:
	python -m pytest tests/integration/ -v

test-unit:
	python -m pytest tests/unit/ -v

# Database operations
migrate:
	python scripts/init_db.py init --config development

migrate-prod:
	python scripts/init_db.py init --config production

seed:
	python scripts/init_db.py seed --config development

reset-db:
	python scripts/init_db.py reset --config development

db-status:
	python scripts/init_db.py status --config development

# Application running
run:
	python app.py

run-prod:
	gunicorn --bind 0.0.0.0:5000 --workers 4 --worker-class eventlet app:app

run-debug:
	FLASK_DEBUG=True python app.py

# Docker operations
docker-build:
	docker build -t chat-agent .

docker-run:
	docker-compose up -d

docker-dev:
	docker-compose -f docker-compose.dev.yml up -d

docker-stop:
	docker-compose down
	docker-compose -f docker-compose.dev.yml down

docker-logs:
	docker-compose logs -f chat-agent

docker-clean:
	docker-compose down -v
	docker system prune -f

# Code quality
lint:
	flake8 chat_agent/ --max-line-length=100 --ignore=E203,W503
	flake8 tests/ --max-line-length=100 --ignore=E203,W503

format:
	black chat_agent/ tests/ --line-length=100
	isort chat_agent/ tests/

type-check:
	mypy chat_agent/ --ignore-missing-imports

# Cleanup
clean:
	find . -type f -name "*.pyc" -delete
	find . -type d -name "__pycache__" -delete
	find . -type d -name "*.egg-info" -exec rm -rf {} +
	rm -rf .coverage htmlcov/ .pytest_cache/ .mypy_cache/
	rm -rf logs/*.log



clean-all: clean

	rm -rf venv/

	rm -rf instance/

	rm -rf flask_session/



# Health checks

health:

	curl -s http://localhost:5000/health/ | python -m json.tool



health-detailed:

	curl -s http://localhost:5000/health/detailed | python -m json.tool



# Development helpers

dev-install:

	pip install -r requirements.txt

	pip install flask-debugtoolbar ipdb watchdog black flake8 isort mypy



logs:

	tail -f logs/chat_agent.log



logs-error:

	tail -f logs/chat_agent.log | grep ERROR



# Production deployment helpers

deploy-check:

	@echo "Pre-deployment checklist:"

	@echo "- [ ] Environment variables configured"

	@echo "- [ ] Database migrations applied"

	@echo "- [ ] SSL certificates installed"

	@echo "- [ ] Firewall configured"

	@echo "- [ ] Monitoring set up"

	@echo "- [ ] Backups configured"



backup-db:

	pg_dump $(DATABASE_URL) > backups/backup_$(shell date +%Y%m%d_%H%M%S).sql



restore-db:

	@echo "Warning: This will overwrite the current database!"

	@read -p "Enter backup file path: " backup_file; \

	psql $(DATABASE_URL) < $$backup_file



# Monitoring

monitor:

	watch -n 5 'curl -s http://localhost:5000/health/detailed | python -m json.tool'



# Documentation

docs:

	@echo "Documentation available:"

	@echo "- README.md - Project overview"

	@echo "- docs/DEPLOYMENT.md - Deployment guide"

	@echo "- docs/ENVIRONMENT_SETUP.md - Environment setup"

	@echo "- .kiro/specs/multi-language-chat-agent/ - Feature specifications"