Skip to content

πŸ“Š 섀문쑰사 μ„œλΉ„μŠ€ A-FORM Server

Notifications You must be signed in to change notification settings

chldppwls12/aform-service-survey

Β 
Β 

Repository files navigation

🌼 λͺ¨λ‘λ₯Ό μœ„ν•œ 섀문쑰사 ν”Œλž«νΌ, A-FORM

a-form μ„€λ¬Έ 쑰사 생성 및 뢄석 ν”„λ‘œμ„ΈμŠ€λ₯Ό λ‹¨μˆœν™”ν•˜μ—¬ μ„€λ¬Έ 쑰사 μ œμž‘μžμ™€ μ‘λ‹΅μž κ°„μ˜ 참여와 ν”Όλ“œλ°±μ„ 높일 수 μžˆλŠ” κ°„νŽΈν•œ μ„€λ¬Έ 쑰사 ν”Œλž«νΌμž…λ‹ˆλ‹€.

개발 κΈ°κ°„ 2023.03 ~ 2023.05
μ‚¬μ΄νŠΈ λ°”λ‘œκ°€κΈ° https://server.acceler.kr/ (πŸ”§μ—…λ°μ΄νŠΈ 쀑)
Team repo https://github.com/orgs/KEA-ACCELER/repositories

😺 Stacks

πŸ“š Project Structure

src
β”œβ”€β”€ common          # 곡톡 μ»΄ν¬λ„ŒνŠΈ
β”‚   β”œβ”€β”€ constant
β”‚   β”œβ”€β”€ decorator
β”‚   β”œβ”€β”€ dto
β”‚   β”œβ”€β”€ guard
β”‚   └── pipe
β”œβ”€β”€ cache           # μΊμ‹œ λͺ¨λ“ˆ
β”œβ”€β”€ batch           # batch λͺ¨λ“ˆ
β”œβ”€β”€ answer          # 응닡 λͺ¨λ“ˆ
β”‚   β”œβ”€β”€ controller
β”‚   β”œβ”€β”€ dto
β”‚   β”œβ”€β”€ helper
β”‚   β”œβ”€β”€ pipe
β”‚   β”œβ”€β”€ repository
β”‚   └── service
β”œβ”€β”€ file            # 파일 λͺ¨λ“ˆ
β”‚   β”œβ”€β”€ controller
β”‚   β”œβ”€β”€ dto
β”‚   β”œβ”€β”€ helper
β”‚   β”œβ”€β”€ repository
β”‚   └── service
β”œβ”€β”€ my-page         # λ§ˆμ΄νŽ˜μ΄μ§€ λͺ¨λ“ˆ
β”‚   β”œβ”€β”€ controller
β”‚   └── service
β”œβ”€β”€ schema          # μŠ€ν‚€λ§ˆ
└── survey          # 섀문지 λͺ¨λ“ˆ
    β”œβ”€β”€ controller
    β”œβ”€β”€ dto
    β”œβ”€β”€ helper
    β”œβ”€β”€ pipe
    β”œβ”€β”€ repository
    └── service

Components

  • common
    • κ³΅ν†΅μ μœΌλ‘œ μ‚¬μš©λ  파일둜 ꡬ성
    • constant, decorator, dto, guard, pipe λ“±
  • cache
    • λ ˆλ””μŠ€λ₯Ό μ‚¬μš©ν•œ 기본적인 캐싱 처리
  • batch
    • λ§€μ‹œκ°„λ§ˆλ‹€ μŠ€μΌ€μ€„λŸ¬λ₯Ό 톡해 μ‹œκ°„λ³„ 인기글 캐싱 처리
  • schema
    • μŠ€ν‚€λ§ˆ κ΄€λ ¨ 파일둜 ꡬ성
  • answer
    • μ„€λ¬Έ 응닡 κ΄€λ ¨ 파일둜 ꡬ성
  • file
    • 파일 처리 κ΄€λ ¨ 파일둜 ꡬ성
  • my-page
    • λ§ˆμ΄νŽ˜μ΄μ§€ κ΄€λ ¨ 파일둜 ꡬ성
  • survey
    • μ„€λ¬Έ κ΄€λ ¨ 파일둜 ꡬ성

πŸ™‚ Pattern & Workflow

Repository Pattern

λΉ„μ¦ˆλ‹ˆμŠ€ 둜직이 μžˆλŠ” μ„œλΉ„μŠ€ 계측과 λ°μ΄ν„°λ² μ΄μŠ€μ— μ ‘κ·Όν•˜λŠ” 데이터 μ†ŒμŠ€ 계측 사이에 λ ˆν¬μ§€ν† λ¦¬ 계측을 생성해 두 계측을 쀑계

Caching

캐싱 μ „λž΅ Look Aside + Write Around

  • 데이터λ₯Ό 찾을 λ•Œ μš°μ„ μ μœΌλ‘œ μΊμ‹œμ— μžˆλŠ”μ§€ ν™•μΈν•˜κ³ , μΊμ‹œμ— 데이터가 μ—†λŠ” κ²½μš°μ—λ§Œ λ°μ΄ν„°λ² μ΄μŠ€(DB)μ—μ„œ 쑰회 -> 이후 μ‘°νšŒν•œ λ°μ΄ν„°λŠ” μΊμ‹œμ— μ €μž₯

μ‹œκ°„λ³„ 인기 μ„€λ¬Έ 캐싱 μ •κ°λ§ˆλ‹€ cron job을 톡해 μ‹œκ°„λ³„ 인기 μ„€λ¬Έ(이전 ν•œ μ‹œκ°„ λ™μ•ˆ μ„€λ¬Έ 응닡이 κ°€μž₯ λ§Žμ€ 것)을 캐싱

 @Cron(CronExpression.EVERY_HOUR, {
    name: 'popular-survey',
    timeZone: 'Asia/Seoul',
  })
  async cachingPopularSurvey() {
    const currentTime = moment().tz('Asia/Seoul').toDate();
    const popularSurvey = await this.surveyService.findPopular({
      date: currentTime,
      type: PopularSurveyResponseType.ID,
    });

    await this.cacheService.set(
      this.keyHelper.getPopularSurveyKey(currentTime),
      JSON.stringify(popularSurvey),
    );
  }

✨ Installation

.env

PORT=

# MONGOOSE
DATABASE_URL=
DATABASE_USER=
DATABASE_PASSWORD=

# REDIS
USER_HOSTNAME=
REDIS_HOST=
REDIS_PORT=

# AWS S3
AWS_ENDPOINT=
REGION=
S3_BUCKET_NAME=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=

Running the app

  • λ‘œμ»¬μ—μ„œ μ‹€ν–‰
# νŒ¨ν‚€μ§€ μ„€μΉ˜
$ npm install

# development, 데λͺ¨ μ‹œ μ‚¬μš©
$ npm start

# watch mode
$ npm run start:dev

# debug mode
$ npm run start:debug

# production mode
$ npm run start:prod
  • 도컀 μ»¨ν…Œμ΄λ„ˆ μ‹€ν–‰
docker compose up -d

πŸ€ Swagger

http://localhost:${PORT}/surveys/api

swagger

🌱 Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

About

πŸ“Š 섀문쑰사 μ„œλΉ„μŠ€ A-FORM Server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.8%
  • JavaScript 2.0%
  • Dockerfile 0.2%