Skip to content
/ BE Public

๐Ÿ–๏ธ Airbnb ํด๋ก  ์ฝ”๋”ฉ

Notifications You must be signed in to change notification settings

hanghaebnb/BE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

91 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ํ•ญํ•ดbnb

๋ชฉ์ฐจ

1๏ธ. ํ”„๋กœ์ ํŠธ ์†Œ๊ฐœ
2๏ธ. ์ฃผ์š” ๊ธฐ๋Šฅ
3๏ธ. ์„œ๋น„์Šค ์•„ํ‚คํ…์ณ
4. ERD
5. ๊ธฐ์ˆ  ์Šคํƒ
6. ํŠธ๋Ÿฌ๋ธ” ์ŠˆํŒ…
7. ๊นƒํ—ˆ๋ธŒ
8. ํŒ€์›์ •๋ณด


1. ํ”„๋กœ์ ํŠธ ์†Œ๊ฐœ

๐Ÿ–๏ธ ์—์–ด๋น„์•ค๋น„ ์›น์„œ๋น„์Šค๋ฅผ ํด๋กœ๋‹ํ•œ ํ”„๋กœ์ ํŠธ ์ž…๋‹ˆ๋‹ค!

hanghaebnb

๐Ÿ”— ํŒ€ ๋…ธ์…˜ ๋ณด๋Ÿฌ๊ฐ€๊ธฐ
๐Ÿ“ธ ์‹œ์—ฐ ์˜์ƒ ๋ณด๋Ÿฌ๊ฐ€๊ธฐ


2. ์ฃผ์š” ๊ธฐ๋Šฅ

  • Spring Security, JWT๋ฅผ ์ด์šฉํ•œ ํšŒ์›๊ฐ€์ž…/๋กœ๊ทธ์ธ
  • ์ด๋ฉ”์ผ ์ธ์ฆ์„ ํ†ตํ•œ ๋กœ๊ทธ์ธ ๊ตฌํ˜„
  • AWS S3๋ฅผ ์ด์šฉํ•œ ๋‹ค์ค‘ ์ด๋ฏธ์ง€ ์—…๋กœ๋“œ
  • JPA Pageable์„ ์ด์šฉํ•œ ํŽ˜์ด์ง€ ๋ฌดํ•œ ์Šคํฌ๋กค
  • ํƒ€์ž…๋ณ„, ๊ฐ€๊ฒฉ๋ณ„ ํ•„ํ„ฐ๋ง ๊ธฐ๋Šฅ
  • ํ‚ค์›Œ๋“œ ๊ฒ€์ƒ‰ ๊ธฐ๋Šฅ
  • ์ˆ™์†Œ ์ข‹์•„์š” ๊ธฐ๋Šฅ
  • swagger ์ ์šฉ
  • ๋‹ค์ค‘ ์ด๋ฏธ์ง€ ์—…๋กœ๋“œ CRUD(์กฐํšŒ ์‹œ ์ด๋ฏธ์ง€ preview)

3. ์„œ๋น„์Šค ์•„ํ‚คํ…์ณ

serviceArchitecture


4. ERD

hanghaebnbERD

5. ๊ธฐ์ˆ  ์Šคํƒ

๐ŸŽจ Front-end Stack

  • React , javascript
  • Redux
  • Redux Toolkit
  • mui , styled-components
  • axios

๐Ÿ›  Back-end Stack

  • Spring boot
  • Spring Security, JWT
  • Spring Data JPA

๐ŸŒ Infrastructure

  • AWS EC2
  • AWS S3
  • AWS RDS(MySQL)

๐Ÿ—‚ Dev tools

  • Swagger
  • Git, Github

6. ํŠธ๋Ÿฌ๋ธ” ์ŠˆํŒ…

@Enablejpaauditing

๋ฌธ์ œ

๊ฒŒ์‹œ๊ธ€์„ ์ˆ˜์ •ํ•  ๋•Œ, CreatedAt/ModifiedAt ๊ฐ’์ด null๋กœ ๋ฐ˜ํ™˜๋˜๋Š” ๋ฌธ์ œ ๋ฐœ์ƒ. troubleShooting

ํ•ด๊ฒฐ

@Enablejpaauditing ์–ด๋…ธํ…Œ์ด์…˜ ์ถ”๊ฐ€ํ•˜์—ฌ ํ•ด๊ฒฐ.

@EnableJpaAuditing
@SpringBootApplication
public class HanghaebnbApplication {

    public static void main(String[] args) {
        SpringApplication.run(HanghaebnbApplication.class, args);
    }

}
ํ•„ํ„ฐ๋ง + ํŽ˜์ด์ง• (with Spring Data JPA)

๋ฌธ์ œ

ํŽ˜์ด์ง•๊ณผ ์นดํ…Œ๊ณ ๋ฆฌ๋ณ„/๊ฐ€๊ฒฉ๋ณ„ ์กฐํšŒ๋ฅผ ํ•œ ๋ฒˆ์— ํ•˜๋ ค๋‹ค๋ณด๋‹ˆ ์ฟผ๋ฆฌ๊ฐ€ ๋ณต์žกํ•ด์ ธ์„œ Spring Data JPA์˜ Query Method๋งŒ์œผ๋กœ๋Š” ์กฐํšŒ๊ฐ€ ์–ด๋ ค์šด ์ƒํ™ฉ. @Query ์–ด๋…ธํ…Œ์ด์…˜๊ณผ native query๋ฅผ ์ด์šฉํ•˜์—ฌ ํ•ด๊ฒฐํ•˜๋ ค ํ•˜์˜€์œผ๋‚˜ native query์™€ ํŽ˜์ด์ง•์„ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๊ธฐ๊ฐ€ ๊นŒ๋‹ค๋กœ์› ์Œ.

ํ•ด๊ฒฐ

countQuery๋ฅผ ์ด์šฉํ•˜์—ฌ query๋ฌธ์„ ์ž‘์„ฑํ•˜๊ณ , @Param ์–ด๋…ธํ…Œ์ด์…˜๊ณผ ํ•จ๊ป˜ ๋ฉ”์„œ๋“œ๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ํ•ด๊ฒฐ.

@Query(countQuery = "select count(*) from room r where (r.price between :minPrice and :maxPrice) and r.type = :type", nativeQuery = true)
Page<Room> findByPriceBetweenAndType(@Param("minPrice") int minPrice,
                                     @Param("maxPrice") int maxPrice,
                                     @Param("type") String type,
                                     Pageable pageable);
๋ฐ์ดํ„ฐ ์ „๋‹ฌ ์‹œ ํƒ€์ž… ์ง€์ •

๋ฌธ์ œ

String type์œผ๋กœ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ๋ฐ›์•„์˜ฌ ๋•Œ ๊ณต๋ฐฑ๋ฌธ์ž๊ฐ€ ์„ž์ด๋Š” ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒ. ํฌ์ŠคํŠธ๋งจ์—์„œ body - text๋กœ ๋†“๊ณ  {}์—†์ด ๊ทธ๋ƒฅ String ์ผ์–ด์•ผ ํ•จ. ์—ฌํƒœ๊นŒ์ง€๋Š” ์™œ ์ด๋Ÿฐ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒ ์•ˆ ํ–ˆ๋Š”์ง€ ์ƒ๊ฐํ•ด๋ณด๋‹ˆ ์—ฌํƒœ๊นŒ์ง€๋Š” dto๋กœ ๋ฐ›์•˜์—ˆ์Œ.

ํ•ด๊ฒฐ

์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ์ œ๋„ค๋ฆญ์Šค๋ฅผ ์‚ฌ์šฉํ•ด์„œ ํ•ด๊ฒฐํ–ˆ๋‹ค๊ฐ€, ํ†ต์ผ์„ฑ์œ„ํ•ด dto๋กœ responsebody๋กœ jsonํ˜•์‹์œผ๋กœ ๋ฐ›์•„์˜ค๋Š” ๋ฐฉ์‹์œผ๋กœ ๋ฐ”๊ฟˆ.

if-else์™€ try-catch

๋ฌธ์ œ

if-else๋ฌธ ๋‚ด๋ถ€ throw โ†’ ํŠน์ • ์กฐ๊ฑด์—์„œ๋งŒ ๋˜์ ธ์ง€๋Š” exception.

ํ•ด๊ฒฐ

try-catch๋ฌธ์œผ๋กœ ๋ณ€๊ฒฝ. catch์‹œ try์ฝ”๋“œ์—์„œ ์–ด๋–ค exception์ด ํ„ฐ์งˆ์ง€ ์•Œ๊ณ ์žˆ์œผ๋‹ˆ ๊ทธ๊ฒŒ ๋งž๊ฒŒ ์ž‘์„ฑํ•ด์ฃผ๋ฉด ๋จ.
? โ†’ ์ง€๊ธˆ์€ IOException์ด๋‚˜ ์ง์ ‘๋งŒ๋“  CustomException ๋‘๊ฐœ๋กœ catch๋ฅผ ํ•˜๊ณ ์žˆ์ง€๋งŒ ์—๋Ÿฌ๊ฐ€ ๋”์šฑ ๋งŽ์•„์ง€๋ฉด ๊ณ„์† ํ•ด์„œ catch๋ฌธ์„ ์ถ”๊ฐ€ํ•ด์„œ ํ•ด๋‹นํ•˜๋Š” ์—๋Ÿฌ๋ฅผ ์žก์•„์•ผํ•˜๋‚˜?
! โ†’ ์ž๋ฐ”๊ฐ€ ๊ธฐ๋ณธ ์ œ๊ณตํ•˜๋Š” Exception์ค‘ ํ•ด๋‹น exception์ด ์ƒ์†๋ฐ›๋Š” ์ƒ์œ„ ์ƒ์œ„ ์ƒ์œ„ exception์ด ์กด์žฌํ•จ. ์ดˆ๊ธฐ์—๋Š” ์ ์ ˆํ•œ exception์„ catch๋ฌธ์œผ๋กœ ์‚ฌ์šฉํ•˜์—ฌ ์žก์œผ๋ฉด ๋„“์€ ๋ฒ”์œ„์˜ catch๋กœ ํ•ธ๋“ค๋ง ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ ์ด ๋ฒ”์œ„๋Š” ์ตœ์ ํ™” ๊ณผ์ •์—์„œ ์ค„์—ฌ๋‚˜๊ฐ€๋ฉด ๋จ.


7. ๊นƒํ—ˆ๋ธŒ


8. ํŒ€์›์ •๋ณด

์ด๋ฆ„ ์ฃผํŠน๊ธฐ ๊นƒํ—ˆ๋ธŒ ์ฃผ์†Œ
ํ™ฉ๋ฏธ๊ฒฝ BE https://github.com/beautifulseoul
์•ˆ์€์†” BE https://github.com/eunsol-an
์ฐจ์ด์ง„ BE https://github.com/leejincha/
๊น€์žฌ์˜ BE https://github.com/code0613
์ด๋ฏผ๊ทœ FE https://github.com/GosuEE
๋…ธํ˜„์Šน FE https://github.com/rlaqndlf1

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages