# ase-fs25/dailygrind architecture

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

- Interactive diagram: https://gitdiagram.com/ase-fs25/dailygrind
- Repository: https://github.com/ase-fs25/dailygrind

## Overview

##### Project type & purpose
- DailyGrind is a cloud-native, full-stack social-learning application. It consists of:
- A React/Vite frontend that users load in a browser
- Three primary Spring Boot microservices (User, Post, Push-Notification)
- A set of AWS Lambda functions for scheduled and event-driven push notifications and email confirmations
- AWS resources (DynamoDB, SNS/SQS, Cognito, API Gateway/ALB, S3) all provisioned via Terraform
- A Docker-Compose/LocalStack setup for local development
- Prometheus/Grafana monitoring and a fully automated GitHub Actions CI/CD pipeline

##### File-structure driven architecture
- Top-level folders:
- /frontend → React SPA
- /microservices → three separate Spring Boot services (user-service, post-service, push-notification-service) each with its own Dockerfile, entrypoint, docs, Maven config
- /lambda-functions → lightweight Node.js/Python lambdas for push-notification, scheduler, user-confirmation
- /terraform → IaC modules for network, ECS, Lambda, DynamoDB, SNS/SQS, Cognito, API Gateway, ALB, S3, etc.
- /docker-compose.yaml & Dockerfiles → orchestrate LocalStack, Terraform runner, microservices, frontend, Mailhog
- /prometheus → scrape config for monitoring

##### Key insights from README
- Single-table DynamoDB design, asynchronous event bus (SNS topics + SQS queues), Cognito for auth, API Gateway/ALB fronting microservices, S3 bucket for hosting frontend, scheduled and event-driven lambdas for push messages, full Terraform provisioning, LocalStack for emulation, GitHub Actions for CI/CD, Prometheus/Grafana observability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Users & UI Layer
    subgraph "Users & UI" 
        direction TB
        Browser(["User Browser"]):::frontend
        S3(["S3 / CDN (Static Hosting)"]):::infra
    end

    %% API & Auth Layer
    subgraph "API & Auth"
        direction TB
        Cognito(["Cognito (Auth)"]):::api
        APIGW(["API Gateway / ALB"]):::api
    end

    %% Services & Data Layer
    subgraph "Services & Data"
        direction TB
        UserSvc(["User Service"]):::service
        PostSvc(["Post Service"]):::service
        PushSvc(["Push-Notification Service"]):::service
        DynamoDB(["DynamoDB (Single Table)"]):::database
    end

    %% Async Messaging Layer
    subgraph "Async Messaging"
        direction TB
        SNSTopic(["SNS Topic (UserEvents)"]):::messaging
        SQSQueue(["SQS Queue (UserEvents Sub)"]):::messaging
    end

    %% Workers Layer
    subgraph "Lambda Workers"
        direction TB
        ScheduleLambda(["Schedule-Notification Lambda"]):::lambda
        PushLambda(["Push-Notification Lambda"]):::lambda
        ConfirmLambda(["User-Confirmation Lambda"]):::lambda
    end

    %% Monitoring Layer
    subgraph "Monitoring & Observability"
        direction TB
        Prometheus(["Prometheus"]):::monitoring
        Grafana(["Grafana"]):::monitoring
    end

    %% CI/CD & IaC Layer
    subgraph "CI/CD & IaC"
        direction TB
        Terraform(["Terraform IaC"]):::infra
        DockerCompose(["Docker-Compose / LocalStack"]):::infra
        GitHubActions(["GitHub Actions CI/CD"]):::cicd
    end

    %% Relationships
    Browser -->|"HTTP GET"| S3
    Browser -->|"OAuth/JWT"| Cognito
    Browser -->|"HTTP/REST + JWT"| APIGW
    Cognito -->|"JWT Token"| Browser

    APIGW -->|"routes to"| UserSvc
    APIGW -->|"routes to"| PostSvc
    APIGW -->|"routes to"| PushSvc

    UserSvc -->|"Read/Write"| DynamoDB
    PostSvc -->|"Read/Write"| DynamoDB
    PushSvc -->|"Read/Write"| DynamoDB

    UserSvc -->|"SNS Publish"| SNSTopic
    SNSTopic -->|"SQS Subscribe"| SQSQueue
    SQSQueue -->|"Consume events"| PostSvc

    SNSTopic -->|"SNS Trigger"| PushLambda
    ScheduleLambda -->|"CloudWatch Event"| SNSTopic
    ConfirmLambda -->|"API or SNS Trigger"| SNSTopic

    %% Monitoring flows
    UserSvc -->|"scrape /actuator/prometheus"| Prometheus
    PostSvc -->|"scrape /actuator/prometheus"| Prometheus
    PushSvc -->|"scrape /actuator/prometheus"| Prometheus
    Prometheus -->|"visualize"| Grafana

    %% CI/CD & IaC orchestration
    Terraform -.->|"provisions"| S3
    Terraform -.->|"provisions"| Cognito
    Terraform -.->|"provisions"| APIGW
    Terraform -.->|"provisions"| DynamoDB
    Terraform -.->|"provisions"| SNSTopic
    Terraform -.->|"provisions"| SQSQueue
    Terraform -.->|"provisions"| Lambdas
    Terraform -.->|"provisions"| ECS/Containers

    GitHubActions -->|"runs workflows"| DockerCompose
    GitHubActions -->|"runs workflows"| Terraform

    %% Click Events
    click Browser "https://github.com/ase-fs25/dailygrind/tree/main/frontend/"
    click UserSvc "https://github.com/ase-fs25/dailygrind/tree/main/microservices/user-service/"
    click PostSvc "https://github.com/ase-fs25/dailygrind/tree/main/microservices/post-service/"
    click PushSvc "https://github.com/ase-fs25/dailygrind/tree/main/microservices/push-notification-service/"
    click PushLambda "https://github.com/ase-fs25/dailygrind/tree/main/lambda-functions/push-notification-lambda/"
    click ScheduleLambda "https://github.com/ase-fs25/dailygrind/tree/main/lambda-functions/schedule-notification-lambda/"
    click ConfirmLambda "https://github.com/ase-fs25/dailygrind/tree/main/lambda-functions/user-confirmation-lambda/"
    click Terraform "https://github.com/ase-fs25/dailygrind/tree/main/terraform/"
    click DockerCompose "https://github.com/ase-fs25/dailygrind/blob/main/docker-compose.yaml"
    click Prometheus "https://github.com/ase-fs25/dailygrind/blob/main/prometheus/prometheus.yml"
    click GitHubActions "https://github.com/ase-fs25/dailygrind/tree/main/.github/workflows/"

    %% Styles
    classDef frontend fill:#FFDDE2,stroke:#E33E5C,color:#000;
    classDef api fill:#D0E8F2,stroke:#1C6EA4,color:#000;
    classDef service fill:#E2F0CB,stroke:#8DAA04,color:#000;
    classDef database fill:#FFF2CC,stroke:#D6A01A,color:#000;
    classDef messaging fill:#E8D0F2,stroke:#7D3BA8,color:#000;
    classDef lambda fill:#FDEBD0,stroke:#CA6F1E,color:#000;
    classDef infra fill:#D5D8DC,stroke:#566573,color:#000,stroke-dasharray: 5 5;
    classDef monitoring fill:#D1F2EB,stroke:#117A65,color:#000;
    classDef cicd fill:#F0F3F4,stroke:#566573,color:#000;
```
