Files
site11/services/news-engine-console
jungwoo choi 52c857fced feat: Complete backend implementation - Users, Applications, Monitoring
Phase 1 Backend 100% 완료:

 UserService (312 lines):
- 인증 시스템 (authenticate_user, JWT 토큰 생성)
- CRUD 전체 기능 (get, create, update, delete)
- 권한 기반 필터링 (role, disabled, search)
- 비밀번호 관리 (change_password, hash 검증)
- 상태 토글 및 통계 조회

 ApplicationService (254 lines):
- OAuth2 클라이언트 관리
- Client ID/Secret 자동 생성
- Secret 재생성 기능
- 소유권 검증 (ownership check)
- 통계 조회 (grant types별)

 MonitoringService (309 lines):
- 시스템 헬스 체크 (MongoDB, pipelines)
- 시스템 메트릭 (keywords, pipelines, users, apps)
- 활동 로그 조회 (필터링, 날짜 범위)
- 데이터베이스 통계 (크기, 컬렉션, 인덱스)
- 파이프라인 성능 분석
- 에러 요약

 Users API (11 endpoints + OAuth2 로그인):
- POST /login - OAuth2 password flow
- GET /me - 현재 사용자 정보
- GET / - 사용자 목록 (admin only)
- GET /stats - 사용자 통계 (admin only)
- GET /{id} - 사용자 조회 (자신 or admin)
- POST / - 사용자 생성 (admin only)
- PUT /{id} - 사용자 수정 (권한 검증)
- DELETE /{id} - 사용자 삭제 (admin only, 자기 삭제 방지)
- POST /{id}/toggle - 상태 토글 (admin only)
- POST /change-password - 비밀번호 변경

 Applications API (7 endpoints):
- GET / - 애플리케이션 목록 (admin: 전체, user: 자신 것만)
- GET /stats - 통계 (admin only)
- GET /{id} - 조회 (소유자 or admin)
- POST / - 생성 (client_secret 1회만 표시)
- PUT /{id} - 수정 (소유자 or admin)
- DELETE /{id} - 삭제 (소유자 or admin)
- POST /{id}/regenerate-secret - Secret 재생성

 Monitoring API (8 endpoints):
- GET /health - 시스템 헬스 상태
- GET /metrics - 시스템 메트릭
- GET /logs - 활동 로그 (필터링 지원)
- GET /database/stats - DB 통계 (admin only)
- GET /database/collections - 컬렉션 통계 (admin only)
- GET /pipelines/performance - 파이프라인 성능
- GET /errors/summary - 에러 요약

주요 특징:
- 🔐 역할 기반 접근 제어 (RBAC: admin/editor/viewer)
- 🔒 OAuth2 Password Flow 인증
- 🛡️ 소유권 검증 (자신의 리소스만 수정)
- 🚫 안전 장치 (자기 삭제 방지, 자기 비활성화 방지)
- 📊 종합적인 모니터링 및 통계
- 🔑 안전한 Secret 관리 (1회만 표시)
-  완전한 에러 핸들링

Backend API 총 45개 엔드포인트 완성!
- Keywords: 8
- Pipelines: 11
- Users: 11
- Applications: 7
- Monitoring: 8

다음 단계:
- Frontend 구현 (React + TypeScript + Material-UI)
- Docker & Kubernetes 배포
- Redis 통합
- 테스트 작성

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 16:58:02 +09:00
..

News Engine Console

뉴스 파이프라인 관리 및 모니터링 통합 콘솔 시스템

프로젝트 개요

News Engine Console은 뉴스 파이프라인의 전체 lifecycle을 관리하고 모니터링하는 통합 관리 시스템입니다.

핵심 기능

  1. 키워드 관리 - 파이프라인 키워드 CRUD, 활성화/비활성화
  2. 파이프라인 모니터링 - 파이프라인별 처리 수량, 활용도 통계
  3. 파이프라인 제어 - 스텝별 시작/중지, 스케줄링
  4. 로깅 시스템 - 파이프라인 상태 로그, 에러 추적
  5. 사용자 관리 - User CRUD, 역할 기반 권한 (Admin/Editor/Viewer)
  6. 애플리케이션 관리 - OAuth2/JWT 기반 Application CRUD
  7. 시스템 모니터링 - 서비스 헬스체크, 리소스 사용량

기술 스택

Backend

  • FastAPI (Python 3.11)
  • Motor (MongoDB async driver)
  • Redis (캐싱, Pub/Sub)
  • JWT + OAuth2 인증

Frontend (예정)

  • React 18 + TypeScript
  • Material-UI v7
  • React Query
  • Recharts (통계 차트)

Infrastructure

  • Docker
  • Kubernetes
  • MongoDB (ai_writer_db)
  • Redis

프로젝트 구조

services/news-engine-console/
├── README.md
├── TODO.md                      # 상세 구현 계획
├── backend/
│   ├── Dockerfile
│   ├── requirements.txt
│   ├── main.py
│   ├── .env.example
│   └── app/
│       ├── api/                 # API 엔드포인트
│       │   ├── keywords.py      # ✅ 키워드 관리
│       │   ├── pipelines.py     # ✅ 파이프라인 제어/모니터링
│       │   ├── users.py         # ✅ 사용자 관리
│       │   ├── applications.py  # ✅ Application 관리
│       │   └── monitoring.py    # ✅ 시스템 모니터링
│       ├── core/                # 핵심 설정
│       │   ├── config.py        # ✅ 설정 관리
│       │   ├── database.py      # ✅ MongoDB 연결
│       │   └── auth.py          # ✅ JWT/OAuth2 인증
│       ├── models/              # 데이터 모델 (TODO)
│       ├── services/            # 비즈니스 로직 (TODO)
│       └── schemas/             # Pydantic 스키마 (TODO)
├── frontend/                    # TODO
│   └── src/
│       ├── api/
│       ├── components/
│       ├── pages/
│       └── types/
└── k8s/                         # TODO
    ├── namespace.yaml
    ├── backend-deployment.yaml
    ├── frontend-deployment.yaml
    └── service.yaml

현재 구현 상태

완료

  • 프로젝트 디렉토리 구조
  • Backend 기본 설정 (config, database, auth)
  • API 라우터 기본 구조 (5개 라우터)
    • Keywords API
    • Pipelines API
    • Users API
    • Applications API
    • Monitoring API

🚧 진행 중

  • Backend 상세 구현 (models, services, schemas)
  • MongoDB 컬렉션 및 인덱스 설계
  • Redis 연결 및 캐싱 로직

📋 예정

  • Frontend 구현
  • Dockerfile 작성
  • Kubernetes 배포 설정
  • CI/CD 파이프라인
  • API 문서 (OpenAPI/Swagger)

API 엔드포인트

Keywords API (/api/v1/keywords)

  • GET / - 키워드 목록 조회
  • POST / - 키워드 생성
  • PUT /{keyword_id} - 키워드 수정
  • DELETE /{keyword_id} - 키워드 삭제

Pipelines API (/api/v1/pipelines)

  • GET / - 파이프라인 목록 및 상태
  • GET /{pipeline_id}/stats - 파이프라인 통계
  • POST /{pipeline_id}/start - 파이프라인 시작
  • POST /{pipeline_id}/stop - 파이프라인 중지

Users API (/api/v1/users)

  • GET / - 사용자 목록
  • POST / - 사용자 생성
  • GET /me - 현재 사용자 정보

Applications API (/api/v1/applications)

  • GET / - Application 목록
  • POST / - Application 생성 (OAuth2 클라이언트 등록)

Monitoring API (/api/v1/monitoring)

  • GET /system - 시스템 상태
  • GET /logs - 파이프라인 로그

로컬 개발 환경 설정

Prerequisites

  • Python 3.11+
  • MongoDB (localhost:27017)
  • Redis (localhost:6379)

Backend 실행

cd services/news-engine-console/backend

# 가상환경 생성 (선택)
python3 -m venv venv
source venv/bin/activate

# 의존성 설치
pip install -r requirements.txt

# 환경 변수 설정
cp .env.example .env
# .env 파일 수정

# 서버 실행
python main.py

서버 실행 후: http://localhost:8100/docs (Swagger UI)

환경 변수

# MongoDB
MONGODB_URL=mongodb://localhost:27017
DB_NAME=ai_writer_db

# Redis
REDIS_URL=redis://localhost:6379

# JWT
SECRET_KEY=your-secret-key-here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30

# Service
SERVICE_NAME=news-engine-console
API_V1_STR=/api/v1
PORT=8100

# CORS
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:3100

다음 단계 (TODO.md 참조)

Phase 1: Backend 완성 (우선순위 높음)

  1. MongoDB 스키마 설계

    • keywords 컬렉션
    • pipelines 컬렉션
    • users 컬렉션
    • applications 컬렉션
    • logs 컬렉션
  2. Pydantic 모델 및 스키마 작성

    • Request/Response 모델
    • 유효성 검증
  3. 비즈니스 로직 구현

    • KeywordService
    • PipelineService
    • UserService
    • ApplicationService
    • MonitoringService
  4. Redis 통합

    • 캐싱 레이어
    • Pub/Sub for real-time updates

Phase 2: Frontend 구현

  1. React 프로젝트 설정
  2. Material-UI 레이아웃
  3. 페이지 구현
    • Dashboard (통계 요약)
    • Keywords Management
    • Pipelines Control
    • Users Management
    • Applications Management
    • System Monitoring

Phase 3: 배포

  1. Dockerfile 작성
  2. Kubernetes 매니페스트
  3. CI/CD 설정

데이터베이스 설계 (Draft)

keywords 컬렉션

{
  "_id": "ObjectId",
  "keyword": "string",
  "category": "string",
  "status": "active|inactive",
  "created_at": "datetime",
  "updated_at": "datetime",
  "created_by": "user_id"
}

pipelines 컬렉션

{
  "_id": "ObjectId",
  "name": "string",
  "type": "rss|translation|image",
  "status": "running|stopped|error",
  "config": {},
  "stats": {
    "total_processed": 0,
    "success_count": 0,
    "error_count": 0,
    "last_run": "datetime"
  }
}

users 컬렉션

{
  "_id": "ObjectId",
  "username": "string",
  "email": "string",
  "hashed_password": "string",
  "full_name": "string",
  "role": "admin|editor|viewer",
  "disabled": false,
  "created_at": "datetime"
}

역할 기반 권한

  • Admin: 모든 기능 접근
  • Editor: 키워드/파이프라인 관리, 모니터링 조회
  • Viewer: 조회만 가능

기여 가이드

  1. 기능 구현 전 TODO.md 확인
  2. API 엔드포인트 추가 시 문서 업데이트
  3. 테스트 코드 작성
  4. Commit 메시지 규칙 준수

라이선스

Part of Site11 Platform - Internal Use


최종 업데이트: 2024-01-15 버전: 0.1.0 (Alpha) 작성자: Site11 Development Team