# baejw0111/re-view architecture

> Architecture diagram of the GitHub repository baejw0111/re-view, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/baejw0111/re-view
- Repository: https://github.com/baejw0111/re-view

## Overview

##### Project Type and Purpose
- This is a full-stack, serverless review-community web application named “Re|view.”
- Frontend: A React/TypeScript SPA built with Vite, Redux Toolkit & React Query, styled with TailwindCSS, deployed on Vercel.
- Backend: An Express API packaged via Serverless Framework into AWS Lambda functions behind API Gateway, using MongoDB (Mongoose) for data persistence and AWS S3 for image storage.
- External integrations: OAuth providers (Kakao, Google, Naver) for social login; Discord & Puuush webhooks for notifications; CI/CD via GitHub Actions.

##### File-Structure Highlights
- Top-level “front” and “back” directories isolate client and server code.
- “back/controllers” organizes MVC-style handler modules (Auth, Review, Comment, Like, Notification, Tag, User, SocialAuth).
- “serverless.yml” defines AWS Lambda functions, API Gateway routes, IAM roles, and S3 bucket permissions.
- “back/utils” holds shared logic: ID generation, generic model wrapper, upload helper (S3), and controller utilities.
- “front/src/api” encapsulates HTTP calls to each backend resource.
- “front/src/features” and “front/src/widgets” hold UI components and feature modules (forms, lists, interactions).

- Use a layered view:
a. Clients Layer (User & Browser)
b. Presentation Layer (React SPA served by Vercel CDN)
c. API Layer (AWS API Gateway → Lambda)
d. Application Layer (Express controllers inside Lambda)
e. Data Layer (MongoDB Atlas & AWS S3)
f. External Services (OAuth providers, Webhooks)
g. CI/CD Pipeline (GitHub Actions → Vercel & AWS)

##### Main Components & Interactions
- User → Browser: Interacts via SPA UI.
- Browser → Vercel CDN: GET static assets (HTML, JS, CSS).
- Browser → API Gateway (HTTPS): RESTful calls (/auth, /reviews, /comments, /like, /notification, /tag, /user).
- API Gateway → AWS Lambda (Express): Invokes controllers to handle requests.
- Auth controllers manage JWT or cookie issuance.
- SocialAuth modules handle OAuth redirects & token exchange with Kakao/Google/Naver.
- Review/Comment/Like controllers read/write to MongoDB.
- Upload controller generates pre-signed S3 URLs and handles image storage.
- Notification controller pushes events to Discord/Puuush webhooks.
- Lambda → MongoDB Atlas: CRUD operations via Mongoose.
- Lambda → AWS S3: Store and retrieve webp images.
- Lambda → External OAuth Providers: Exchange auth codes for tokens.
- CI/CD: GitHub Actions workflows triggered on push → build & deploy “front” to Vercel; build & deploy “back” to AWS via Serverless Framework.

##### Architectural Patterns & Design Principles
- SPA / API separation.
- Serverless microservices (one Lambda per route or logical group).
- MVC-style controllers inside Lambdas.
- Stateless functions with external persistent storage.
- OAuth 2.0 social login flows.
- Asynchronous notifications via webhooks.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients Layer
    subgraph "Clients Layer"
        User["User"]:::external
        Browser["Browser"]:::external
        User --> Browser
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        CDN["Vercel CDN"]:::aws
        SPA["React SPA"]:::frontend
        VITE["Vite Config"]:::frontend
        TAILWIND["Tailwind Config"]:::frontend
        POSTCSS["PostCSS Config"]:::frontend
        MAIN["Entry Point (main.tsx)"]:::frontend
        HTML["index.html"]:::frontend
        Browser -->|Fetch assets|CDN
        CDN --> SPA
    end

    %% State & API Clients
    subgraph "Frontend State & API"
        Store["Redux Store"]:::frontend
        IsSignedIn["isSignedInSlice"]:::frontend
        NotificationOpen["notificationOpenSlice"]:::frontend
        SearchDialogOpen["searchDialogOpenSlice"]:::frontend
        UserInfo["userInfoSlice"]:::frontend
        ApiDir["API Clients"]:::frontend
        Util["util.ts"]:::frontend
        AuthAPI["auth.ts"]:::frontend
        ReviewAPI["review.ts"]:::frontend
        CommentAPI["comment.ts"]:::frontend
        LikeAPI["like.ts"]:::frontend
        NotificationAPI["notification.ts"]:::frontend
        TagAPI["tag.ts"]:::frontend
        UserAPI["user.ts"]:::frontend

        SPA --> Store
        SPA --> ApiDir
        Store --> IsSignedIn
        Store --> NotificationOpen
        Store --> SearchDialogOpen
        Store --> UserInfo
        ApiDir --> Util
        ApiDir --> AuthAPI
        ApiDir --> ReviewAPI
        ApiDir --> CommentAPI
        ApiDir --> LikeAPI
        ApiDir --> NotificationAPI
        ApiDir --> TagAPI
        ApiDir --> UserAPI
    end

    %% API Layer
    subgraph "API Layer"
        APIGW["API Gateway"]:::aws
        SPA -->|HTTPS REST calls|APIGW
    end

    %% Application Layer
    subgraph "Application Layer"
        Lambda["AWS Lambda (Express)"]:::aws
        APIGW --> Lambda
        subgraph "Controllers"
            AuthC["Auth Controller"]:::backend
            SocialC["SocialAuth Controllers"]:::backend
            ReviewC["Review Controller"]:::backend
            CommentC["Comment Controller"]:::backend
            LikeC["Like Controller"]:::backend
            NotificationC["Notification Controller"]:::backend
            TagC["Tag Controller"]:::backend
            UserC["User Controller"]:::backend
        end
        subgraph "Shared Utilities"
            IdGen["IdGenerator"]:::backend
            Model["Model Wrapper"]:::backend
            UploadU["S3 Upload Helper"]:::backend
            CtrlUtils["Controller Utilities"]:::backend
        end
        Lambda --> AuthC
        Lambda --> SocialC
        Lambda --> ReviewC
        Lambda --> CommentC
        Lambda --> LikeC
        Lambda --> NotificationC
        Lambda --> TagC
        Lambda --> UserC
        AuthC --> Model
        AuthC --> IdGen
        SocialC --> IdGen
        ReviewC --> Model
        ReviewC --> IdGen
        CommentC --> Model
        CommentC --> IdGen
        LikeC --> Model
        LikeC --> IdGen
        NotificationC --> Model
        NotificationC --> IdGen
        NotificationC --> UploadU
        TagC --> Model
        TagC --> IdGen
        UserC --> Model
        UserC --> IdGen
    end

    %% Data Layer
    subgraph "Data Layer"
        MongoDB["MongoDB Atlas"]:::storage
        S3["AWS S3 Bucket"]:::aws
    end
    ReviewC --> MongoDB
    CommentC --> MongoDB
    LikeC --> MongoDB
    TagC --> MongoDB
    UserC --> MongoDB
    AuthC --> MongoDB
    UploadU --> S3

    %% External Services
    subgraph "External Services"
        OAuth["OAuth Providers (Kakao, Google, Naver)"]:::external
        Webhooks["Discord & Puuush Webhooks"]:::external
    end
    SocialC -->|OAuth flow|OAuth
    NotificationC -.->|Asynchronous|Webhooks

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        GH["GitHub Actions"]:::external
        Vercel["Vercel"]:::aws
        AWSDeploy["AWS (Serverless)"]:::aws
        GH -->|Build & Deploy Front|Vercel
        GH -->|Build & Deploy Back|AWSDeploy
    end

    %% Click Events
    click SPA "https://github.com/baejw0111/re-view/tree/main/front/src"
    click VITE "https://github.com/baejw0111/re-view/blob/main/front/vite.config.ts"
    click TAILWIND "https://github.com/baejw0111/re-view/blob/main/front/tailwind.config.js"
    click POSTCSS "https://github.com/baejw0111/re-view/blob/main/front/postcss.config.js"
    click MAIN "https://github.com/baejw0111/re-view/blob/main/front/src/main.tsx"
    click HTML "https://github.com/baejw0111/re-view/blob/main/front/index.html"
    click Store "https://github.com/baejw0111/re-view/tree/main/front/src/state/store"
    click IsSignedIn "https://github.com/baejw0111/re-view/blob/main/front/src/state/store/isSignedInSlice.ts"
    click NotificationOpen "https://github.com/baejw0111/re-view/blob/main/front/src/state/store/notificationOpenSlice.ts"
    click SearchDialogOpen "https://github.com/baejw0111/re-view/blob/main/front/src/state/store/searchDialogOpenSlice.ts"
    click UserInfo "https://github.com/baejw0111/re-view/blob/main/front/src/state/store/userInfoSlice.ts"
    click ApiDir "https://github.com/baejw0111/re-view/tree/main/front/src/api"
    click Util "https://github.com/baejw0111/re-view/blob/main/front/src/api/util.ts"
    click AuthAPI "https://github.com/baejw0111/re-view/blob/main/front/src/api/auth.ts"
    click ReviewAPI "https://github.com/baejw0111/re-view/blob/main/front/src/api/review.ts"
    click CommentAPI "https://github.com/baejw0111/re-view/blob/main/front/src/api/comment.ts"
    click LikeAPI "https://github.com/baejw0111/re-view/blob/main/front/src/api/like.ts"
    click NotificationAPI "https://github.com/baejw0111/re-view/blob/main/front/src/api/notification.ts"
    click TagAPI "https://github.com/baejw0111/re-view/blob/main/front/src/api/tag.ts"
    click UserAPI "https://github.com/baejw0111/re-view/blob/main/front/src/api/user.ts"
    click Server "https://github.com/baejw0111/re-view/blob/main/back/server.js"
    click Serverless "https://github.com/baejw0111/re-view/blob/main/back/serverless.yml"
    click AuthC "https://github.com/baejw0111/re-view/blob/main/back/controllers/Auth.js"
    click ReviewC "https://github.com/baejw0111/re-view/blob/main/back/controllers/Review.js"
    click CommentC "https://github.com/baejw0111/re-view/blob/main/back/controllers/Comment.js"
    click LikeC "https://github.com/baejw0111/re-view/blob/main/back/controllers/Like.js"
    click NotificationC "https://github.com/baejw0111/re-view/blob/main/back/controllers/Notification.js"
    click TagC "https://github.com/baejw0111/re-view/blob/main/back/controllers/Tag.js"
    click UserC "https://github.com/baejw0111/re-view/blob/main/back/controllers/User.js"
    click SocialC "https://github.com/baejw0111/re-view/blob/main/back/controllers/SocialAuth/index.js"
    click GoogleAuth "https://github.com/baejw0111/re-view/blob/main/back/controllers/SocialAuth/GoogleAuth.js"
    click KakaoAuth "https://github.com/baejw0111/re-view/blob/main/back/controllers/SocialAuth/KakaoAuth.js"
    click NaverAuth "https://github.com/baejw0111/re-view/blob/main/back/controllers/SocialAuth/NaverAuth.js"
    click IdGen "https://github.com/baejw0111/re-view/blob/main/back/utils/IdGenerator.js"
    click Model "https://github.com/baejw0111/re-view/blob/main/back/utils/Model.js"
    click UploadU "https://github.com/baejw0111/re-view/blob/main/back/utils/Upload.js"
    click CtrlUtils "https://github.com/baejw0111/re-view/blob/main/back/utils/ControllerUtils.js"
    click FrontDeploy "https://github.com/baejw0111/re-view/blob/main/.github/workflows/frontend-deploy.yml"
    click BackDeploy "https://github.com/baejw0111/re-view/blob/main/.github/workflows/backend-deploy.yml"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#4da3ff;
    classDef aws fill:#ffe0b2,stroke:#ff9800;
    classDef storage fill:#dcedc8,stroke:#8bc34a;
    classDef external fill:#e0e0e0,stroke:#9e9e9e;
    classDef backend fill:#fddede,stroke:#e57373;
```
