Monitor tweets from selected accounts, store them, and feed an AI reasoning memory layer — all in a clean dark-mode dashboard.
Features · Architecture · Quick Start · API Reference · Roadmap
| Feature | Description |
|---|---|
| Account Manager | Add / remove Twitter/X usernames to monitor |
| Auto Polling | Background worker fetches tweets every N minutes (configurable) |
| Deduplication | Tweets stored by ID — never double-ingested |
| Memory Layer | Store AI interpretations, tags, and importance scores per tweet |
| Live Dashboard | Auto-refreshes every 5 seconds, no page reload needed |
| Settings UI | Change the poll interval live — reschedules the job instantly |
| API Docs Explorer | Reads /openapi.json live, grouped endpoints with cURL copy |
| Swagger UI | Full interactive API docs at /docs |
┌─────────────────────────────────────────────────────────────────┐
│ Frontend (Next.js) │
│ │
│ ┌────────────┐ ┌──────────────┐ ┌───────────┐ ┌─────────┐ │
│ │ Dashboard │ │ Accounts │ │ Memory │ │Settings │ │
│ │ (5s poll) │ │ Manager │ │ Viewer │ │+ API │ │
│ └─────┬──────┘ └──────┬───────┘ └─────┬─────┘ └────┬────┘ │
│ └────────────────┴──────────────── ┴─────────────┘ │
│ lib/api.ts (typed client) │
└─────────────────────────┬───────────────────────────────────────┘
│ HTTP (localhost:8000)
┌─────────────────────────▼───────────────────────────────────────┐
│ Backend (FastAPI) │
│ │
│ /accounts /tweets /memory /fetch /settings /docs │
│ │
│ ┌─────────────────────────┐ ┌──────────────────────────────┐ │
│ │ APScheduler │ │ SQLite │ │
│ │ (configurable poll) │ │ │ │
│ │ fetch_and_store() ────┼──►│ accounts │ tweets │ memory │ │
│ └────────────┬────────────┘ │ │ │settings│ │
│ │ └──────────────────────────────┘ │
└───────────────┼─────────────────────────────────────────────────┘
│ HTTPS
┌───────▼────────┐
│ twitterapi.io │
│ advanced_search│
└────────────────┘
System flow:
- APScheduler runs
fetch_and_store_tweets()every N minutes - Builds dynamic query:
(from:user1 OR from:user2 OR ...) - Calls twitterapi.io Advanced Search (Latest)
- Deduplicates by tweet ID → inserts into
tweetstable - Frontend polls
GET /tweets/newevery 5 seconds - AI agent reads unprocessed tweets →
POST /memorywith interpretation - Memory Viewer surfaces stored reasoning
x-scanner/
├── backend/
│ ├── main.py # FastAPI app entry + lifespan
│ ├── database.py # SQLite connection context manager
│ ├── models.py # Pydantic request models
│ ├── routes/
│ │ ├── accounts.py # GET / POST / DELETE /accounts
│ │ ├── tweets.py # GET /tweets/new · GET /tweets
│ │ ├── memory.py # GET / POST /memory
│ │ ├── fetch.py # POST /fetch (manual trigger)
│ │ └── settings.py # GET / PUT /settings
│ ├── services/
│ │ ├── twitter.py # API fetcher · dedup · query builder
│ │ └── scheduler.py # APScheduler + live reschedule
│ ├── requirements.txt
│ └── .env.example
│
├── frontend/
│ ├── app/
│ │ ├── layout.tsx # Root layout + dark theme
│ │ ├── page.tsx # Dashboard — live tweet feed
│ │ ├── accounts/page.tsx # Account CRUD
│ │ ├── memory/page.tsx # Memory Viewer
│ │ ├── settings/page.tsx # Poll interval + system config
│ │ └── api-docs/page.tsx # Live OpenAPI spec explorer
│ ├── components/
│ │ ├── Sidebar.tsx # Fixed sidebar navigation
│ │ ├── TweetCard.tsx # Tweet display card
│ │ ├── MemoryCard.tsx # Memory entry card
│ │ └── ui/ # Button · Card · Input · Badge
│ ├── lib/
│ │ ├── api.ts # Typed API client
│ │ └── utils.ts # cn() helper
│ └── .env.local.example
│
├── .gitignore
└── README.md
- Python 3.11+
- Node.js 18+
- A twitterapi.io API key
cd backend
# Copy and configure environment
cp .env.example .env
# Open .env and set your TWITTER_API_KEY
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Start the API server
uvicorn main:app --reload --port 8000API available at http://localhost:8000 Interactive Swagger docs at http://localhost:8000/docs
cd frontend
# Copy and configure environment
cp .env.local.example .env.local
# NEXT_PUBLIC_API_URL is set to http://localhost:8000 by default
# Install dependencies
npm install
# Start the dev server
npm run devDashboard available at http://localhost:3000
- Open
http://localhost:3000/accounts - Add Twitter/X usernames you want to monitor (e.g.
elonmusk,sama) - Go to Dashboard and click Fetch Now — or wait for the auto-poll
- Adjust the poll interval at
http://localhost:3000/settings
All endpoints return JSON. Base URL: http://localhost:8000
| Method | Endpoint | Description |
|---|---|---|
GET |
/accounts |
List all monitored accounts |
POST |
/accounts |
Add account { "username": "elonmusk" } |
DELETE |
/accounts/{username} |
Remove account |
| Method | Endpoint | Description |
|---|---|---|
GET |
/tweets/new |
Unprocessed tweets (default limit 50) |
GET |
/tweets |
All tweets, newest first |
POST |
/fetch |
Manually trigger a fetch cycle |
| Method | Endpoint | Description |
|---|---|---|
GET |
/memory |
Recent memory entries (with tweet text joined) |
POST |
/memory |
Store AI interpretation, marks tweet processed |
POST /memory payload:
{
"tweet_id": "1234567890",
"interpretation": "Hints at a new hardware product launch.",
"tags": ["product", "hardware", "launch"],
"importance": 0.87
}| Method | Endpoint | Description |
|---|---|---|
GET |
/settings |
Get current configuration |
PUT |
/settings |
Update config (reschedules job live) |
PUT /settings payload:
{
"poll_interval_minutes": 5
}| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
{ "status": "ok" } |
GET |
/docs |
Swagger UI |
GET |
/openapi.json |
Raw OpenAPI spec |
-- Accounts to monitor
CREATE TABLE accounts (
username TEXT PRIMARY KEY,
added_at TEXT NOT NULL
);
-- Ingested tweets
CREATE TABLE tweets (
id TEXT PRIMARY KEY, -- Twitter tweet ID (dedup key)
text TEXT NOT NULL,
author TEXT NOT NULL,
created_at TEXT NOT NULL,
processed INTEGER DEFAULT 0, -- 1 = AI has processed it
fetched_at TEXT NOT NULL
);
-- AI reasoning memory
CREATE TABLE memory (
id TEXT PRIMARY KEY, -- UUID
tweet_id TEXT NOT NULL REFERENCES tweets(id),
interpretation TEXT NOT NULL,
tags TEXT NOT NULL DEFAULT '', -- comma-separated
importance REAL NOT NULL DEFAULT 0.0, -- 0.0 – 1.0
created_at TEXT NOT NULL
);
-- System configuration
CREATE TABLE settings (
key TEXT PRIMARY KEY,
value TEXT NOT NULL,
updated_at TEXT NOT NULL
);| Variable | Required | Default | Description |
|---|---|---|---|
TWITTER_API_KEY |
✅ | — | Your twitterapi.io API key |
DATABASE_URL |
❌ | tweets.db |
Path to SQLite database file |
| Variable | Required | Default | Description |
|---|---|---|---|
NEXT_PUBLIC_API_URL |
❌ | http://localhost:8000 |
Backend API base URL |
- AI auto-processing — hook Claude/OpenAI to read
/tweets/newand auto-POST to/memory - Webhook support — fire a webhook when high-importance tweets are detected
- Keyword filtering — filter tweets by keyword before storing
- Tweet scoring — pre-rank tweets by relevance before AI processing
- PostgreSQL migration — swap SQLite for Postgres for multi-instance deployments
- Docker Compose — one-command local setup
- Authentication — API key middleware for FastAPI endpoints
- Dark/light mode toggle in UI
- Fork the repo
- Create a feature branch:
git checkout -b feat/your-feature - Commit with conventional commits:
git commit -m "feat: add webhook support" - Push and open a pull request
MIT © Rajdeep Chaudhari