feat(gtm-architect): Integrate GTM Architect app with Python backend, DB persistence, and Docker stack

This commit is contained in:
2025-12-31 12:38:28 +00:00
parent 62f1e453bc
commit 2b4d8d6f7b
12 changed files with 830 additions and 1070 deletions

File diff suppressed because it is too large Load Diff

28
gtm-architect/Dockerfile Normal file
View File

@@ -0,0 +1,28 @@
# Base image for Python
FROM python:3.10-slim
# Set the working directory
WORKDIR /app
# Copy shared modules first
COPY helpers.py /app/
COPY config.py /app/
# Copy application-specific files
COPY gtm_architect_orchestrator.py /app/
COPY gtm-architect /app/gtm-architect
# Install Python dependencies
RUN pip install --no-cache-dir -r /app/gtm-architect/requirements.txt
# Install Node.js and npm
RUN apt-get update && apt-get install -y nodejs npm && npm cache clean --force
# Install Node.js dependencies for the frontend bridge
RUN npm install --prefix /app/gtm-architect
# Expose the port the app runs on
EXPOSE 3005
# Command to run the application
CMD ["node", "/app/gtm-architect/server.cjs"]

View File

@@ -0,0 +1,10 @@
openai
pandas
gspread
oauth2client
beautifulsoup4
requests
python-dotenv
tiktoken
thefuzz
serpapi

62
gtm-architect/server.cjs Normal file
View File

@@ -0,0 +1,62 @@
const express = require('express');
const { spawn } = require('child_process');
const app = express();
const port = 3005; // Port for the GTM Architect service
app.use(express.json({ limit: '50mb' }));
// Middleware to serve static files from the React app
app.use(express.static('.'));
function callPythonScript(mode, data, res) {
const pythonProcess = spawn('python3', ['../gtm_architect_orchestrator.py', '--mode', mode]);
let pythonData = '';
let errorData = '';
pythonProcess.stdout.on('data', (data) => {
pythonData += data.toString();
});
pythonProcess.stderr.on('data', (data) => {
errorData += data.toString();
});
pythonProcess.on('close', (code) => {
if (code !== 0) {
console.error(`Python script exited with code ${code}`);
console.error('Stderr:', errorData);
return res.status(500).json({ error: 'Python script execution failed.', details: errorData });
}
try {
const result = JSON.parse(pythonData);
res.json(result);
} catch (e) {
console.error('Failed to parse Python script output:', e);
console.error('Raw output:', pythonData);
res.status(500).json({ error: 'Failed to parse Python script output.', details: pythonData });
}
});
pythonProcess.stdin.write(JSON.stringify(data));
pythonProcess.stdin.end();
}
// API endpoint to handle requests from the frontend
app.post('/api/gtm', (req, res) => {
const { mode, data } = req.body;
if (!mode || !data) {
return res.status(400).json({ error: 'Missing mode or data in request body' });
}
callPythonScript(mode, data, res);
});
// Serve the main index.html for any other requests to support client-side routing
app.get('*', (req, res) => {
res.sendFile(__dirname + '/index.html');
});
app.listen(port, () => {
console.log(`GTM Architect server listening at http://localhost:${port}`);
});