# viniciussantos45/tik-tech architecture

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

- Interactive diagram: https://gitdiagram.com/viniciussantos45/tik-tech
- Repository: https://github.com/viniciussantos45/tik-tech

## Overview

##### Project type and purpose
- Tik Tech is a full-stack, Docker-containerized video-generation platform.
- It exposes a React/Vite/Tailwind-based frontend, an Express.js API/backend, and two specialized microservices (“image-generator” and “carbonara”) to generate video covers and code‐snippet visuals.
- It orchestrates calls to external services—OpenAI API (for content and narration prompts), AWS Polly (for text-to-speech), and FFmpeg (for final video assembly)—to produce tutorial videos.

##### File structure
- Top-level:
- Dockerfile + docker-compose.yml → multi-container orchestration: `api`, `image-generator`, `carbonara`.
- `client/front-end` → Vite + React + Shadcn/Tailwind UI + IndexedDB + Socket.io.
- `src/` → Express.js server entrypoint (`server.ts`), socket integration (`socket.ts`), and a services folder (BuildVideo, GenerateAudio, GenerateCarbonCode, etc.).
- `modules/image-generator-html` → separate Node service using Puppeteer to snapshot HTML and CSS into images for video covers.
- Config & environment files (.env, .env.example) specify API keys, AWS Region, and results path.
- No traditional database—uses local file-system “results” folder and browser IndexedDB for caching.

##### Extracted architecture from README
- Services:
- POST `/api/generate` → triggers the full pipeline.
- GET `/api/download/:id` → fetches the final MP4 file.
- GET `/` → serves the frontend.
- Docker Compose brings up three containers, wiring ports and inter-container networking.
- Socket.io provides real-time status updates to the client during video generation.

##### Components & relationships
a. Main components:
1. Client/Web Browser with React UI
2. API Container (Express.js + Socket.io + service orchestration)
3. Image-Generator Container (Puppeteer HTML → PNG)
4. “Carbonara” Container (renders code snippets as images)
5. External Services:
– OpenAI API
– AWS Polly
– FFmpeg (installed in API container)
6. Storage: Local “results” folder (mounted volume)
b. Interactions & data flows:
– Client submits `POST /api/generate` → API
– API → (via HTTP/gRPC) → image-generator / carbonara services for visual assets
– API → OpenAI API to generate prompts, narration text, code examples
– API → AWS Polly to convert narration text to audio
– API → FFmpeg to stitch together cover image, code snippet images, narration audio into final MP4
– API writes MP4 to `results/` and emits status via Socket.io back to client
– Client polls or listens to Socket.io events; when done, calls `GET /api/download/:id`
c. Architectural patterns & design principles:
– Microservices for specialized tasks (single-responsibility, container isolation)
– Event-driven status updates (Socket.io)
– External API orchestration (OpenAI, AWS Polly)
– Container orchestration (Docker Compose)
d. Key technologies & frameworks:
– Frontend: Vite, React, Shadcn UI, Tailwind CSS, IndexedDB, Socket.io-client
– Backend: Node.js, Express.js, Socket.io-server, TypeScript
– Microservices: Puppeteer (in image-generator), custom code-rendering (carbonara)
– Third-party: OpenAI API, AWS Polly, FFmpeg
– DevOps: Docker, Docker Compose

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Web Browser (React UI)"]:::frontend
    Browser -->|HTTP POST /api/generate| Server
    Browser -->|HTTP GET /api/download/:id| Server
    Browser <-->|"Socket.io"| SocketServer

    %% Docker Network Boundary
    subgraph "Docker Network"
      direction TB
      subgraph "API Container"
        direction TB
        Server["Express.js Server"]:::api
        SocketServer["Socket.io Server"]:::api
      end

      subgraph "Image-Generator Service"
        ImgGen["Image-Generator Service"]:::worker
      end

      subgraph "Carbonara Service"
        Carbon["Carbonara Service"]:::worker
      end
    end

    %% External Services
    OpenAI["OpenAI API"]:::external
    AWS["AWS Polly"]:::external
    FFmpeg["FFmpeg"]:::external

    %% Storage
    Storage["Results Storage (Local Volume)"]:::storage

    %% Orchestration Flows
    Server -->|REST / generate visual assets| ImgGen
    Server -->|REST / generate code images| Carbon
    Server -->|OpenAI API calls| OpenAI
    Server -->|AWS Polly TTS| AWS
    Server -->|FFmpeg stitch video| FFmpeg
    Server -->|Save MP4| Storage

    %% Click Events
    click Browser "https://github.com/viniciussantos45/tik-tech/tree/main/client/front-end/"
    click Server "https://github.com/viniciussantos45/tik-tech/blob/main/src/server.ts"
    click SocketServer "https://github.com/viniciussantos45/tik-tech/blob/main/src/socket.ts"
    click ImgGen "https://github.com/viniciussantos45/tik-tech/tree/main/modules/image-generator-html/"
    click Carbon "https://github.com/viniciussantos45/tik-tech/blob/main/src/services/GenerateCarbonCode.ts"
    click BuildVideo "https://github.com/viniciussantos45/tik-tech/blob/main/src/services/BuildVideo.ts"
    click GenerateAudio "https://github.com/viniciussantos45/tik-tech/blob/main/src/services/GenerateAudio.ts"
    click GenerateContent "https://github.com/viniciussantos45/tik-tech/blob/main/src/services/GenerateContent.ts"
    click GenerateCover "https://github.com/viniciussantos45/tik-tech/blob/main/src/services/GenerateCover.ts"
    click GenerateSubtitles "https://github.com/viniciussantos45/tik-tech/blob/main/src/services/GenerateSubtitles.ts"
    click BuildSubtitle "https://github.com/viniciussantos45/tik-tech/blob/main/src/services/BuildSubtitle.ts"
    click Docker "https://github.com/viniciussantos45/tik-tech/blob/main/docker-compose.yml"
    click Env "https://github.com/viniciussantos45/tik-tech/blob/main/src/config/environment.ts"
    click Storage "https://github.com/viniciussantos45/tik-tech/tree/main/videos/"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef api fill:#DFFFE0,stroke:#2E8B57,color:#2E8B57;
    classDef worker fill:#FFE8CC,stroke:#FF8C00,color:#FF8C00;
    classDef external fill:#E0E0E0,stroke:#666666,color:#333333;
    classDef storage fill:#FFF2CC,stroke:#D4A017,color:#D4A017;
```
