chore: add Docker deployment files, README, and Prisma migrations

- Add Dockerfile and docker-compose.yml for VPS/LXC deployment.
- Update README with setup, environment variables, and deployment notes.
- Commit initial Prisma migration for SQLite schema.
- Configure Next.js for standalone output and dev origin allowlist.
This commit is contained in:
hermes
2026-06-17 04:34:39 +00:00
parent 1b23f57d6c
commit 6d3cb9d678
6 changed files with 275 additions and 21 deletions

131
README.md
View File

@@ -1,36 +1,127 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
# BiasNews Aggregator
## Getting Started
A full-stack news aggregation website that collects articles, uses AI to classify them by political bias (Left / Center / Right), and presents them in side-by-side columns. Includes a protected admin console for discovering news, managing API keys, and configuring automated searches.
First, run the development server:
## Features
- **Public site**
- Three-column layout: Left, Center, Right
- Search and filter by bias, topic, date, source
- Article detail pages with AI summary and bias explanation
- Mobile-responsive design
- **Admin console**
- Secure credential-based login
- Discover news on demand using NewsAPI, GNews, or Serper web search
- AI processing via Kimi (OpenAI-compatible API) for:
- Summarization
- Bias classification (LEFT / CENTER / RIGHT)
- Political tags (liberal / moderate / conservative)
- Importance ranking and credibility scoring
- Topic extraction
- Manage published/draft/archived articles
- Encrypted API key storage with easy rotation
- Automated search rules with cron scheduling
- Source credibility and active/inactive toggles
## Tech stack
- Next.js 16 (App Router, TypeScript)
- Tailwind CSS 4
- Prisma ORM + SQLite
- `jose` for session cookies
- `bcryptjs` for password hashing
- `node-cron` for scheduled rules
- `openai` SDK for Kimi-compatible APIs
## Local development
```bash
npm install
# Copy environment file and fill in secrets + API keys
cp .env.example .env.local
# Generate admin password hash
npx tsx scripts/generate-admin-hash.ts your-password
# Update ADMIN_PASSWORD_HASH in .env.local
# Apply database migrations and seed default sources
npx prisma migrate dev --name init
npx prisma db seed
# Run dev server
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
Open:
- Public site: http://localhost:3000
- Admin console: http://localhost:3000/admin
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
## API keys
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
Add keys in **Admin > API Keys**:
## Learn More
| Provider | Purpose | How to get |
|----------|---------|------------|
| KIMI | AI summarization / bias / ranking | https://platform.moonshot.cn |
| NEWSAPI | News articles | https://newsapi.org |
| GNEWS | News articles | https://gnews.io |
| WEBSEARCH | Web search via Serper | https://serper.dev |
To learn more about Next.js, take a look at the following resources:
API keys are encrypted at rest with `API_KEY_ENCRYPTION_SECRET`.
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
## Deployment (Docker)
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
```bash
# Build image
docker build -t biasnews .
## Deploy on Vercel
# Run container
docker run -d \
-p 3000:3000 \
-e DATABASE_URL="file:./data/dev.db" \
-e ADMIN_USERNAME=admin \
-e ADMIN_PASSWORD_HASH="$2b$10$..." \
-e NEXTAUTH_SECRET="..." \
-e API_KEY_ENCRYPTION_SECRET="..." \
-e KIMI_API_URL="https://api.moonshot.cn/v1" \
-e KIMI_MODEL="moonshot-v1-8k" \
-v $(pwd)/data:/app/data \
biasnews
```
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Or use Docker Compose:
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
```bash
docker compose up -d
```
## Automated searches
Create a rule in **Admin > Auto Rules**. The scheduler loads active rules when the app starts and reschedules whenever rules change. Each rule specifies:
- Search query
- Sources to query
- Cron schedule
- Max results
- Minimum rank score threshold
- Whether to auto-publish results
## Architecture notes
- The admin console is part of the same Next.js app but protected by authentication. It can be accessed from a separate machine (e.g., local laptop) by browsing to the public URL and logging in.
- If you want a fully separate admin deployment later, the admin API routes are isolated under `/api/admin/*` and admin pages under `/admin/*`.
- SQLite is used for single-node simplicity. For production scale, switch to PostgreSQL by changing the Prisma datasource URL.
## Scripts
```bash
npm run dev # Start dev server
npm run build # Production build
npm run start # Start production server
npm run db:migrate # Run Prisma migrations
npm run db:seed # Seed default sources and admin user
npm run db:studio # Open Prisma Studio
```