Skip to content

ehdgus4173/WP_Final-Project_BE

Repository files navigation

📰 What's Today — Backend

One news issue a day, curated by AI — a place to read, post, and debate.

Backend for What's Today: a discussion forum where everyone gathers around a single news issue that AI curates every day at 06:00 KST, then shares posts, comments, and votes.


CI Node.js Express PostgreSQL Supabase JWT Jest Render

🔗 Live API · API Docs (Swagger) · Web App

Seoultech ITM519 · Web Programming Final Project (2026)


Features

  • AI-curated daily issue — Google Gemini (Grounding with Google Search) generates one news issue every day at 06:00 KST.
  • Admin review — generated issues stay pending until an admin approves and publishes them.
  • Posts & threaded comments — write posts under an issue, comment, and reply (1-level deep) with likes & mentions.
  • Voting — upvote / downvote posts; one vote per user per post.
  • Auth — email/password (JWT) and social login (Google / GitHub via Supabase OAuth).
  • Profiles (MyPage) — edit your username & description, view your recent posts; public read-only profiles for others.

Tech Stack

Area Technology
Runtime Node.js
Framework Express
Database PostgreSQL 16 (hosted on Supabase)
DB driver pg (raw SQL, no ORM)
Auth JWT (HS256) + bcrypt · Supabase OAuth
AI Google Gemini (Search grounding)
Testing Jest + Supertest
CI / CD GitHub Actions / Render

Architecture

A one-directional, layered request flow:

routes → controllers → services → repositories → db
Layer Responsibility
routes declare endpoints + request validation
controllers HTTP I/O only (parse request, shape the response envelope)
services domain rules & transactions
repositories raw parameterized SQL (pg, no ORM)

Every response uses a common envelope:

// success
{ "success": true, "data": { /* ... */ } }
// failure
{ "success": false, "error": { "code": "BAD_INPUT", "message": "..." } }

Getting Started

# 1. Clone & install
git clone https://github.com/ehdgus4173/WP_Final-Projcet_BE.git
cd WP_Final-Projcet_BE
npm install

# 2. Configure environment
cp .env.example .env        # then fill in the values

# 3. Run
npm run dev                 # development (nodemon, auto-reload)
npm start                   # production

The server starts on http://localhost:3000 and the API is served under /api.

Environment variables

Variable Description
PORT Server port (default 3000)
DATABASE_URL Supabase PostgreSQL connection string
JWT_SECRET / JWT_EXPIRES_IN JWT signing secret & TTL
FE_ORIGIN Allowed frontend origin(s) for CORS (comma-separated)
GEMINI_API_KEY Google Gemini key (AI cron)
CRON_SECRET Bearer secret for the internal cron endpoint

API

Quick health check:

curl https://wp-final-projcet-be.onrender.com/api/health

Testing

npm test

Unit tests (Jest) + API integration tests (Supertest). GitHub Actions runs the full suite automatically on every push and pull request to main and develop, and Render auto-deploys on merge.

📁 Project Structure

WP_Final-Project_BE/
├── src/
│   ├── server.js              # HTTP server entrypoint
│   ├── app.js                 # Express app: middleware + route mounting
│   ├── db.js                  # pg connection pool
│   ├── config/                # env, supabase client, swagger loader
│   ├── routes/                # endpoint + validator definitions
│   ├── controllers/           # HTTP I/O layer
│   ├── services/              # domain rules + transactions
│   ├── repositories/          # raw parameterized SQL
│   ├── middleware/            # auth, validation, rate limiting, errors
│   ├── jobs/                  # AI daily issue generation (Gemini)
│   └── utils/                 # jwt, password, permission, time helpers
├── migrations/                # ordered SQL schema migrations
├── tests/                     # Jest (unit) + Supertest (integration)
│   └── unit/
├── scripts/                   # one-off dev scripts (DB connection check)
├── supabase/                  # pg_cron setup SQL
├── docs/                      # openapi.yaml (served at /api/docs) + API.md
└── package.json

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for the branching model, commit conventions, and pull request process. Both main and develop are protected — all changes go in through a Pull Request.

AI Usage Disclosure

  • Daily issue curation: Google Gemini (Grounding with Google Search) generates one news issue each day at 06:00 KST.
  • Development: AI assistant tools were used for code design, debugging, and documentation drafting.

Seoultech ITM519 · Web Programming · 2026

Packages

 
 
 

Contributors