# arthurlopesmagalhaes/foodiary-api architecture

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

- Interactive diagram: https://gitdiagram.com/arthurlopesmagalhaes/foodiary-api
- Repository: https://github.com/arthurlopesmagalhaes/foodiary-api

## Overview

##### Project type and purpose
- This is a Serverless HTTP API built in Node.js/TypeScript, deployed to AWS Lambda behind API Gateway via the Serverless Framework.
- The README confirms it exposes a single “hello” endpoint, has no database, and uses Serverless for deployment, local emulation, and AWS integration.

##### File structure
- Top-level files: serverless.yml (deployment), esbuild.config.mjs (build), eslint.config.mjs, tsconfig.json.
- src/main: entrypoints and adapters for AWS Lambda (lambdaHttpAdapter, body parsing, error formatting), plus the “hello” function definition (hello.ts).
- src/application: Clean-Architecture application layer (Controller interface, HelloController, HelloUseCase, request/response schemas, HTTP errors).
- src/kernel: Dependency Injection container (Registry, container), decorators (@Injectable, @Schema).
- src/shared: cross-cutting types (constructor, etc.).
- No persistence folder—stateless function.

##### README for additional insights
- Confirms one HTTP GET endpoint, default public access, local dev with serverless dev, no DB.
- Mentions AWS Lambda + API Gateway V2, encourages adding authorizers for production.

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Client
    Client["Client (Browser/Curl/Mobile)"]:::external

    %% AWS Infrastructure
    subgraph "AWS Infrastructure"
        direction TB
        APIGW["API Gateway (HTTP API)"]:::aws
        Lambda["Lambda Function: hello"]:::aws
    end

    %% Configuration Files
    subgraph "Configuration"
        direction TB
        ServerlessYML["serverless.yml"]:::config
        ESBUILD["esbuild.config.mjs"]:::config
        TSCONFIG["tsconfig.json"]:::config
        ESLINT["eslint.config.mjs"]:::config
        PKG["package.json"]:::config
        GITIGNORE[".gitignore"]:::config
        EDITOR[".editorconfig"]:::config
        README["README.md"]:::config
    end

    %% Infrastructure / Adapters
    subgraph "Infrastructure / Adapters"
        direction TB
        HTTP_ADAPTER["Lambda HTTP Adapter"]:::adapter
        BODY_PARSER["Body Parser (lambdaBodyParser)"]:::adapter
        ERROR_RESPONSE["Error Formatter (lambdaErrorResponse)"]:::adapter
    end

    %% Kernel / DI Container
    subgraph "Kernel / DI Container"
        direction TB
        REGISTRY["Registry"]:::kernel
        CONTAINER["Container"]:::kernel
        INJECT_DEC["@Injectable Decorator"]:::kernel
        SCHEMA_DEC["@Schema Decorator"]:::kernel
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        CONT_CONTRACT["Controller Interface"]:::app
        HELLO_CTRL["HelloController"]:::app
        HELLO_USE["HelloUseCase"]:::app
        SCHEMA["helloSchema"]:::app
        HTTP_ERROR["HttpError Class"]:::app
        BAD_REQ["BadRequest Error"]:::app
        ERR_CODE["Error Codes"]:::app
    end

    %% Shared Types
    SHARED["Constructor Type"]:::shared

    %% Flow Connections
    Client --> APIGW
    ServerlessYML --> APIGW
    ServerlessYML --> Lambda
    APIGW --> Lambda
    Lambda --> HTTP_ADAPTER
    HTTP_ADAPTER --> BODY_PARSER
    HTTP_ADAPTER --> ERROR_RESPONSE
    HTTP_ADAPTER --> CONTAINER
    CONTAINER --> REGISTRY
    CONTAINER --> INJECT_DEC
    CONTAINER --> SCHEMA_DEC
    CONTAINER -.-> CONT_CONTRACT
    CONT_CONTRACT --> HELLO_CTRL
    HELLO_CTRL --> HELLO_USE
    HELLO_USE --> ERR_CODE
    HELLO_CTRL --> SCHEMA
    HELLO_CTRL --> HTTP_ERROR
    HTTP_ERROR --> BAD_REQ
    HELLO_CTRL --> SHARED
    HELLO_USE --> HELLO_CTRL
    HELLO_CTRL --> HTTP_ADAPTER
    HTTP_ADAPTER --> APIGW
    APIGW --> Client

    %% Click Events
    click ServerlessYML "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/serverless.yml"
    click ESBUILD "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/esbuild.config.mjs"
    click TSCONFIG "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/tsconfig.json"
    click Lambda "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/main/functions/hello.ts"
    click HTTP_ADAPTER "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/main/adapters/lambdaHttpAdapter.ts"
    click BODY_PARSER "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/main/utils/lambdaBodyParser.ts"
    click ERROR_RESPONSE "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/main/utils/lambdaErrorResponse.ts"
    click CONT_CONTRACT "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/application/contracts/Controller.ts"
    click HELLO_CTRL "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/application/controllers/HelloController.ts"
    click HELLO_USE "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/application/usecases/HelloUseCase.ts"
    click SCHEMA "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/application/schemas/helloSchema.ts"
    click HTTP_ERROR "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/application/errors/http/HttpError.ts"
    click BAD_REQ "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/application/errors/http/BadRequest.ts"
    click ERR_CODE "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/application/errors/errorCode.ts"
    click REGISTRY "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/kernel/di/Registry.ts"
    click CONTAINER "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/kernel/di/container.ts"
    click INJECT_DEC "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/kernel/decorators/Injectable.ts"
    click SCHEMA_DEC "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/kernel/decorators/Schema.ts"
    click SHARED "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/src/shared/types/constructor.ts"
    click ESLINT "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/eslint.config.mjs"
    click PKG "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/package.json"
    click GITIGNORE "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/.gitignore"
    click EDITOR "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/.editorconfig"
    click README "https://github.com/arthurlopesmagalhaes/foodiary-api/blob/master/README.md"

    %% Styles
    classDef aws fill:#CCE5FF,stroke:#000,stroke-width:1px;
    classDef adapter fill:#CCFFCC,stroke:#000,stroke-width:1px;
    classDef app fill:#FFD699,stroke:#000,stroke-width:1px;
    classDef kernel fill:#E0CCFF,stroke:#000,stroke-width:1px;
    classDef shared fill:#E0E0E0,stroke:#000,stroke-width:1px;
    classDef config fill:#F2F2F2,stroke:#000,stroke-width:1px;
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px;
```
