# danielfernandes202/patcopy architecture

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

- Interactive diagram: https://gitdiagram.com/danielfernandes202/patcopy
- Repository: https://github.com/danielfernandes202/patcopy

## Overview

##### Main Components Identification
- Frontend Client – Represented by the “pat-app” directory. This is a React application with clearly segmented modules, pages, and components (e.g., authentication, API calls, UI components, state management).
- Backend – Composed of multiple AWS Lambda functions found under “lambdas.” Each Lambda function is a microservice handling a specific domain (e.g., authentication, checksheet processing, email handling, dynamodb export/import).
- Shared Libraries – The “lambda_layers” directory contains common functionality and utilities (e.g., for querying, handling JSON validations, working with DynamoDB, JWT processing).
- Infrastructure & Deployment – The “terraform” directory (with separate folders for client and services) defines the cloud infrastructure (like API Gateway, Lambda, DynamoDB, S3, CloudFront, etc.). CI/CD configuration files (e.g., Jenkinsfile, GitHub workflows, and pre-commit configurations) should be noted as part of the overall deployment pipeline.

##### Relationships and Interactions
- The Frontend (pat-app) makes API calls (as evidenced by the “src/apis” directory) that likely hit endpoints managed by API Gateway (configured within Terraform).
- API Gateway routes these requests to the appropriate Lambda functions.
- Lambda functions may use shared Lambda layers for common functionalities, which are essentially libraries that remove code duplication across different backend functions.
- Some Lambda functions interact with AWS DynamoDB (as seen in lambda_layers/database), SQS, or other services configured in Terraform.
- The CI/CD pipeline (GitHub Actions, Jenkins) automates testing, linting, and deployment, ensuring that changes in the codebase (both in frontend and backend) are continuously integrated.

##### Key Architectural Patterns and Design Principles
- Microservices approach – Each Lambda under “lambdas” is an independent service responsible for a specific functionality.
- Separation of concerns – The clear separation between frontend, backend, and shared libraries (layers) enhances modularity and reusability.
- Infrastructure as Code (IaC) – Terraform configurations define the cloud resources and interactions, facilitating environment consistency.
- Secure configuration management – The project instructions for local testing include careful handling of environment-specific configurations (e.g., SSL certificates, secrets).

##### Relevant Technologies
- Node.js – All backend Lambda functions and Lambda layers use Node.js (evidenced by .mjs files and package.json files).
- React – The “pat-app” uses React (with components, state slices, and pages) to manage the user interface.
- Terraform – Infrastructure provisioning is done using Terraform (both for client and service configurations).
- AWS Services – Lambda, API Gateway, DynamoDB, S3, CloudFront, etc., are implied through configuration files.
- CI/CD Tools – GitHub Actions, Jenkins, and pre-commit hooks enforce quality and deployment processes.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        C1["GitHub Actions"]:::cicd
        C2["Jenkins Pipeline"]:::cicd
        C3["Pre-commit Config"]:::cicd
    end

    %% Frontend
    subgraph "Frontend/Client"
        F1["Frontend (React Client)"]:::frontend
    end

    %% Infrastructure & API Gateway
    subgraph "Infrastructure"
        I1["API Gateway"]:::infra
        I2["AWS Services (DynamoDB, S3, CloudFront)"]:::infra
    end

    %% Backend
    subgraph "Backend – AWS Lambda Functions"
        B1["AWS Lambda Functions"]:::backend
        B2["Shared Lambda Layers"]:::shared
    end

    %% Deployment Flow from CI/CD Pipeline to Components
    C1 -->|"deploys"| F1
    C1 -->|"deploys"| I1
    C1 -->|"deploys"| B1
    C2 -->|"triggers"| F1
    C2 -->|"triggers"| I1
    C2 -->|"triggers"| B1
    C3 -->|"validates"| F1

    %% Functional Flow
    F1 -->|"APIcalls"| I1
    I1 -->|"routes to"| B1
    B1 -->|"uses"| B2
    B1 -->|"integrates with"| I2

    %% Click Events for Component Mapping
    click F1 "https://github.com/danielfernandes202/patcopy/tree/main/pat-app/"
    click B1 "https://github.com/danielfernandes202/patcopy/tree/main/lambdas/"
    click B2 "https://github.com/danielfernandes202/patcopy/tree/main/lambda_layers/"
    click I1 "https://github.com/danielfernandes202/patcopy/tree/main/terraform/"
    click C1 "https://github.com/danielfernandes202/patcopy/tree/main/.github/workflows/"
    click C2 "https://github.com/danielfernandes202/patcopy/tree/main/Jenkinsfile"
    click C3 "https://github.com/danielfernandes202/patcopy/blob/main/.pre-commit-config.yaml"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#008000,stroke-width:2px;
    classDef shared fill:#FFD580,stroke:#FFA500,stroke-width:2px;
    classDef infra fill:#D3D3D3,stroke:#808080,stroke-width:2px;
    classDef cicd fill:#E6E6FA,stroke:#8A2BE2,stroke-width:2px;
```
