# anhdung2k1/contactless-checking architecture

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

- Interactive diagram: https://gitdiagram.com/anhdung2k1/contactless-checking
- Repository: https://github.com/anhdung2k1/contactless-checking

## Overview

- Backend API Service: Represent the “authentication” module (Spring Boot web service). Break it down into subcomponents such as:
- Controllers (e.g., AccountController, CustomerController, etc.)
- Service layers (interfaces and implementations for account, customer, notifications, tasks, and users)
- Security components (JWT filter, SecurityConfiguration, JwtService).
- AI/ML Face Model Service: Represent “face_model” as a separate service that runs the image recognition tasks and model training (with YOLOv11, FaceNet, ArcFace related scripts).
- Database Layer: Include MySQL as a relational database services container that stores user records, check-in logs, customer images, etc.
- CI/CD and Pipeline: A component for Jenkins (noting presence of Jenkinsfile and references to Jenkins in the README for triggering training pipelines).
- Infrastructure and Deployment: Show Kubernetes cluster components (e.g., pods for authentication, web client, MySQL, face model) and the Helm charts that orchestrate these deployments. Include Docker as the containerization platform.
- Additional DevOps Tools: Optionally denote the presence of Makefile (for build automation), Dockerfiles, and test harnesses (from the test/ directory).

##### Representing Relationships and Interactions
- From the Backend API, show interactions with the MySQL database (for CRUD operations) and AWS S3 (for storing and retrieving image files).
- Connection between the Backend and the Face Model service where images (or detection requests) are passed for facial recognition analysis.

##### Architectural Patterns and Design Principles
- A microservices architecture where services (authentication, face model, client, database) are separated into distinct containers.
- Security practices (JWT token-based authentication) and logging/aspects (LoggerAspect in the authentication service).
- Use of external configuration (application.yaml in Spring Boot, Helm values YAML files) to separate code from configuration, which is essential in cloud environments.
- That the system strongly leverages container orchestration (Kubernetes) for scalability and fault tolerance.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Component
    A["Web Client / Frontend"]:::frontend

    %% Backend API Service Subgraph
    subgraph "Backend API Service (Spring Boot)"
        B1["Controllers"]:::backend
        B2a["Service Layers"]:::backend
        B2b["Repositories"]:::backend
        B3["Security Components"]:::backend
        B4["LoggerAspect"]:::backend
    end

    %% Face Recognition Service
    C["Face Recognition Service (Python YOLOv11/FaceNet/ArcFace)"]:::face

    %% Database Subgraph
    subgraph "MySQL Database"
        D1["MySQL Service"]:::db
        D2["MySQL StatefulSet"]:::db
    end

    %% External Storage Subgraph
    subgraph "AWS S3 Storage"
        E1["S3 Utils"]:::storage
        E2["S3 Config"]:::storage
    end

    %% CI/CD Pipeline Subgraph
    subgraph "CI/CD Pipeline"
        F1["Jenkins Pipeline"]:::cicd
        F2["GitLab CI Pipeline"]:::cicd
    end

    %% Infrastructure & Deployment Subgraph
    subgraph "Kubernetes & Helm"
        G1["Helm Charts"]:::infra
        G2["Docker Containers"]:::infra
    end

    %% Build Orchestration
    H["Build Orchestration (Makefile)"]:::devops

    %% Relationships
    A -->|"HTTP/REST"| B1
    B1 -->|"calls"| B2a
    B2a -->|"accesses"| B2b
    B1 -->|"secured_by"| B3
    B1 -->|"logs_via"| B4
    A -->|"detection_request"| C
    B1 -->|"sends_image_data"| C
    B2a -->|"CRUD_ops"| D1
    B2a -->|"CRUD_ops"| D2
    B2a -->|"store_images"| E1
    C -->|"configures"| E2
    F1 -->|"deploys_to"| G1
    F2 -->|"deploys_to"| G1
    G1 -->|"packaged_as"| G2
    H -->|"triggers"| G2

    %% Click Events
    click A "https://github.com/anhdung2k1/contactless-checking/tree/master/face_client/"
    click B1 "https://github.com/anhdung2k1/contactless-checking/tree/master/authentication/authentication/src/main/java/com/example/authentication/controller/"
    click B2a "https://github.com/anhdung2k1/contactless-checking/tree/master/authentication/authentication/src/main/java/com/example/authentication/service/"
    click B2b "https://github.com/anhdung2k1/contactless-checking/tree/master/authentication/authentication/src/main/java/com/example/authentication/repository/"
    click B3 "https://github.com/anhdung2k1/contactless-checking/tree/master/authentication/authentication/src/main/java/com/example/authentication/config/"
    click B4 "https://github.com/anhdung2k1/contactless-checking/tree/master/authentication/authentication/src/main/java/com/example/authentication/aspect/"
    click C "https://github.com/anhdung2k1/contactless-checking/tree/master/face_model/"
    click D1 "https://github.com/anhdung2k1/contactless-checking/blob/master/helm/ck-application/templates/mysql-service.yaml"
    click D2 "https://github.com/anhdung2k1/contactless-checking/blob/master/helm/ck-application/templates/mysql-statefulset.yaml"
    click E1 "https://github.com/anhdung2k1/contactless-checking/blob/master/authentication/authentication/src/main/java/com/example/authentication/Utils/S3Utils.java"
    click E2 "https://github.com/anhdung2k1/contactless-checking/blob/master/face_model/s3_config/s3Config.py"
    click F1 "https://github.com/anhdung2k1/contactless-checking/tree/master/Jenkinsfile"
    click F2 "https://github.com/anhdung2k1/contactless-checking/blob/master/.gitlab-ci.yml"
    click G1 "https://github.com/anhdung2k1/contactless-checking/tree/master/helm/ck-application/"
    click G2 "https://github.com/anhdung2k1/contactless-checking/tree/master/docker/"
    click H "https://github.com/anhdung2k1/contactless-checking/tree/master/Makefile"

    %% Styles
    classDef frontend fill:#fef3c7,stroke:#b45309,stroke-width:2px;
    classDef backend fill:#bfdbfe,stroke:#1e40af,stroke-width:2px;
    classDef face fill:#bbf7d0,stroke:#15803d,stroke-width:2px;
    classDef db fill:#fed7aa,stroke:#c2410c,stroke-width:2px;
    classDef storage fill:#fde68a,stroke:#a16207,stroke-width:2px;
    classDef cicd fill:#d1fae5,stroke:#065f46,stroke-width:2px;
    classDef infra fill:#fecaca,stroke:#991b1b,stroke-width:2px;
    classDef devops fill:#e0e7ff,stroke:#3730a3,stroke-width:2px;
```
