# keiter0309/dictiohub-dictionary architecture

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

- Interactive diagram: https://gitdiagram.com/keiter0309/dictiohub-dictionary
- Repository: https://github.com/keiter0309/dictiohub-dictionary

## Overview

##### Core Project Components
- Frontend (DA-FE): This is a React-based client application using TypeScript, TailwindCSS, and Ant Design. It is built with Vite and configured with Docker and Nginx for deployment. The directory structure shows a well-structured React app with components, pages (for admin and client views), routing, styling, and state management (stores with Redux slices).
- Backend (DA-BE): This Node/Express server uses Prisma ORM for MySQL database interactions, and integrates AWS services (Polly for audio, S3 for storage). The backend code is organized by features such as authentication, word handling, admin controllers, audio controllers, and more. It further includes utility functions, middlewares (auth, CORS, rate limiter) and database connection handling.
- Database: A MySQL database is used, with Prisma managing the schema and migrations (located under DA-BE/prisma) including initial migrations and seed data.
- External Services: AWS Polly for synthesizing audio content and AWS S3 for handling storage.

##### Relationships and Data Flow
- The backend handles these requests by interacting with the MySQL database via Prisma ORM. Show the backend as making SQL queries and reading/updating data.
- Docker: Both the frontend and backend have Dockerfiles and docker-compose configurations. Include a container orchestration layer to signify deployment consistency across environments.

##### Architectural Patterns and Design Principles
- Modular Components: The layered structure in both DA-FE and DA-BE, where controllers, routes, services, and models serve their individual purposes.
- Middleware and Security: The backend uses middlewares for authentication, CORS, rate limiting, and role management. Highlight these as key “processing layers” ensuring secure data handling.
- Dockerization: Emphasize containerization for consistent deployment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Component (React/Vite - DA-FE)"
        FE["React Client – DA-FE"]:::frontend
    end

    subgraph "Backend Component (Node/Express - DA-BE)"
        BE["API Server – DA-BE"]:::backend
        CTRLS["Backend Controllers"]:::backend
        ROUTES["Backend Routes"]:::backend
        BE --> CTRLS
        BE --> ROUTES
    end

    subgraph "Data Persistence"
        DB["Database – MySQL/Prisma"]:::database
        PRISMA_SCHEMA["Prisma Schema"]:::database
        PRISMA_MIG["Prisma Migrations"]:::database
        PRISMA_SEED["Prisma Seed Data"]:::database
        DB --> PRISMA_SCHEMA
        DB --> PRISMA_MIG
        DB --> PRISMA_SEED
    end

    subgraph "AWS Services Integration"
        AWS["AWS Integration – Polly & S3"]:::aws
        POLLY["AWS Polly"]:::aws
        S3["AWS S3"]:::aws
        AWS --> POLLY
        AWS --> S3
    end

    subgraph "Deployment & Infrastructure"
        DEP_FE["Frontend Docker & Nginx Setup"]:::deployment
        DEP_BE["Backend Docker Setup"]:::deployment
        CI_CD["CI/CD Workflows"]:::deployment
    end

    FE -->|"API_calls"| BE
    BE -->|"CRUD_ops"| DB
    BE -->|"Audio_calls"| AWS
    FE ---|"Deployed_via"| DEP_FE
    BE ---|"Deployed_via"| DEP_BE
    DEP_FE ---|"CI_CD_triggers"| CI_CD
    DEP_BE ---|"CI_CD_triggers"| CI_CD

    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef aws fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef deployment fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;

click FE "https://github.com/keiter0309/dictiohub-dictionary/tree/main/DA-FE/src"
click FE "https://github.com/keiter0309/dictiohub-dictionary/blob/main/DA-FE/index.html"
click FE "https://github.com/keiter0309/dictiohub-dictionary/blob/main/DA-FE/vite.config.ts"
click FE "https://github.com/keiter0309/dictiohub-dictionary/blob/main/DA-FE/nginx.conf"

click BE "https://github.com/keiter0309/dictiohub-dictionary/blob/main/DA-BE/src/index.ts"
click CTRLS "https://github.com/keiter0309/dictiohub-dictionary/tree/main/DA-BE/src/controllers"
click ROUTES "https://github.com/keiter0309/dictiohub-dictionary/tree/main/DA-BE/src/routes"

click DB "https://github.com/keiter0309/dictiohub-dictionary/tree/main/DA-BE/prisma"
click PRISMA_SCHEMA "https://github.com/keiter0309/dictiohub-dictionary/blob/main/DA-BE/prisma/schema.prisma"
click PRISMA_MIG "https://github.com/keiter0309/dictiohub-dictionary/tree/main/DA-BE/prisma/migrations"
click PRISMA_SEED "https://github.com/keiter0309/dictiohub-dictionary/blob/main/DA-BE/prisma/seed.ts"

click POLLY "https://github.com/keiter0309/dictiohub-dictionary/blob/main/DA-BE/src/services/aws/polly.service.ts"
click S3 "https://github.com/keiter0309/dictiohub-dictionary/blob/main/DA-BE/src/services/aws/s3.service.ts"
click AWS "https://github.com/keiter0309/dictiohub-dictionary/tree/main/DA-BE/src/services/aws"

click DEP_BE "https://github.com/keiter0309/dictiohub-dictionary/tree/main/DA-BE/Dockerfile"
click DEP_BE "https://github.com/keiter0309/dictiohub-dictionary/blob/main/DA-BE/docker-compose.yml"
click DEP_FE "https://github.com/keiter0309/dictiohub-dictionary/tree/main/DA-FE/Dockerfile"
click DEP_FE "https://github.com/keiter0309/dictiohub-dictionary/blob/main/DA-FE/nginx.conf"
click CI_CD "https://github.com/keiter0309/dictiohub-dictionary/blob/main/.github/workflows/deploy.yml"
```
