# git-baboo/easy-review architecture

> Architecture diagram of the GitHub repository git-baboo/easy-review, 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/git-baboo/easy-review
- Repository: https://github.com/git-baboo/easy-review

## Overview

##### Project type and purpose
- This is a Next.js-based full-stack (mostly frontend) application called “Easy Review” that helps beginner engineers write and post review comments on GitHub pull requests.
- It uses React/TypeScript for the UI, Recoil for state management, Next.js for routing and SSR, and integrates directly with the GitHub API and Firebase Authentication.

##### File structure
- Top-level files and directories:
- Dockerfile, docker-compose.yml, Makefile (deployment & containerization)
- next.config.js, tsconfig.json, package.json (build & config)
- public/ (static assets, favicons)
- src/pages/ (Next.js page-based routing)
- src/components/ (UI components)
- src/hooks/ (custom React hooks: useApi, useAuth)
- src/store/ (Recoil atoms/keys)
- src/utils/firebase.ts (Firebase Auth client)
- src/utils/markdown (custom markdown renderer themes)
- There is no monolithic backend code or database schema—data flows directly to external services.

##### README
- Confirms core features:
- Simplified UI for beginners
- Review template system
- Automatic posting of comments to GitHub via API
- No internal DB or custom backend—uses Firebase Auth and GitHub REST/GraphQL.

a. User’s Browser (Client)
- Renders Next.js pages and React components.
- Holds Recoil state, invokes useAuth and useApi hooks.
- Hosts static assets from public/.

b. Next.js Server (SSR/SSG & Hosting)
- Serves React pages at routes under src/pages/…
- Builds and bundles the app.
- May perform server-side fetches (if SSR is used) to GitHub API using stored tokens.

c. Firebase Authentication (External)
- Handles user sign-in (e.g., Google OAuth).
- Returns JWT/ID token to client for authorizing GitHub API requests (or session cookies).

d. GitHub API (External)
- REST or GraphQL endpoints for listing pull requests, posting review comments.
- Client (or Next.js server) sends authenticated requests here.

e. Container/Deployment Layer
- Docker image running Node/Next.js
- docker-compose for local dev or multi-container setup (e.g., local emulators)

##### Relationships and data flows
- The Browser → Next.js Server: Request pages; download JS bundle & CSS.
- Browser ↔ Firebase Auth: Login flow; receive auth token.
- Browser (or Next.js server) → GitHub API:
- GET PR lists, GET PR details.
- POST review comments via templates.
- Next.js Server → public/ (serves static assets)
- Docker orchestration wraps the Next.js service (and any local emulators if configured).

##### Architectural patterns & design principles
- Component-based UI (src/components)
- Page-based routing (src/pages)
- Global state via Recoil (src/store)
- Custom hooks for separation of concerns (useAuth, useApi)
- Theming via CSS and modular markdown theme components

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Browser" 
        direction TB
        UI["UI Components\n(Recoil, React, TypeScript)"]:::client
        Hooks["Custom Hooks\n(useApi, useAuth)"]:::client
        State["Global State\nRecoil Keys"]:::client
        Template["Review Templates & Markdown Rendering"]:::client
        Static["Static Assets\n(public/)"]:::client
    end

    subgraph "Next.js App (SSR/SSG & Routing)"
        direction TB
        Pages["Pages & Routing\n(src/pages/)"]:::internal
        Config["Config & Build\n(next.config.js, next-env.d.ts, package.json)"]:::internal
    end

    subgraph "External Services"
        direction TB
        Firebase[(Firebase Authentication)]:::external
        GitHub[(GitHub API)]:::external
    end

    subgraph "Container/Deployment Layer"
        direction TB
        Docker[/"Docker Container"/]:::infra
        Compose[/docker-compose.yml,\nMakefile/]:::infra
    end

    %% Connections
    UI -->|"HTTP GET/JS/CSS bundle"| Pages
    UI -->|"OAuth2 login"| Firebase
    UI -->|"REST/GraphQL calls"| GitHub
    Pages -->|"Serves static assets"| Static
    Docker -->|"Hosts Next.js App"| Pages
    Compose -->|"Orchestrates containers"| Docker

    %% Click Events
    click UI "https://github.com/git-baboo/easy-review/tree/develop/src/components/"
    click Hooks "https://github.com/git-baboo/easy-review/tree/develop/src/hooks/"
    click State "https://github.com/git-baboo/easy-review/blob/develop/src/store/RecoilKeys.ts"
    click State "https://github.com/git-baboo/easy-review/blob/develop/src/store/currentUserState.ts"
    click Template "https://github.com/git-baboo/easy-review/blob/develop/src/components/review/Template.tsx"
    click Template "https://github.com/git-baboo/easy-review/tree/develop/src/utils/markdown/"
    click Template "https://github.com/git-baboo/easy-review/blob/develop/src/utils/markdown/customTheme.ts"
    click Template "https://github.com/git-baboo/easy-review/tree/develop/src/utils/markdown/theme/"
    click Static "https://github.com/git-baboo/easy-review/tree/develop/public/"
    click Pages "https://github.com/git-baboo/easy-review/tree/develop/src/pages/"
    click Config "https://github.com/git-baboo/easy-review/blob/develop/next.config.js"
    click Config "https://github.com/git-baboo/easy-review/blob/develop/next-env.d.ts"
    click Config "https://github.com/git-baboo/easy-review/blob/develop/package.json"
    click Firebase "https://github.com/git-baboo/easy-review/blob/develop/src/utils/firebase.ts"
    click Firebase "https://github.com/git-baboo/easy-review/blob/develop/src/components/AuthProvider.tsx"
    click Firebase "https://github.com/git-baboo/easy-review/blob/develop/src/hoc/withAuth.tsx"
    click Firebase "https://github.com/git-baboo/easy-review/blob/develop/src/hoc/withoutAuth.tsx"
    click GitHub "https://github.com/git-baboo/easy-review/blob/develop/src/hooks/useApi.ts"
    click Docker "https://github.com/git-baboo/easy-review/tree/develop/Dockerfile"
    click Compose "https://github.com/git-baboo/easy-review/blob/develop/docker-compose.yml"
    click Compose "https://github.com/git-baboo/easy-review/tree/develop/Makefile"

    %% Styles
    classDef client fill:#D6EAF8,stroke:#217DBB
    classDef internal fill:#EBDEF0,stroke:#8E44AD
    classDef external fill:#D5F5E3,stroke:#27AE60
    classDef infra fill:#F2F3F4,stroke:#95A5A6
```
