# abdulhakkeempa/accentace architecture

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

- Interactive diagram: https://gitdiagram.com/abdulhakkeempa/accentace
- Repository: https://github.com/abdulhakkeempa/accentace

## Overview

##### Main Components
- Frontend: Built using Next.js and Tailwind CSS. It is responsible for rendering the user interface, handling client-side logic, and integrating Firebase for authentication.
- Backend: Built on FastAPI (as indicated by the backend files and README) that manages business logic such as text generation, voice analysis, and interactions with the Gemini API (as seen in files like gemini.py, prompt.py, and text_processing.py).
- Gemini API: An external LLM service (Gemini-1.5-Pro) which the backend communicates with in order to generate text.
- Firebase: Used for user authentication (Google Auth), integrated on the frontend and likely verified on the backend.
- Deployment Platforms: Vercel for the frontend and Google Cloud Run for the backend.
- Containerization: Dockerfiles (for both frontend and backend) and a docker-compose file are used for building and running the system locally.

##### Relationships and Interactions
- The frontend interacts with Firebase directly for authentication and sends authenticated requests to the backend.
- The backend (FastAPI) exposes REST endpoints that the frontend calls. It processes these requests, performing tasks like text generation (by forwarding the request to the Gemini API) and voice pronunciation analysis.
- The Gemini API serves as an external service that the backend utilizes to generate the required texts.
- Deployment components (Docker, Vercel, Cloud Run) should be represented to show the containerized environments and the separation between local development and production hosting.

##### Architectural Patterns and Design Principles
- Separation of concerns: The clear division between frontend and backend encourages maintainability.
- Microservices-ish behavior: The backend serves as a stateless RESTful service interacting with external APIs (Gemini).
- Containerization: Docker-managed builds and deployment via docker-compose illustrate a modern cloud and container-oriented deployment strategy.
- Integration with external authentication: Firebase integration demonstrates decoupling of authentication from business logic, enhancing security and modularity.

##### Relevant Technologies
- Frontend: Next.js, Tailwind CSS, Firebase (for client-side authentication).
- Backend: FastAPI, Python libraries (for Gemini API integration, text processing).
- Containers: Docker and docker-compose, illustrating how both frontend and backend are containerized.
- Cloud Platforms: Vercel (frontend hosting) and Google Cloud Run (backend serverless container deployment).
- External API: Gemini LLM (Gemini-1.5-Pro API) included as a service call within the backend.

##### Specific Elements
- External Services: Create separate nodes for “Firebase Authentication”, “Gemini API (LLM)”, “Vercel (Hosting)”, and “Google Cloud Run (Serverless Backend)” arranged accordingly.
- Labels: Each component should have clear labels to avoid confusion. Include key filenames or configuration references if necessary (like Dockerfile usage in both directories, docker-compose for local orchestration).

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("User"):::user

    subgraph "Frontend Layer"
        FE("Frontend (Next.js & Tailwind CSS)"):::frontend
        Firebase("Firebase Authentication"):::external
        Vercel("Vercel (Hosting)"):::external
        FDocker("Dockerfile (Frontend)"):::container
    end

    subgraph "Backend Layer"
        BE("Backend (FastAPI)"):::backend
        BL("Gemini Integration (Business Logic)"):::backendLogic
        CloudRun("Google Cloud Run (Serverless Backend)"):::external
        BDocker("Dockerfile (Backend)"):::container
    end

    Orchestration("Docker Compose Orchestration"):::containerOrch

    User -->|"interacts"| FE
    FE -->|"authenticates"| Firebase
    FE -->|"calls_API"| BE
    BE -->|"processes"| BL
    BL -->|"calls"| Gemini("Gemini API (LLM)"):::external

    Vercel --- FE
    CloudRun --- BE

    FE --- FDocker
    BE --- BDocker
    Orchestration --- FDocker
    Orchestration --- BDocker

    click FE "https://github.com/abdulhakkeempa/accentace/tree/main/frontend/"
    click Firebase "https://github.com/abdulhakkeempa/accentace/blob/main/frontend/src/app/firebase/config.js"
    click BE "https://github.com/abdulhakkeempa/accentace/blob/main/backend/app.py"
    click BL "https://github.com/abdulhakkeempa/accentace/blob/main/backend/src/gemini.py"
    click FDocker "https://github.com/abdulhakkeempa/accentace/tree/main/frontend/Dockerfile"
    click BDocker "https://github.com/abdulhakkeempa/accentace/tree/main/backend/Dockerfile"
    click Orchestration "https://github.com/abdulhakkeempa/accentace/blob/main/docker-compose.yml"
    click CloudRun "https://github.com/abdulhakkeempa/accentace/blob/main/.github/workflows/google-cloudrun-docker.yml"

    classDef user fill:#ffd700,stroke:#333,stroke-width:2px;
    classDef frontend fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef backend fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef backendLogic fill:#98fb98,stroke:#333,stroke-width:2px;
    classDef external fill:#ffa07a,stroke:#333,stroke-width:2px;
    classDef container fill:#d3d3d3,stroke:#333,stroke-width:2px;
    classDef containerOrch fill:#dcdcdc,stroke:#333,stroke-width:2px;
```
