# omerteomim/essay-inspector architecture

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

- Interactive diagram: https://gitdiagram.com/omerteomim/essay-inspector
- Repository: https://github.com/omerteomim/essay-inspector

## Overview

##### Project Type and Purpose
- This is a serverless, full‐stack web application (“Essay Inspector”) that analyzes and scores essays.
- The front end is a single static HTML file (index.html) and the back end is an AWS Lambda function (lambda_function.py).
- Infrastructure is provisioned via Terraform (main.tf, variables.tf) and deployed automatically with a GitHub Actions workflow (.github/workflows/deploy.yaml).

##### File Structure
- Top level:
- index.html – static UI (web form, results display)
- lambda_function.py – serverless compute, houses NLP/ML scoring logic
- main.tf & variables.tf – Terraform modules for AWS resources (Lambda, IAM, API Gateway, S3, CloudFront, etc.)
- .github/workflows/deploy.yaml – CI/CD pipeline deploying Terraform and application
- No separate “frontend” or “backend” directories—everything lives at root, indicating a minimal, serverless architecture.

##### Extract Additional Insights from README
- Core features: automated scoring, grammar/style analysis, structure evaluation, vocabulary assessment, detailed feedback, batch processing.
- Under the hood: natural language processing and machine learning algorithms all executed in the Lambda function.

##### Main Components
a. Frontend (browser)
b. CDN & Static Hosting (Amazon CloudFront + S3)
c. API Layer (Amazon API Gateway)
d. Compute (AWS Lambda with NLP/ML libraries)
e. Infrastructure as Code (Terraform)
f. CI/CD Pipeline (GitHub Actions)

##### Relationships and Data Flows
1. User opens the browser → requests index.html from CloudFront → CloudFront fetches from S3
2. index.html (JavaScript) sends HTTP(S) POST to API Gateway endpoint
3. API Gateway invokes the Lambda function
4. Lambda executes NLP/ML scoring logic, returns JSON report
5. API Gateway returns the response to the browser, which renders the feedback report
6. (Batch mode: same flow, but JavaScript payload contains multiple essays)
7. CI/CD: GitHub Actions triggers on push → runs Terraform apply → updates S3, API Gateway, Lambda, etc.

##### Architectural Patterns and Design Principles
- Serverless microservices: each unit of functionality is a discrete Lambda function
- Infrastructure as Code: Terraform modules define and version your entire stack
- Separation of concerns: static UI vs. compute layer vs. CI/CD
- Event-driven: HTTP events trigger compute
- High scalability and pay-per-use: Lambda and CDN scale automatically

##### Technologies and Frameworks to Highlight
- AWS Lambda (compute)
- Amazon API Gateway (REST API)
- Amazon S3 & CloudFront (static hosting + CDN)
- Terraform (IaC)
- GitHub Actions (CI/CD)
- Python, plus NLP/ML libraries in lambda_function.py

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User and Frontend
    U["User Browser"]:::frontend

    %% AWS Cloud Boundary
    subgraph "AWS Cloud"
        subgraph "Static Hosting & CDN"
            CF["CloudFront"]:::network
            S3["S3 Bucket"]:::storage
            Index["index.html"]:::frontend
        end
        subgraph "API & Compute"
            APIGW["API Gateway"]:::network
            Lambda["Lambda: lambda_function.py"]:::compute
        end
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        GH["GitHub Repo"]:::cicd
        GA["GitHub Actions: deploy.yaml"]:::cicd
    end

    %% Terraform IaC
    subgraph "Terraform IaC"
        MainTF["main.tf"]:::iac
        VarsTF["variables.tf"]:::iac
    end

    %% Data Flows - Static Content
    U -->|"GET index.html"| CF
    CF -->|"Fetch file"| Index
    Index -->|"Return HTML"| CF
    CF -->|"Serves index.html"| U

    %% Data Flows - API Requests
    U -->|"POST /analyze"| APIGW
    APIGW -->|"Invoke lambda_function"| Lambda
    Lambda -->|"Return JSON report"| APIGW
    APIGW -->|"Returns response"| U

    %% CI/CD and IaC Flows
    GH --> GA
    GA --> MainTF
    GA --> VarsTF
    MainTF -.-> CF
    MainTF -.-> S3
    MainTF -.-> APIGW
    MainTF -.-> Lambda
    VarsTF -.-> CF
    VarsTF -.-> S3
    VarsTF -.-> APIGW
    VarsTF -.-> Lambda

    %% Click Events
    click Index "https://github.com/omerteomim/essay-inspector/blob/main/index.html"
    click Lambda "https://github.com/omerteomim/essay-inspector/blob/main/lambda_function.py"
    click MainTF "https://github.com/omerteomim/essay-inspector/blob/main/main.tf"
    click VarsTF "https://github.com/omerteomim/essay-inspector/blob/main/variables.tf"
    click GA "https://github.com/omerteomim/essay-inspector/blob/main/.github/workflows/deploy.yaml"

    %% Styles
    classDef frontend fill:#E8F4FC,stroke:#027BCE,color:#027BCE
    classDef compute fill:#F3E5F5,stroke:#6A1B9A,color:#6A1B9A
    classDef storage fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32
    classDef network fill:#FFF3E0,stroke:#FB8C00,color:#FB8C00
    classDef cicd fill:#ECEFF1,stroke:#546E7A,color:#546E7A
    classDef iac fill:#FFFDE7,stroke:#F9A825,color:#F9A825
```
