@timmeck/marketing-brain 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (294) hide show
  1. package/.mcp.json +9 -0
  2. package/README.md +342 -0
  3. package/dashboard.html +666 -0
  4. package/dist/api/server.d.ts +15 -0
  5. package/dist/api/server.js +73 -0
  6. package/dist/api/server.js.map +1 -0
  7. package/dist/cli/colors.d.ts +43 -0
  8. package/dist/cli/colors.js +54 -0
  9. package/dist/cli/colors.js.map +1 -0
  10. package/dist/cli/commands/campaign.d.ts +2 -0
  11. package/dist/cli/commands/campaign.js +62 -0
  12. package/dist/cli/commands/campaign.js.map +1 -0
  13. package/dist/cli/commands/config.d.ts +2 -0
  14. package/dist/cli/commands/config.js +164 -0
  15. package/dist/cli/commands/config.js.map +1 -0
  16. package/dist/cli/commands/dashboard.d.ts +2 -0
  17. package/dist/cli/commands/dashboard.js +147 -0
  18. package/dist/cli/commands/dashboard.js.map +1 -0
  19. package/dist/cli/commands/doctor.d.ts +2 -0
  20. package/dist/cli/commands/doctor.js +111 -0
  21. package/dist/cli/commands/doctor.js.map +1 -0
  22. package/dist/cli/commands/export.d.ts +2 -0
  23. package/dist/cli/commands/export.js +37 -0
  24. package/dist/cli/commands/export.js.map +1 -0
  25. package/dist/cli/commands/import.d.ts +2 -0
  26. package/dist/cli/commands/import.js +76 -0
  27. package/dist/cli/commands/import.js.map +1 -0
  28. package/dist/cli/commands/insights.d.ts +2 -0
  29. package/dist/cli/commands/insights.js +41 -0
  30. package/dist/cli/commands/insights.js.map +1 -0
  31. package/dist/cli/commands/learn.d.ts +2 -0
  32. package/dist/cli/commands/learn.js +22 -0
  33. package/dist/cli/commands/learn.js.map +1 -0
  34. package/dist/cli/commands/network.d.ts +2 -0
  35. package/dist/cli/commands/network.js +66 -0
  36. package/dist/cli/commands/network.js.map +1 -0
  37. package/dist/cli/commands/post.d.ts +2 -0
  38. package/dist/cli/commands/post.js +45 -0
  39. package/dist/cli/commands/post.js.map +1 -0
  40. package/dist/cli/commands/query.d.ts +2 -0
  41. package/dist/cli/commands/query.js +96 -0
  42. package/dist/cli/commands/query.js.map +1 -0
  43. package/dist/cli/commands/rules.d.ts +2 -0
  44. package/dist/cli/commands/rules.js +25 -0
  45. package/dist/cli/commands/rules.js.map +1 -0
  46. package/dist/cli/commands/start.d.ts +2 -0
  47. package/dist/cli/commands/start.js +91 -0
  48. package/dist/cli/commands/start.js.map +1 -0
  49. package/dist/cli/commands/status.d.ts +2 -0
  50. package/dist/cli/commands/status.js +63 -0
  51. package/dist/cli/commands/status.js.map +1 -0
  52. package/dist/cli/commands/stop.d.ts +2 -0
  53. package/dist/cli/commands/stop.js +34 -0
  54. package/dist/cli/commands/stop.js.map +1 -0
  55. package/dist/cli/commands/suggest.d.ts +2 -0
  56. package/dist/cli/commands/suggest.js +57 -0
  57. package/dist/cli/commands/suggest.js.map +1 -0
  58. package/dist/cli/ipc-helper.d.ts +2 -0
  59. package/dist/cli/ipc-helper.js +26 -0
  60. package/dist/cli/ipc-helper.js.map +1 -0
  61. package/dist/cli/update-check.d.ts +2 -0
  62. package/dist/cli/update-check.js +58 -0
  63. package/dist/cli/update-check.js.map +1 -0
  64. package/dist/config.d.ts +2 -0
  65. package/dist/config.js +111 -0
  66. package/dist/config.js.map +1 -0
  67. package/dist/dashboard/renderer.d.ts +11 -0
  68. package/dist/dashboard/renderer.js +112 -0
  69. package/dist/dashboard/renderer.js.map +1 -0
  70. package/dist/dashboard/server.d.ts +15 -0
  71. package/dist/dashboard/server.js +122 -0
  72. package/dist/dashboard/server.js.map +1 -0
  73. package/dist/db/connection.d.ts +2 -0
  74. package/dist/db/connection.js +19 -0
  75. package/dist/db/connection.js.map +1 -0
  76. package/dist/db/migrations/001_core_schema.d.ts +2 -0
  77. package/dist/db/migrations/001_core_schema.js +62 -0
  78. package/dist/db/migrations/001_core_schema.js.map +1 -0
  79. package/dist/db/migrations/002_learning_schema.d.ts +2 -0
  80. package/dist/db/migrations/002_learning_schema.js +45 -0
  81. package/dist/db/migrations/002_learning_schema.js.map +1 -0
  82. package/dist/db/migrations/003_synapse_schema.d.ts +2 -0
  83. package/dist/db/migrations/003_synapse_schema.js +26 -0
  84. package/dist/db/migrations/003_synapse_schema.js.map +1 -0
  85. package/dist/db/migrations/004_insights_schema.d.ts +2 -0
  86. package/dist/db/migrations/004_insights_schema.js +37 -0
  87. package/dist/db/migrations/004_insights_schema.js.map +1 -0
  88. package/dist/db/migrations/005_fts_indexes.d.ts +2 -0
  89. package/dist/db/migrations/005_fts_indexes.js +76 -0
  90. package/dist/db/migrations/005_fts_indexes.js.map +1 -0
  91. package/dist/db/migrations/index.d.ts +2 -0
  92. package/dist/db/migrations/index.js +47 -0
  93. package/dist/db/migrations/index.js.map +1 -0
  94. package/dist/db/repositories/audience.repository.d.ts +18 -0
  95. package/dist/db/repositories/audience.repository.js +45 -0
  96. package/dist/db/repositories/audience.repository.js.map +1 -0
  97. package/dist/db/repositories/campaign.repository.d.ts +15 -0
  98. package/dist/db/repositories/campaign.repository.js +58 -0
  99. package/dist/db/repositories/campaign.repository.js.map +1 -0
  100. package/dist/db/repositories/engagement.repository.d.ts +26 -0
  101. package/dist/db/repositories/engagement.repository.js +83 -0
  102. package/dist/db/repositories/engagement.repository.js.map +1 -0
  103. package/dist/db/repositories/insight.repository.d.ts +18 -0
  104. package/dist/db/repositories/insight.repository.js +87 -0
  105. package/dist/db/repositories/insight.repository.js.map +1 -0
  106. package/dist/db/repositories/post.repository.d.ts +21 -0
  107. package/dist/db/repositories/post.repository.js +105 -0
  108. package/dist/db/repositories/post.repository.js.map +1 -0
  109. package/dist/db/repositories/rule.repository.d.ts +16 -0
  110. package/dist/db/repositories/rule.repository.js +71 -0
  111. package/dist/db/repositories/rule.repository.js.map +1 -0
  112. package/dist/db/repositories/strategy.repository.d.ts +16 -0
  113. package/dist/db/repositories/strategy.repository.js +69 -0
  114. package/dist/db/repositories/strategy.repository.js.map +1 -0
  115. package/dist/db/repositories/synapse.repository.d.ts +25 -0
  116. package/dist/db/repositories/synapse.repository.js +115 -0
  117. package/dist/db/repositories/synapse.repository.js.map +1 -0
  118. package/dist/db/repositories/template.repository.d.ts +16 -0
  119. package/dist/db/repositories/template.repository.js +61 -0
  120. package/dist/db/repositories/template.repository.js.map +1 -0
  121. package/dist/index.d.ts +2 -0
  122. package/dist/index.js +62 -0
  123. package/dist/index.js.map +1 -0
  124. package/dist/ipc/client.d.ts +13 -0
  125. package/dist/ipc/client.js +93 -0
  126. package/dist/ipc/client.js.map +1 -0
  127. package/dist/ipc/protocol.d.ts +8 -0
  128. package/dist/ipc/protocol.js +29 -0
  129. package/dist/ipc/protocol.js.map +1 -0
  130. package/dist/ipc/router.d.ts +30 -0
  131. package/dist/ipc/router.js +88 -0
  132. package/dist/ipc/router.js.map +1 -0
  133. package/dist/ipc/server.d.ts +14 -0
  134. package/dist/ipc/server.js +130 -0
  135. package/dist/ipc/server.js.map +1 -0
  136. package/dist/learning/confidence-scorer.d.ts +17 -0
  137. package/dist/learning/confidence-scorer.js +26 -0
  138. package/dist/learning/confidence-scorer.js.map +1 -0
  139. package/dist/learning/learning-engine.d.ts +33 -0
  140. package/dist/learning/learning-engine.js +211 -0
  141. package/dist/learning/learning-engine.js.map +1 -0
  142. package/dist/marketing-core.d.ts +17 -0
  143. package/dist/marketing-core.js +233 -0
  144. package/dist/marketing-core.js.map +1 -0
  145. package/dist/mcp/server.d.ts +1 -0
  146. package/dist/mcp/server.js +67 -0
  147. package/dist/mcp/server.js.map +1 -0
  148. package/dist/mcp/tools.d.ts +3 -0
  149. package/dist/mcp/tools.js +138 -0
  150. package/dist/mcp/tools.js.map +1 -0
  151. package/dist/research/research-engine.d.ts +28 -0
  152. package/dist/research/research-engine.js +211 -0
  153. package/dist/research/research-engine.js.map +1 -0
  154. package/dist/services/analytics.service.d.ts +116 -0
  155. package/dist/services/analytics.service.js +69 -0
  156. package/dist/services/analytics.service.js.map +1 -0
  157. package/dist/services/audience.service.d.ts +20 -0
  158. package/dist/services/audience.service.js +30 -0
  159. package/dist/services/audience.service.js.map +1 -0
  160. package/dist/services/campaign.service.d.ts +27 -0
  161. package/dist/services/campaign.service.js +65 -0
  162. package/dist/services/campaign.service.js.map +1 -0
  163. package/dist/services/insight.service.d.ts +18 -0
  164. package/dist/services/insight.service.js +40 -0
  165. package/dist/services/insight.service.js.map +1 -0
  166. package/dist/services/post.service.d.ts +48 -0
  167. package/dist/services/post.service.js +93 -0
  168. package/dist/services/post.service.js.map +1 -0
  169. package/dist/services/rule.service.d.ts +29 -0
  170. package/dist/services/rule.service.js +67 -0
  171. package/dist/services/rule.service.js.map +1 -0
  172. package/dist/services/strategy.service.d.ts +17 -0
  173. package/dist/services/strategy.service.js +39 -0
  174. package/dist/services/strategy.service.js.map +1 -0
  175. package/dist/services/synapse.service.d.ts +22 -0
  176. package/dist/services/synapse.service.js +22 -0
  177. package/dist/services/synapse.service.js.map +1 -0
  178. package/dist/services/template.service.d.ts +17 -0
  179. package/dist/services/template.service.js +37 -0
  180. package/dist/services/template.service.js.map +1 -0
  181. package/dist/synapses/activation.d.ts +13 -0
  182. package/dist/synapses/activation.js +50 -0
  183. package/dist/synapses/activation.js.map +1 -0
  184. package/dist/synapses/decay.d.ts +11 -0
  185. package/dist/synapses/decay.js +27 -0
  186. package/dist/synapses/decay.js.map +1 -0
  187. package/dist/synapses/hebbian.d.ts +13 -0
  188. package/dist/synapses/hebbian.js +35 -0
  189. package/dist/synapses/hebbian.js.map +1 -0
  190. package/dist/synapses/pathfinder.d.ts +14 -0
  191. package/dist/synapses/pathfinder.js +50 -0
  192. package/dist/synapses/pathfinder.js.map +1 -0
  193. package/dist/synapses/synapse-manager.d.ts +32 -0
  194. package/dist/synapses/synapse-manager.js +76 -0
  195. package/dist/synapses/synapse-manager.js.map +1 -0
  196. package/dist/types/config.types.d.ts +69 -0
  197. package/dist/types/config.types.js +2 -0
  198. package/dist/types/config.types.js.map +1 -0
  199. package/dist/types/ipc.types.d.ts +11 -0
  200. package/dist/types/ipc.types.js +2 -0
  201. package/dist/types/ipc.types.js.map +1 -0
  202. package/dist/types/post.types.d.ts +141 -0
  203. package/dist/types/post.types.js +2 -0
  204. package/dist/types/post.types.js.map +1 -0
  205. package/dist/types/synapse.types.d.ts +23 -0
  206. package/dist/types/synapse.types.js +2 -0
  207. package/dist/types/synapse.types.js.map +1 -0
  208. package/dist/utils/events.d.ts +57 -0
  209. package/dist/utils/events.js +23 -0
  210. package/dist/utils/events.js.map +1 -0
  211. package/dist/utils/hash.d.ts +1 -0
  212. package/dist/utils/hash.js +5 -0
  213. package/dist/utils/hash.js.map +1 -0
  214. package/dist/utils/logger.d.ts +8 -0
  215. package/dist/utils/logger.js +39 -0
  216. package/dist/utils/logger.js.map +1 -0
  217. package/dist/utils/paths.d.ts +3 -0
  218. package/dist/utils/paths.js +18 -0
  219. package/dist/utils/paths.js.map +1 -0
  220. package/package.json +40 -0
  221. package/seed-data.json +78 -0
  222. package/src/api/server.ts +86 -0
  223. package/src/cli/colors.ts +59 -0
  224. package/src/cli/commands/campaign.ts +66 -0
  225. package/src/cli/commands/config.ts +168 -0
  226. package/src/cli/commands/dashboard.ts +165 -0
  227. package/src/cli/commands/doctor.ts +110 -0
  228. package/src/cli/commands/export.ts +40 -0
  229. package/src/cli/commands/import.ts +84 -0
  230. package/src/cli/commands/insights.ts +44 -0
  231. package/src/cli/commands/learn.ts +24 -0
  232. package/src/cli/commands/network.ts +71 -0
  233. package/src/cli/commands/post.ts +47 -0
  234. package/src/cli/commands/query.ts +108 -0
  235. package/src/cli/commands/rules.ts +27 -0
  236. package/src/cli/commands/start.ts +100 -0
  237. package/src/cli/commands/status.ts +73 -0
  238. package/src/cli/commands/stop.ts +33 -0
  239. package/src/cli/commands/suggest.ts +64 -0
  240. package/src/cli/ipc-helper.ts +22 -0
  241. package/src/cli/update-check.ts +63 -0
  242. package/src/config.ts +110 -0
  243. package/src/dashboard/renderer.ts +136 -0
  244. package/src/dashboard/server.ts +140 -0
  245. package/src/db/connection.ts +22 -0
  246. package/src/db/migrations/001_core_schema.ts +63 -0
  247. package/src/db/migrations/002_learning_schema.ts +46 -0
  248. package/src/db/migrations/003_synapse_schema.ts +27 -0
  249. package/src/db/migrations/004_insights_schema.ts +38 -0
  250. package/src/db/migrations/005_fts_indexes.ts +77 -0
  251. package/src/db/migrations/index.ts +62 -0
  252. package/src/db/repositories/audience.repository.ts +53 -0
  253. package/src/db/repositories/campaign.repository.ts +72 -0
  254. package/src/db/repositories/engagement.repository.ts +108 -0
  255. package/src/db/repositories/insight.repository.ts +100 -0
  256. package/src/db/repositories/post.repository.ts +123 -0
  257. package/src/db/repositories/rule.repository.ts +87 -0
  258. package/src/db/repositories/strategy.repository.ts +82 -0
  259. package/src/db/repositories/synapse.repository.ts +148 -0
  260. package/src/db/repositories/template.repository.ts +76 -0
  261. package/src/index.ts +69 -0
  262. package/src/ipc/client.ts +110 -0
  263. package/src/ipc/protocol.ts +35 -0
  264. package/src/ipc/router.ts +126 -0
  265. package/src/ipc/server.ts +140 -0
  266. package/src/learning/confidence-scorer.ts +36 -0
  267. package/src/learning/learning-engine.ts +254 -0
  268. package/src/marketing-core.ts +285 -0
  269. package/src/mcp/server.ts +72 -0
  270. package/src/mcp/tools.ts +216 -0
  271. package/src/research/research-engine.ts +226 -0
  272. package/src/services/analytics.service.ts +73 -0
  273. package/src/services/audience.service.ts +40 -0
  274. package/src/services/campaign.service.ts +80 -0
  275. package/src/services/insight.service.ts +54 -0
  276. package/src/services/post.service.ts +116 -0
  277. package/src/services/rule.service.ts +90 -0
  278. package/src/services/strategy.service.ts +53 -0
  279. package/src/services/synapse.service.ts +32 -0
  280. package/src/services/template.service.ts +50 -0
  281. package/src/synapses/activation.ts +80 -0
  282. package/src/synapses/decay.ts +38 -0
  283. package/src/synapses/hebbian.ts +68 -0
  284. package/src/synapses/pathfinder.ts +81 -0
  285. package/src/synapses/synapse-manager.ts +115 -0
  286. package/src/types/config.types.ts +79 -0
  287. package/src/types/ipc.types.ts +8 -0
  288. package/src/types/post.types.ts +156 -0
  289. package/src/types/synapse.types.ts +43 -0
  290. package/src/utils/events.ts +44 -0
  291. package/src/utils/hash.ts +5 -0
  292. package/src/utils/logger.ts +48 -0
  293. package/src/utils/paths.ts +19 -0
  294. package/tsconfig.json +18 -0
package/.mcp.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "mcpServers": {
3
+ "marketing-brain": {
4
+ "command": "npx",
5
+ "args": ["tsx", "src/index.ts", "mcp-server"],
6
+ "cwd": "C:/Users/mecklenburg/Desktop/marketing-brain"
7
+ }
8
+ }
9
+ }
package/README.md ADDED
@@ -0,0 +1,342 @@
1
+ # Marketing Brain
2
+
3
+ **Self-Learning Marketing Intelligence System for Claude Code**
4
+
5
+ Marketing Brain is an MCP server that gives Claude Code a persistent marketing memory. It tracks every post you publish, learns what works across platforms, and builds a Hebbian synapse network connecting posts, campaigns, strategies, templates, and insights. Over time, it learns your best-performing patterns and proactively suggests what to post, when, and where.
6
+
7
+ ## Why Marketing Brain?
8
+
9
+ Without Marketing Brain, your marketing knowledge lives in your head. With it:
10
+
11
+ - **Posts are tracked** — Every post on X, Reddit, LinkedIn, Bluesky is stored with engagement metrics
12
+ - **Patterns emerge** — The learning engine finds your best posting times, formats, and platforms automatically
13
+ - **Strategies compound** — Successful strategies are recorded and suggested for similar future contexts
14
+ - **Rules are learned** — "Posts at 15:00 CET perform 2x better" — discovered and enforced automatically
15
+ - **Templates are extracted** — High-performing post structures become reusable templates
16
+ - **Gaps are detected** — "You never post on LinkedIn — potential?" — the research engine spots blind spots
17
+ - **Campaigns are connected** — Cross-promotion synergies between brands surface through the synapse network
18
+ - **Knowledge persists** — Every session builds on everything before it
19
+
20
+ ## Features
21
+
22
+ ### Core Intelligence
23
+ - **Post Tracking** — Store posts with platform, format, hashtags, URL, and full engagement history
24
+ - **Campaign Management** — Group posts into campaigns, track aggregate performance
25
+ - **Hebbian Synapse Network** — Weighted graph connecting posts, campaigns, strategies, templates, rules, audiences, and insights
26
+ - **Spreading Activation** — Explore related content by activating nodes in the network
27
+ - **Full-Text Search** — FTS5 indexes on posts, strategies, and templates
28
+
29
+ ### Learning Engine (runs every 15 min)
30
+ - **Timing Patterns** — Discovers best/worst posting hours from engagement data
31
+ - **Format Patterns** — Finds which formats (text, image, video, thread) perform best
32
+ - **Platform Patterns** — Identifies your top-performing platform with Wilson Score confidence
33
+ - **Strategy Confidence** — Updates strategy scores based on real engagement
34
+ - **Rule Confidence** — Prunes low-confidence rules, promotes high-confidence ones
35
+ - **Similar Post Wiring** — Automatically connects similar posts in the synapse network
36
+
37
+ ### Research Engine (runs every hour)
38
+ - **Trend Detection** — "Engagement on X is up 30% this week"
39
+ - **Gap Analysis** — "You haven't posted on LinkedIn yet — consider expanding"
40
+ - **Synergy Detection** — "Video + Monday = your best combo on Reddit"
41
+ - **Template Suggestions** — "Post #42 has high engagement — extract as template"
42
+ - **Optimization Ideas** — "Cross-post your top tweet as a LinkedIn article"
43
+
44
+ ### Dashboard
45
+ - **HTML Dashboard** — Neural canvas background, glassmorphism UI, animated stats
46
+ - **Force-Directed Synapse Graph** — Interactive network visualization with drag, hover, tooltips
47
+ - **Platform Charts** — Color-coded distribution bars
48
+ - **Top Posts** — Engagement-scored post cards
49
+ - **Research Insights** — Tabbed view: Trends, Gaps, Synergies, Templates, Optimizations
50
+ - **Real-Time Updates** — SSE-powered live stats refresh every 30 seconds
51
+
52
+ ### MCP Tools (13 tools for Claude Code)
53
+ - **Draft Checking** — Check a post against learned rules before publishing
54
+ - **Post Reporting** — Track published posts with one command
55
+ - **Engagement Updates** — Feed in likes, shares, impressions as they come
56
+ - **Strategy Memory** — Report what worked, get suggestions for what's next
57
+ - **Template Library** — Find and reuse high-performing post structures
58
+ - **Analytics** — Full dashboard data accessible from Claude Code
59
+
60
+ ## Quick Start
61
+
62
+ ### Installation
63
+
64
+ ```bash
65
+ git clone https://github.com/timmeck/marketing-brain.git
66
+ cd marketing-brain
67
+ npm install
68
+ npm run build
69
+ ```
70
+
71
+ ### Setup with Claude Code
72
+
73
+ Add to `~/.claude/settings.json`:
74
+
75
+ ```json
76
+ {
77
+ "mcpServers": {
78
+ "marketing-brain": {
79
+ "command": "npx",
80
+ "args": ["tsx", "C:/path/to/marketing-brain/src/index.ts", "mcp-server"],
81
+ "cwd": "C:/path/to/marketing-brain"
82
+ }
83
+ }
84
+ }
85
+ ```
86
+
87
+ ### Start the Daemon
88
+
89
+ ```bash
90
+ marketing start
91
+ marketing status
92
+ marketing doctor # verify everything works (5/5 green)
93
+ ```
94
+
95
+ ## CLI Commands
96
+
97
+ ### Daemon Management
98
+ ```
99
+ marketing start Start the daemon
100
+ marketing stop Stop the daemon
101
+ marketing status Show stats (posts, campaigns, synapses, insights)
102
+ marketing doctor Health check (daemon, DB, MCP, data dir)
103
+ ```
104
+
105
+ ### Content Management
106
+ ```
107
+ marketing post <platform> [url] Report a published post
108
+ marketing campaign create <name> Create a campaign
109
+ marketing campaign list List all campaigns
110
+ marketing campaign stats <id> Show campaign performance
111
+ marketing import <file.json> Bulk import posts from JSON
112
+ ```
113
+
114
+ ### Intelligence
115
+ ```
116
+ marketing insights Show current marketing insights
117
+ marketing rules Show learned marketing rules
118
+ marketing suggest <topic> Get content suggestions for a topic
119
+ marketing learn Trigger a learning cycle manually
120
+ marketing query <search> Search posts, strategies, and insights
121
+ ```
122
+
123
+ ### Visualization & Export
124
+ ```
125
+ marketing dashboard Open interactive HTML dashboard in browser
126
+ marketing network Show synapse network overview
127
+ marketing network --node post:42 Explore a specific node's connections
128
+ marketing export Export all data as JSON
129
+ ```
130
+
131
+ ### Configuration
132
+ ```
133
+ marketing config show Show current configuration
134
+ marketing config set <key> <val> Set a config value (e.g., learning.intervalMs 600000)
135
+ marketing config delete <key> Revert a config key to default
136
+ marketing config path Show config file location
137
+ ```
138
+
139
+ ### Example Workflow
140
+
141
+ ```bash
142
+ # Track a new post
143
+ marketing post x --content "Just shipped v2.0!" --campaign "Product Launch" --hashtags "#launch,#dev"
144
+
145
+ # Update engagement later
146
+ # (via MCP tool or API: marketing_post_engagement)
147
+
148
+ # See what the brain learned
149
+ marketing insights
150
+ marketing rules
151
+ marketing learn
152
+
153
+ # Open the visual dashboard
154
+ marketing dashboard
155
+
156
+ # Explore the synapse network
157
+ marketing network
158
+ marketing network --node post:1
159
+
160
+ # Search across everything
161
+ marketing query "developer tools"
162
+
163
+ # Export your data
164
+ marketing export > marketing-data.json
165
+
166
+ # Get suggestions before your next post
167
+ marketing suggest "developer tools"
168
+ ```
169
+
170
+ ## MCP Tools
171
+
172
+ These tools are available to Claude Code when Marketing Brain is configured:
173
+
174
+ | Tool | Description |
175
+ |------|-------------|
176
+ | `marketing_post_draft` | Check a post draft against learned rules |
177
+ | `marketing_post_report` | Report a published post |
178
+ | `marketing_post_engagement` | Update engagement metrics (likes, shares, etc.) |
179
+ | `marketing_post_similar` | Find similar posts via synapse network |
180
+ | `marketing_campaign_create` | Create a new campaign |
181
+ | `marketing_campaign_stats` | Get campaign performance stats |
182
+ | `marketing_strategy_report` | Report a strategy that worked |
183
+ | `marketing_strategy_suggest` | Get strategy suggestions for a context |
184
+ | `marketing_template_find` | Find reusable content templates |
185
+ | `marketing_rule_check` | Check content against all learned rules |
186
+ | `marketing_insight_list` | Get active insights (trends, gaps, synergies) |
187
+ | `marketing_analytics_summary` | Full analytics overview |
188
+ | `marketing_analytics_best` | Top performing posts and strategies |
189
+
190
+ ## REST API
191
+
192
+ Marketing Brain includes a REST API on port 7780 (default).
193
+
194
+ ```bash
195
+ # Health check
196
+ curl http://localhost:7780/api/v1/health
197
+
198
+ # List all available methods
199
+ curl http://localhost:7780/api/v1/methods
200
+
201
+ # Call any method via RPC
202
+ curl -X POST http://localhost:7780/api/v1/rpc \
203
+ -H "Content-Type: application/json" \
204
+ -d '{"method": "analytics.summary", "params": {}}'
205
+ ```
206
+
207
+ ## Dashboard Server
208
+
209
+ The daemon starts a live dashboard server on port 7782 (default).
210
+
211
+ ```bash
212
+ # Open the dashboard in your browser
213
+ marketing dashboard
214
+
215
+ # Or visit directly while the daemon is running
216
+ open http://localhost:7782
217
+ ```
218
+
219
+ Features:
220
+ - Real-time stats updates via Server-Sent Events (SSE)
221
+ - Interactive force-directed synapse network graph
222
+ - Platform distribution charts
223
+ - Top performing posts with engagement scores
224
+ - Research insights organized by type
225
+ - Neural canvas background with mouse interaction
226
+
227
+ ## Architecture
228
+
229
+ ```
230
+ +------------------+ +------------------+ +------------------+
231
+ | Claude Code | | Browser/CI/CD | | Dashboard |
232
+ | (MCP stdio) | | (REST API) | | (SSE live) |
233
+ +--------+---------+ +--------+---------+ +--------+---------+
234
+ | | |
235
+ v v v
236
+ +--------+---------+ +--------+---------+ +--------+---------+
237
+ | MCP Server | | REST API | | Dashboard Server |
238
+ | (stdio) | | (port 7780) | | (port 7782) |
239
+ +--------+---------+ +--------+---------+ +--------+---------+
240
+ | | |
241
+ +----------+-------------+----------+-------------+
242
+ |
243
+ v
244
+ +----------+-----------+
245
+ | MarketingCore |
246
+ | (Daemon / Services) |
247
+ +----------+-----------+
248
+ |
249
+ +-------+-------+--------+-------+
250
+ | | | | |
251
+ v v v v v
252
+ +---+--+ +--+---+ +-+-----+ +-+--+ +-+------+
253
+ |Post | |Camp- | |Synapse| |Rule| |Template|
254
+ |Track | |aigns | |Network| |Eng.| |Library |
255
+ +---+--+ +--+---+ +-+-----+ +-+--+ +-+------+
256
+ | | | | |
257
+ v v v v v
258
+ +---+--+ +--+---+ +-+-----+ +-+--+ +-+------+
259
+ |Learn | |Strat-| |Hebbian| |Ins-| |Audience|
260
+ |Engine| |egies | |Learn | |ight| |Segments|
261
+ +------+ +------+ +-------+ +----+ +--------+
262
+ |
263
+ v
264
+ +----------+-----------+
265
+ | SQLite (DB) |
266
+ | better-sqlite3 |
267
+ +----------------------+
268
+ ```
269
+
270
+ ### Synapse Types
271
+
272
+ ```
273
+ post → campaign (belongs_to)
274
+ post → post (similar_to)
275
+ post → audience (engages_with)
276
+ strategy → post (improves)
277
+ rule → post (prevents / recommends)
278
+ template → post (generated_from)
279
+ campaign → campaign (cross_promotes)
280
+ insight → campaign (informs)
281
+ ```
282
+
283
+ ## How It Learns
284
+
285
+ 1. **Post Reported** — You publish a post and report it via CLI or MCP tool
286
+ 2. **Engagement Tracked** — Likes, shares, impressions are updated over time
287
+ 3. **Synapses Form** — Post ↔ Campaign, Post ↔ Post (similar), Strategy ↔ Post connections are created
288
+ 4. **Patterns Extracted** — Learning engine finds timing, format, and platform patterns
289
+ 5. **Rules Generated** — High-confidence patterns become rules with Wilson Score confidence
290
+ 6. **Research Runs** — Trends, gaps, and synergies are surfaced as actionable insights
291
+ 7. **Next Time** — When you draft a new post, Marketing Brain checks it against rules and suggests proven strategies
292
+
293
+ ## Configuration
294
+
295
+ Configure via environment variables, CLI, or `~/.marketing-brain/config.json`:
296
+
297
+ ```bash
298
+ # View current config
299
+ marketing config show
300
+
301
+ # Set a value
302
+ marketing config set learning.intervalMs 600000
303
+ marketing config set research.trendWindowDays 14
304
+
305
+ # Revert to default
306
+ marketing config delete learning.intervalMs
307
+ ```
308
+
309
+ ### Environment Variables
310
+
311
+ | Env Variable | Default | Description |
312
+ |---|---|---|
313
+ | `MARKETING_BRAIN_DATA_DIR` | `~/.marketing-brain` | Data directory |
314
+ | `MARKETING_BRAIN_LOG_LEVEL` | `info` | Log level |
315
+ | `MARKETING_BRAIN_API_PORT` | `7780` | REST API port |
316
+ | `MARKETING_BRAIN_API_KEY` | — | API authentication key |
317
+ | `MARKETING_BRAIN_DB_PATH` | `~/.marketing-brain/marketing-brain.db` | Database path |
318
+
319
+ ### Ports
320
+
321
+ | Service | Default Port | Description |
322
+ |---|---|---|
323
+ | REST API | 7780 | JSON-RPC endpoint for integrations |
324
+ | MCP HTTP | 7781 | MCP HTTP transport (optional) |
325
+ | Dashboard | 7782 | Live dashboard with SSE |
326
+
327
+ ## Tech Stack
328
+
329
+ - **TypeScript** — Full type safety, ES2022, ESM modules
330
+ - **better-sqlite3** — Embedded SQLite with WAL mode
331
+ - **MCP SDK** — Model Context Protocol integration (stdio transport)
332
+ - **Commander** — CLI framework
333
+ - **Chalk** — Colored terminal output
334
+ - **Winston** — Structured logging
335
+
336
+ ## Related
337
+
338
+ - [Brain](https://github.com/timmeck/brain) — Adaptive error memory & code intelligence (same architecture, applied to debugging)
339
+
340
+ ## License
341
+
342
+ [MIT](LICENSE)