How alex-vesel/xai-hackathon works
Project type and purpose
• This is a full-stack, data-visualization web application (“A Hitchhiker’s Guide to X”) that lets users enter an X (formerly Twitter) username, fetch their tweets and mentions, embed those with xAI/OpenAI, then render an interactive force-graph in the browser.
• Frontend: React app (built with Create React App) that provides UI components (chat sidebar, tweet input, force-graph).
• Backend: Python FastAPI (uvicorn) serving REST endpoints, orchestrating calls to the X API, xAI embed API, and Grok interface.
File structure
• Top-level: package.json & requirements.txt → Node and Python package management.
• src/backend: FastAPI app modules
• main.py (entrypoint)
• server.py (API routes)
• orchestrator.py (business logic)
• grok_interface.py, xai_embed_api.py, x_api.py (external-service wrappers)
• graph.py (graph data model)
• client_demo.py, testing.py (demos/tests)
• src/frontend: React app
• public/ (static HTML, manifest)
• src/ (JS/CSS)
– components/ (UI widgets)
– endpoints/ (JS modules calling backend)
– forcegraph.js (visualization logic)
– useScript.js, data.json (utilities, sample data)
README for additional insights
• No persistent database—graph built on-the-fly in memory.
• Deploy: npm start for frontend; uvicorn main:app for backend.
• Relies on environment variables for X API, xAI API, OpenAI API credentials.
Elements
• Clear labels: React SPA, FastAPI server, Orchestrator, X API, xAI API, Grok API
• Browser → Frontend HTTP calls (e.g. /init, /addNodes)
• Frontend → Backend
• Backend → External services
• Backend → Frontend (JSON response)
• Rectangles for internal components (Frontend modules in blue, Backend modules in green)
• Clouds for external services (X API, xAI Embed, Grok/OpenAI)