# samarth8765/reactify architecture

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

- Interactive diagram: https://gitdiagram.com/samarth8765/reactify
- Repository: https://github.com/samarth8765/reactify

## Overview

##### Project Type and Purpose
- Reactify is a container-driven build-and-deploy service.
- It exposes a REST API (api-server) that accepts GitHub URLs, spins up isolated build containers on AWS ECS, stores artifacts in EFS, uploads to S3, and serves static sites via a reverse-proxy.

##### Main Components
a. Client (Browser/CLI)
b. API Server (api-server)
c. AWS ECS Cluster
- Build Task (build-server Dockerfile.builder)
- Deploy/Upload Task (build-server Dockerfile.deploy)
d. Shared Storage (Amazon EFS)
e. Artifact Store (Amazon S3)
f. Reverse-Proxy Service (s3-reverse-proxy)
g. DNS/Route 53 (maps unique subdomains to reverse proxy)

##### Relationships and Interactions
1. Client → API Server: REST call with GitHub repo URL.
2. API Server → ECS: Uses AWS SDK/Task ARN to launch a “builder” container.
3. Builder Container:
- Clones repo, installs dependencies, runs build → writes output to EFS volume.
4. API Server → ECS: Launches a separate “deploy” container.
5. Deploy Container:
- Reads from EFS volume, uploads build artifacts to S3 under a unique prefix (e.g., a1/).
6. DNS/Route 53: Assigns a1.domain.com pointing to the reverse-proxy service.
7. Client → a1.domain.com: Hits reverse-proxy → fetches static files from S3 → serves them.

##### Architectural Patterns & Principles
- Microservices: Three Node.js services (api-server, build-server, reverse-proxy).
- Containerization & Isolation: Build and deploy steps run in distinct Docker containers on ECS.
- Shared File System for artifacts (EFS) to decouple build and upload phases.
- Security by Isolation: Build container has no direct AWS credentials for S3.
- Event-driven Orchestration: API server orchestrates ECS tasks via AWS SDK.

##### Technologies, Frameworks, Libraries
- Node.js / Express (api-server & reverse-proxy)
- Docker (build-server images)
- AWS ECS (Task ARNs, Cluster ARNs)
- Amazon EFS (volume mounts)
- Amazon S3 (static hosting)
- DNS / Route 53 for subdomains

## Diagram (Mermaid)

```mermaid
flowchart TB
    Client["Client (Browser/CLI)"]:::external
    APIServer["api-server (Node.js/Express)"]:::api
    Route53["DNS (Route 53)"]:::dns
    ReverseProxy["Reverse-Proxy (s3-reverse-proxy)"]:::api
    EFS[(Amazon EFS)]:::storage
    S3[(Amazon S3)]:::storage

    subgraph "AWS ECS Cluster" 
        BuilderTask["Builder Task<br/><i>Dockerfile.builder</i>"]:::ecsTask
        UploaderTask["Uploader Task<br/><i>Dockerfile.deploy</i>"]:::ecsTask
    end

    Client -->|"1. REST call with GitHub URL"| APIServer
    APIServer -->|"2. Launch Builder Task"| BuilderTask
    BuilderTask -->|"3. Write build output"| EFS
    APIServer -->|"4. Launch Uploader Task"| UploaderTask
    UploaderTask -->|"5. Read build output"| EFS
    UploaderTask -->|"6. Upload artifacts"| S3
    Route53 -->|"a1.domain.com"| ReverseProxy
    Client -->|"7. Request static site"| Route53
    ReverseProxy -->|"Fetch static files"| S3

    click APIServer "https://github.com/samarth8765/reactify/blob/master/api-server/index.js"
    click BuilderTask "https://github.com/samarth8765/reactify/blob/master/build-server/Dockerfile.builder"
    click UploaderTask "https://github.com/samarth8765/reactify/blob/master/build-server/Dockerfile.deploy"
    click ReverseProxy "https://github.com/samarth8765/reactify/blob/master/reverse-proxy/index.js"

    classDef api fill:#c6dbf7,stroke:#2171b5
    classDef ecsTask fill:#c6f5c6,stroke:#238b45
    classDef storage fill:#f5e384,stroke:#b58900
    classDef dns fill:#f4c2c2,stroke:#cb410b
    classDef external fill:#dddddd,stroke:#888888
```
