캡스톤 디자인 프로젝트 -맛집 정보 사이트 만들기- (3) 데이터 베이스 및 Postgresql

2024. 12. 2. 16:03프로젝트

728x90
반응형

각 테이블 구조는 이런식으로 되어있습니다.

users id (PK), username, password, email, full_name, phone_number, created_at, reset_password_token,
reset_password_expiry
restaurants restaurants_id (PK), restaurants_name, address, phone, opening_hours, rating, spicy, sweet, sour, salty, food_type, image, latitude, longitude, category, food_menu
reviews id (PK), username, contents, date, rating, restaurant_id (FK), author_id (FK)
hashtags id (PK), contents
reviews_hashtags reviews_id (FK), hashtags_id (FK)
LikeTable id (PK), user_id (FK), restaurants_id (FK), created_at
posts post_id (PK), title, content, post_date, author_id (FK), username
comments id (PK), comment_text, comment_date, username, author_id (FK), post_id (FK)

 

node.js를 통해서 express를 통해서 백엔드를 구현하도록 하겠습니다.

폴더를 하나 만들어주고 터미널을 켜서 npm i express를 설치하고 npm i 를 통해  node_modules를 설치를 해줍니다.

npm i express

npm i

 

또한 .gitignore파일을 설치해주고 아래 코드를 복붙 해줍니다.

# npm
node_modules
package-lock.json
*.log
*.gz

# Coveralls
.nyc_output
coverage

# Benchmarking
benchmarks/graphs

 

기본 설정은 끝이 나고 이 백엔드 폴더는 Node.js 기반의 Express 웹 애플리케이션 서버입니다.

주요 기능을 사용할것 입니다.

  1. PostgreSQL 데이터베이스와 연결
  2. 세션 기반 인증 및 사용자 관리
  3. CORS 설정을 통한 프론트엔드와의 통신
  4. 다양한 API 엔드포인트로 데이터 처리 (식당, 리뷰, 커뮤니티 등)

세션 기반 인증은

사용자가 로그인한 상태를 유지하기 위해 서버와 클라이언트 간의 세션 정보를 활용하는 인증 방식입니다

 

CORS (Cross-Origin Resource Sharing)는 다른 도메인 간 요청을 허용하거나 제한하는 웹 보안 메커니즘입니다.

https://codingbasics.tistory.com/311

 

CORS란

1. CORS가 대체 뭐길래?CORS(Cross-Origin Resource Sharing)는 서로 다른 도메인 간 요청을 허용하거나 차단하는 규칙입니다.동일 출처 정책(Same-Origin Policy)브라우저는 기본적으로 보안 때문에 **동일 출처(S

codingbasics.tistory.com

 

프론트 코드와 백엔드 코드를 보면서 자세하게 분석해보겠습니다.