# alen-kuriakose/content-moderation-service architecture

> Architecture diagram of the GitHub repository alen-kuriakose/content-moderation-service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alen-kuriakose/content-moderation-service
- Repository: https://github.com/alen-kuriakose/content-moderation-service

## Overview

##### Project type and purpose
- This is a backend microservice built with FastAPI. Its sole purpose is to expose two moderation endpoints—one for text (using Google Cloud Natural Language API) and one for images (using Google Cloud Vision API). It has no database of its own; it acts as a stateless API gateway to two external Google Cloud services.

##### File structure
- Top level: Dockerfile, requirements.txt, README.md, `.env` expectations.
- `src/main.py`: Instantiates the FastAPI app, loads config, logging, and includes routes.
- `src/routes/api.py`: Registers the `/moderate_text/` and `/moderate_image/` routes, mapping them to controller functions.
- `src/api/v1/*`: Controller layer (or “handlers”) for version 1 of the API: `text_moderation.py` and `image_moderation.py`.
- `src/schemas/moderation.py`: Pydantic models for request/response payloads.
- `src/services`: Two service classes, `LanguageService` and `VisionService`, which encapsulate all calls to Google Cloud APIs.
- `src/core/config.py` & `src/core/logger.py`: Configuration loading (via `.env`) and logging setup with `logging.conf`.

##### README for technical stack and patterns
- FastAPI for web framework, Uvicorn for ASGI server.
- Google Cloud credentials provided via environment variable.
- Docker for containerization.
- No mention of in-process caching or persistence; it is stateless and simply forwards requests.

## Diagram (Mermaid)

```mermaid
graph TB
    Client["Client (HTTP)"]:::external

    subgraph "Docker Container"
        direction TB
        App["FastAPI App"]:::app

        subgraph "Core / Infra"
            Config["Config Loader"]:::infra
            Logger["Logging Setup"]:::infra
        end

        Router["FastAPI Router"]:::app

        subgraph "Controllers"
            TextController["TextModerationController"]:::app
            ImageController["ImageModerationController"]:::app
        end

        Schemas["Pydantic Schemas"]:::app

        subgraph "Services"
            LanguageService["LanguageService"]:::app
            VisionService["VisionService"]:::app
        end
    end

    GCP_NL["Google Cloud Natural Language API"]:::external
    GCP_Vision["Google Cloud Vision API"]:::external

    Docs["README.md"]:::infra
    Reqs["requirements.txt"]:::infra
    DockerfileNode["Dockerfile & .dockerignore"]:::infra

    Client -->|"POST /moderate_text or /moderate_image"| App
    App --> Router
    Router --> TextController
    Router --> ImageController
    TextController --> Schemas
    ImageController --> Schemas
    TextController --> LanguageService
    ImageController --> VisionService
    LanguageService -->|"API Call"| GCP_NL
    VisionService -->|"API Call"| GCP_Vision
    LanguageService --> TextController
    VisionService --> ImageController
    Config --> App
    Logger --> App
    App --> DockerfileNode
    App --> Reqs
    App --> Docs

    click App "https://github.com/alen-kuriakose/content-moderation-service/blob/main/src/main.py"
    click Router "https://github.com/alen-kuriakose/content-moderation-service/blob/main/src/routes/api.py"
    click TextController "https://github.com/alen-kuriakose/content-moderation-service/blob/main/src/api/v1/text_moderation.py"
    click ImageController "https://github.com/alen-kuriakose/content-moderation-service/blob/main/src/api/v1/image_moderation.py"
    click Schemas "https://github.com/alen-kuriakose/content-moderation-service/blob/main/src/schemas/moderation.py"
    click LanguageService "https://github.com/alen-kuriakose/content-moderation-service/blob/main/src/services/language_service.py"
    click VisionService "https://github.com/alen-kuriakose/content-moderation-service/blob/main/src/services/vision_service.py"
    click Config "https://github.com/alen-kuriakose/content-moderation-service/blob/main/src/core/config.py"
    click Logger "https://github.com/alen-kuriakose/content-moderation-service/blob/main/src/core/logger.py"
    click DockerfileNode "https://github.com/alen-kuriakose/content-moderation-service/tree/main/Dockerfile"
    click Reqs "https://github.com/alen-kuriakose/content-moderation-service/blob/main/requirements.txt"
    click Docs "https://github.com/alen-kuriakose/content-moderation-service/blob/main/README.md"

    classDef app fill:#D6EAF8,stroke:#3498DB;
    classDef external fill:#D5F5E3,stroke:#27AE60;
    classDef infra fill:#E5E7E9,stroke:#95A5A6;
```
