A web application that displays news articles from different perspectives (liberal, conservative, and neutral).
news-perspectives-app/
├── backend/
│ ├── models/
│ │ └── Article.js
│ ├── routes/
│ │ └── news.js
│ ├── services/
│ │ └── summaryService.js
│ ├── .env
│ ├── package.json
│ └── server.js
└── frontend/
├── public/
├── src/
│ ├── components/
│ │ ├── ArticleList.js
│ │ ├── NavBar.js
│ │ ├── PerspectiveToggle.js
│ │ └── SummaryView.js
│ ├── App.css
│ ├── App.js
│ └── index.js
└── package.json
- Node.js (v14 or higher)
- Supabase account and project
- OpenAI API key
- NewsAPI key
- Docker (for containerization)
- Google Cloud account (for Cloud Run deployment)
-
Navigate to the backend directory:
cd backend
-
Install dependencies:
npm install
-
Create a
.env
file with the following variables (see.env.example
for a template):# OpenAI API Key - Get from https://platform.openai.com/api-keys OPENAI_API_KEY=your_openai_api_key_here # NewsAPI Key - Get from https://newsapi.org/register NEWS_API_KEY=your_newsapi_key_here # Supabase Configuration SUPABASE_URL=https://ueqselkevtzpzgcapbzc.supabase.co SUPABASE_KEY=your_supabase_key_here # Server Configuration PORT=5001
-
Start the development server:
npm run dev
-
Navigate to the frontend directory:
cd frontend
-
Install dependencies:
npm install
-
Start the development server:
npm start
You can run the entire application using Docker Compose:
docker-compose up
This will start both the frontend and backend services.
-
Build and push the backend image:
cd backend gcloud builds submit --tag gcr.io/[PROJECT_ID]/news-perspectives-backend gcloud run deploy news-perspectives-backend --image gcr.io/[PROJECT_ID]/news-perspectives-backend --platform managed --region us-central1 --allow-unauthenticated --set-env-vars OPENAI_API_KEY=[YOUR_OPENAI_API_KEY],NEWS_API_KEY=[YOUR_NEWS_API_KEY],SUPABASE_URL=[YOUR_SUPABASE_URL],SUPABASE_KEY=[YOUR_SUPABASE_KEY]
-
Build and push the frontend image:
cd frontend gcloud builds submit --tag gcr.io/[PROJECT_ID]/news-perspectives-frontend gcloud run deploy news-perspectives-frontend --image gcr.io/[PROJECT_ID]/news-perspectives-frontend --platform managed --region us-central1 --allow-unauthenticated
-
Set up secret environment variables in Secret Manager:
gcloud secrets create OPENAI_API_KEY --replication-policy automatic gcloud secrets create NEWS_API_KEY --replication-policy automatic gcloud secrets create SUPABASE_URL --replication-policy automatic gcloud secrets create SUPABASE_KEY --replication-policy automatic echo -n "your_openai_api_key" | gcloud secrets versions add OPENAI_API_KEY --data-file=- echo -n "your_news_api_key" | gcloud secrets versions add NEWS_API_KEY --data-file=- echo -n "your_supabase_url" | gcloud secrets versions add SUPABASE_URL --data-file=- echo -n "your_supabase_key" | gcloud secrets versions add SUPABASE_KEY --data-file=-
-
Grant Secret Manager access to Cloud Build service account:
gcloud projects add-iam-policy-binding [PROJECT_ID] \ --member="serviceAccount:[PROJECT_NUMBER]@cloudbuild.gserviceaccount.com" \ --role="roles/secretmanager.secretAccessor"
-
Set up a Cloud Build trigger connected to your GitHub repository.
-
Push changes to your repository to trigger the deployment.
-
Initialize Git repository:
git init
-
Add files to Git:
git add .
-
Commit changes:
git commit -m "Initial commit"
-
Add GitHub remote:
git remote add origin https://github.com/yourusername/news-perspectives.git
-
Push to GitHub:
git push -u origin main