Full-stack app that pulls X (Twitter) user tweets, stores them in MongoDB, and can run OpenAI-based analysis. The frontend is a Vite + React UI that triggers the backend API.
- Fetch X user profile by username and cache it in MongoDB.
- Fetch recent tweets for a user and cache them in MongoDB.
- Analyze stored tweets with OpenAI and store summaries/keywords.
- React UI to submit a username search.
- Backend: Node.js, Express, Mongoose, Axios
- Database: MongoDB
- External APIs: X API, OpenAI API
- Frontend: React, Vite, Tailwind CSS
.
├── Backend
│ ├── Server.js
│ └── Src
│ ├── Controller
│ ├── Service
│ ├── Router
│ ├── Data
│ ├── Model
│ └── ThirdParty
└── frontend
├── src
└── index.html
- Install dependencies
cd Backend
npm install- Create a
.envfile inBackend:
MONGO_URI=your_mongodb_connection_string
X_BEARER_TOKEN=your_x_api_bearer_token
OPENAI_API_KEY=your_openai_api_key
- Start the server
npm startThe server listens on http://localhost:3000.
Base URL: http://localhost:3000/api
GET /health checkGET /x/user/:usernamefetch user and cached tweetsPOST /ai/tweet/analyzeanalyze tweets stored in MongoDB
- Install dependencies
cd frontend
npm install- Optional environment variable:
Create frontend/.env if the API is not on localhost.
VITE_API_URL=http://localhost:3000
- Start the dev server
npm run devVite will print the local URL (typically http://localhost:5173).
- MongoDB must be running before starting the backend.
- The OpenAI analysis endpoint reads tweets already stored in MongoDB.
- The frontend currently sends a request to the backend when searching a username.