How merge4victor/word-cloud-generator works
What this project is (type + purpose)
This is a single-binary Go web application that:
• Serves a browser UI (HTML/CSS/JS) for uploading/pasting text.
• Exposes an HTTP JSON API (POST /api) that accepts text and returns data used to render a word cloud.
• Uses Godeps for dependency pinning (Godeps/Godeps.json) and a Makefile for build/test/release automation.
So the “system” is primarily: Browser → Go HTTP server → word cloud generation logic → response (JSON and/or HTML). There is no obvious external database or message queue in the tree.
Read the file tree as architecture clues
Top-level items mapped to responsibilities:
Runtime / application entrypoint
• main.go (+ main_test.go): app bootstrap; likely HTTP routing, server start on :8888, wiring handlers.
• wordyapi/api.go (+ tests): core API handler/business logic (word extraction, counting, weighting, output structure).
Asset bundling into the binary
• Makefile: build orchestration (make, make test, make rice, make run, cross-platform artifacts into ./artifacts).
• Godeps/: dependency snapshotting (pre-Go modules workflow).
• vendor/: vendored dependencies used by the app at build time.
• hooks/git-pre-commit.hook: standardized local dev checks.
• gauntlt/ (+ xss.attack): security testing (likely DAST-style checks) that can be shown as part of the delivery pipeline.
Web Browser (Client)
• Loads GET / (or similar)
• Submits text via UI (form upload or paste)
• Calls POST /api with JSON payload
Go Web App (Single Process / Single Binary)
• HTTP Server / Router (in main.go)
• UI Handler
• Renders templates/upload.tmpl
• Serves embedded static assets (static/*) via go.rice
• API Handler (in wordyapi/api.go)
• Accepts JSON: {"text":"..."}
• Produces response for word cloud (word list + weights/frequencies; exact format inferred)
• Word Cloud / Text Processing Logic
• Tokenization, normalization, counting, ranking
• (Even if implemented inside wordyapi/api.go, call it out as a logical component)
• As a dependency of the UI Handler:
Browser → Go App
• HTTP GET / → returns HTML (from templates/upload.tmpl)
Browser → Go App
• HTTP POST /api with Content-Type: application/json → returns JSON payload (word list/frequencies)
Inside Go App
• Router → UI Handler → Template Renderer → Embedded Templates
• Router → API Handler → Text Processing → JSON Encoder → HTTP Response
If the front-end uses client-side word cloud rendering (likely given jqcloud.css), show:
• “JS Word Cloud Renderer” (in Browser) consuming the /api response.
Important patterns / principles present
• Single deployable artifact: one Go binary (daemon on :8888)
• Separation of concerns:
• main.go: wiring + server lifecycle
• wordyapi/: API/business logic
• templates/ + static/: presentation assets
• Embedded static/template assets using go.rice (packaging pattern)
Technologies to label
• Language/runtime: Go
• Asset bundling: go.rice
• Dependency mgmt: Godeps + vendor/
• Testing: *_test.go, goconvey (dev tool)
• Security testing: gauntlt (gauntlt/xss.attack)
• Build: Makefile (cross-platform artifacts)
Center: Go Web App (single binary)
• Router/Server
• UI Handler → Templates/Static (embedded)
• API Handler (wordyapi) → Text processing
Bottom/side: Build & Packaging
• Makefile pipeline (test → rice embed → build artifacts)
• Godeps/vendor feeding compilation
• gauntlt tests as a security gate