# mongulu-cm/mtchoun-mouh architecture

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

- Interactive diagram: https://gitdiagram.com/mongulu-cm/mtchoun-mouh
- Repository: https://github.com/mongulu-cm/mtchoun-mouh

## Overview

##### Main Components Identification

a) Frontend Layer:
- Static website hosted on S3 (evident from the html directory and deployment instructions)
- Registration interface (mtchoun-mouhregistration.html)
- Error handling page (error.html)

b) Backend Layer:
- AWS Lambda functions (visible in infra/api):
- Registration handler
- Scan handler
- Notification handler

c) Data Storage:
- DynamoDB for user registration data
- S3 for static website hosting

d) External Services:
- Consulate website (data source)
- Email notification service
- Monitoring services (Matomo, Sentry, CloudWatch)

**[User Browser] → [CloudFront/S3 (Static Website)]**
- ↓
**[API Gateway] → [Lambda Functions]**
- ↓
- [DynamoDB Tables]
- ↓
**[External Consulate Website] ← [Scan Lambda Function]**
- ↓
- [Email Notification Service]

##### Key Flows to Highlight

a) Registration Flow:
- User submission → API Gateway → Register Lambda → DynamoDB

b) Scanning Flow:
- Scheduled trigger → Scan Lambda → Consulate Website → DynamoDB → Notify Lambda → Email Service

c) Monitoring Flow:
- All components → CloudWatch Logs
- Frontend → Matomo Analytics
- Error tracking → Sentry

##### Important Details

- AWS Region information (from terraform configs)
- Security groups and IAM roles
- API Gateway endpoints
- CloudWatch logging points
- Error handling paths

##### Technical Stack Callouts

- Python for Lambda functions
- Terraform for infrastructure
- HTML/CSS for frontend
- AWS services (Lambda, API Gateway, DynamoDB, S3)
- Monitoring tools (Matomo, Sentry, CloudWatch)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph User["User Interface"]
        Browser["Web Browser"]
        Browser --> StaticSite["Static Website (S3/CloudFront)"]:::aws
    end

    subgraph Frontend["Frontend Components"]
        StaticSite --> RegPage["Registration Page"]:::frontend
        StaticSite --> ErrorPage["Error Page"]:::frontend
        
        click RegPage "https://github.com/mongulu-cm/mtchoun-mouh/blob/master/infra/api/mtchoun-mouhregistration.html"
        click ErrorPage "https://github.com/mongulu-cm/mtchoun-mouh/blob/master/html/error.html"
    end

    subgraph API["API Layer"]
        APIGW["API Gateway"]:::aws
        
        subgraph Lambda["Lambda Functions"]
            RegHandler["Registration Handler"]:::lambda
            ScanHandler["Scan Handler"]:::lambda
            NotifyHandler["Notification Handler"]:::lambda
            ExtractHandler["Data Extraction"]:::lambda
            
            click RegHandler "https://github.com/mongulu-cm/mtchoun-mouh/blob/master/infra/api/registre.py"
            click ScanHandler "https://github.com/mongulu-cm/mtchoun-mouh/blob/master/infra/api/scan.py"
            click NotifyHandler "https://github.com/mongulu-cm/mtchoun-mouh/blob/master/infra/api/notify.py"
            click ExtractHandler "https://github.com/mongulu-cm/mtchoun-mouh/blob/master/infra/api/extract.py"
        end
    end

    subgraph Storage["Data Layer"]
        DDB["DynamoDB"]:::aws
    end

    subgraph External["External Services"]
        Consulate["Consulate Website"]:::external
        EmailService["Email Service"]:::external
    end

    subgraph Monitoring["Monitoring & Logging"]
        CloudWatch["CloudWatch"]:::monitoring
        Matomo["Matomo Analytics"]:::monitoring
        Sentry["Sentry Error Tracking"]:::monitoring
    end

    subgraph IaC["Infrastructure as Code"]
        Terraform["Terraform Configs"]:::infra
        LambdaConfig["Lambda Configs"]:::infra
        
        click Terraform "https://github.com/mongulu-cm/mtchoun-mouh/blob/master/infra/main.tf"
        click LambdaConfig "https://github.com/mongulu-cm/mtchoun-mouh/blob/master/infra/api/config.py"
    end

    subgraph Testing["Testing Components"]
        Tests["Test Suites"]:::testing
        
        click Tests "https://github.com/mongulu-cm/mtchoun-mouh/blob/master/infra/api/test_extract.py"
    end

    %% Flow Connections
    Browser --> APIGW
    APIGW --> RegHandler
    APIGW --> ScanHandler
    APIGW --> NotifyHandler
    
    RegHandler --> DDB
    ScanHandler --> Consulate
    ScanHandler --> DDB
    NotifyHandler --> EmailService
    
    %% Monitoring Connections
    Lambda --> CloudWatch
    StaticSite --> Matomo
    Lambda --> Sentry

    %% Styling
    classDef aws fill:#FF9900,stroke:#232F3E,color:white
    classDef frontend fill:#42B883,stroke:#35495E,color:white
    classDef lambda fill:#009CDC,stroke:#232F3E,color:white
    classDef external fill:#7B8794,stroke:#232F3E,color:white
    classDef monitoring fill:#17A2B8,stroke:#232F3E,color:white
    classDef infra fill:#6F42C1,stroke:#232F3E,color:white
    classDef testing fill:#28A745,stroke:#232F3E,color:white
```
