[maxxlog] 요구 사항 분석과 스키마 도출

maxxyoung·2024년 3월 21일
0

maxxlog

목록 보기
3/9

스터디 인증 애플리케이션

컨셉

회원가입시 포인트를 제공받는다. 사용자는 포인트를 사용해서 스터디를 참여할 수 있고 만약 인증 참여하지 않는다면 포인트를 돌려받지 못하고 스터디 방에서 탈퇴 당한다. 스터디는 매달 1일에 시작하고 말일에 끝난다. 말일에 살아남은 회원들은 남은 포인트의 1/N을 다시 돌려받는다. 이렇게 매달 반복한다.

뷰 & 요구사항 분석

인증, 인가

  • 회원가입 API
  • 로그인 API

내가 참여한 스터디방

  • 내가 참여한 스터디방 목록 조회 API

내가 참여한 스터디방 상세

  • 스터디 상세 API(스터디방 상세 정보, 쌓인 포인트, 참여 인원)
  • 스터디원 오늘 인증 현황 API*
  • 스터디원 가입, 탈퇴 현황 API*
  • 스터디원 신고하기 API*

스터디 인증하기

  • 스터디 인증 API

스터디방 목록

  • 스터디방 생성 API
  • 스터디방 목록 API(카테고리, 스터디방 제목 검색, 스터디방 최신 순으로 정렬, 커서 방식)

참여할 수 있는 스터디방 상세

  • 스터디방 상세 API
  • 스터디 가입 API

나의 인증 현황

  • 달 기준 인증 기록 API*

백오피스

스티디원 강제 스터디방 탈퇴

  • 강제 탈퇴 스터디방*

규칙 도출

스터디 참여 규칙

  • 스터디방 목록은 모두가 볼 수 있으며, 참여 시점에 제한 혹은 승인한다.
  • 사용자는 처음 회원 가입할 때 포인트를 받는다.
  • 방장은 스터디 방을 만들 때 스터디 스터디 타이틀, 내용소개, 카테고리, 불참 횟수 제한, 인원을 할 수 있다.
  • 방의 인원은 최대 10명까지 제한한다.
  • 스터디원은 스터디 방을 가입할 때, 달 마다 포인트가 차감된다.
  • 스터디 참여 인원은 달마다 스터디를 진행할 건지 선택할 수 있다.
  • 스터디를 인증할 경우 포인트를 받는다.
  • 달 마다 스터디에서 살아남은 최종 인원은 남은 포인트 1/N하여 되돌려 받는다.
  • 부적절한 사진은 신고가 가능하며, 운영진이 확인 후 해당 인원을 회원 탈퇴시킨다.
  • 탈퇴는 오직 스터디 불참 혹은 운영진만이 시킬 수 있다.
  • 하루 한 번 배치를 통해 스터디 불참 횟수를 카운트하여 스터디방 탈퇴 진행한다.
  • 스터디 불참으로 탈퇴당한 스터디원은 똑같은 스터디방은 다시 가입할 수 없다.
  • 스터디방은 한 명 이상일 경우 활성화 되며 아무도 남지 않는다면 해당 방의 포인트는 사라진다.
  • 한 달 한 번 배치를 통해 스터디방은 사라진다.
  • 스터디는 중간에 참여할 수 없으며 오직 매달 1일만 참여할 수 있다.
  • 인증 파일은 한 달만 보관하며 그 이후는 물리적으로 삭제된다.

포인트 규칙

  • 회원가입 시 1000 point를 받는다
  • 스터디를 참여할 때 100 point를 걸어야한다.
  • 인증을 할 때 10 point를 받는다.

Batch

  • 한 달 한 번 스터디에서 살아남은 최종 인원은 남은 포인트 1/N하여 되돌려 받는다.
  • 하루 한 번 배치를 통해 스터디 불참 횟수를 카운트하여 스터디방 탈퇴 진행한다.
  • 한 달 한 번 배치를 통해 스터디방은 사라진다.

자원

  • 유저
  • 스터디방
  • 포인트
  • 신고
  • 스터디방 탈퇴
  • 인증
  • 카테고리

스키마

테이블 간 관계 정리

  • 사용자
  • 스터디방
  • 유저스터디(사용자 1 : 유저스터디 N, 유저스터디 N : 스터디 방 :1)
    유저와 스터디방은 N:M으로 매핑 테이블이 필요하다.
  • 스터디방 포인트(스터디방 포인트 1 : 스터디방 1)
  • 스터디방 포인트 로그(스터디방 포인트 로그 N : 스터디방 1)
  • 유저 포인트(유저 포인트 1 : 유저 1)
  • 유저 포인인트 로그(유저 포인트 로그 N : 유저 포인트 1)
  • 신고(신고 1 : 유저 1)
  • 스터디 인증(유저 1 : 스터디 인증 N, 스터디 인증 N : 스터디 방 1)
  • 카테고리

테이블 정의

    create table auth_file (
        id bigint generated by default as identity,
        file_name varchar(255),
        created_at timestamp(6) with time zone not null,
        updated_at timestamp(6) with time zone not null,
        primary key (id)
    )

    create table category (
        id bigint generated by default as identity,
        depth integer not null, 
        parent_id bigint,
        name varchar(255),
        created_at timestamp(6) with time zone not null,
        updated_at timestamp(6) with time zone not null,
        primary key (id)
    )

    create table report (
        id bigint generated by default as identity,
        user_id bigint unique,
        auth_file_id bigint ,
		created_at timestamp(6) with time zone not null,
        updated_at timestamp(6) with time zone not null,
        primary key (id)
    )

    create table study_authentication (
        id bigint generated by default as identity,
        user_id bigint unique,
        auth_file_id bigint unique,
        study_room_id bigint unique,
        created_at timestamp(6) with time zone not null,
        updated_at timestamp(6) with time zone not null,
        primary key (id)
    )

    create table study_room (
        id bigint generated by default as identity,
		category_id bigint unique,
        title varchar(255),
		explanation varchar(255),
        state varchar(255) check (state in ('ACTIVATED','DISABLED')),
        created_at timestamp(6) with time zone not null,
		updated_at timestamp(6) with time zone not null,
        primary key (id)
    )

    create table study_room_point (
        id bigint generated by default as identity,
		study_room_id bigint unique,
		point integer not null,
        created_at timestamp(6) with time zone not null,
		updated_at timestamp(6) with time zone not null,
        primary key (id)
    )

    create table study_room_point_log (
        id bigint generated by default as identity,
        user_id bigint unique,
		point integer not null,
        study_room_id bigint unique,
        point_action_type varchar,
        provider_type varchar,
        created_at timestamp(6) with time zone not null,
		updated_at timestamp(6) with time zone not null,
        primary key (id)
    )

    create table user (
        id bigint generated by default as identity,
        email varchar(255),
        name varchar(255),
        password varchar(255),
        state varchar(255) check (state in ('ACTIVATED','DISABLED','BLOCKED')),
        updated_at timestamp(6) with time zone not null,
		created_at timestamp(6) with time zone not null,
        primary key (id)
    )

    create table user_point (
        id bigint generated by default as identity,
        user_id bigint unique,
		point integer not null,
        created_at timestamp(6) with time zone not null,
		updated_at timestamp(6) with time zone not null,
        primary key (id)
    )

    create table user_point_log (
        id bigint generated by default as identity,
        user_id bigint unique,		
        point integer not null,
        point_action_type varchar(255),
        created_at timestamp(6) with time zone not null,
        updated_at timestamp(6) with time zone not null,
        primary key (id)
    )
    
    create table user_study_room (
        id bigint generated by default as identity,
        user_id bigint unique,
        state varchar(255) check (state in ('ACTIVATED','DISABLED','BLOCKED')),
        study_room_id bigint unique,
		created_at timestamp(6) with time zone not null,
		updated_at timestamp(6) with time zone not null,
        primary key (id)
    )

인덱스 설계

스터디룸

CREATE INDEX idx_id_title_category ON users (id, title, category);

도메인과 도메인 규칙

  • User
    • 유저 상태: ACTIVATED, DISABLED, BLOCKED
  • StudyRoom
    • 방의 인원은 최대 10명까지 제한한다.
    • 스터디는 중간에 참여할 수 없으며 오직 매달 1일만 참여할 수 있다.
    • 스터디방 상태: ACTIVATED, DISABLED
  • UserStudyRoom
    • 참여인원 상태: ACTIVATED, DISABLED, BLOCKED
  • StudyRoomPoint
    • 달 마다 스터디에서 살아남은 최종 인원은 남은 포인트 1/N하여 되돌려 받는다.
    • 포인트 차감
    • 포인트 증가
  • StudyRoomPointLog
  • UserPoint
    • 사용자는 처음 회원 가입할 때 포인트를 받는다.
    • 포인트 증가
    • 포인트 차감
  • UserPointLog
  • Report
  • StudyAuthentication
  • AuthFile
  • Category

서버 구성도

profile
오직 나만을 위한 글. 틀린 부분 말씀해 주시면 감사드립니다.

0개의 댓글