# z-fujimori/tema_sns architecture

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

- Interactive diagram: https://gitdiagram.com/z-fujimori/tema_sns
- Repository: https://github.com/z-fujimori/tema_sns

## Overview

1. A backend built with NestJS, using a modular structure (modules such as auth, post, users, etc.) which also integrates Prisma for database operations and migrations.
2. A frontend built likely with React (using TypeScript and Vite) that interacts with the backend via API calls.

The project is containerized using Docker Compose, which orchestrates at least two containers (and possibly a database container as well even though it isn’t explicitly listed, the presence of Prisma migrations suggests a relational database is in use).

##### Main Components
- Frontend Component:
- React/Vite-based frontend application.
- Key UI elements if needed, like routing for home, profile, login/register, post creation, etc.
- Backend Component:
- NestJS backend which is organized into several modules (Auth, Post, Users, etc.).
- Auxiliary components such as Prisma for database interaction and configuration files (like Nest CLI configurations, Dockerfile, etc.).
- Database (Implicit):
- Although not directly pictured, include a relational database (e.g., PostgreSQL/MySQL) that the Prisma layer interacts with, as indicated by the migration folders and schema.prisma file.
- Docker Compose / Container Orchestration:
- That the system runs within multiple Docker containers (frontend, backend, and possibly the database) under Docker Compose’s management.

##### Relationships & Interactions
- How a client (typically a web browser or mobile app) sends requests to the Frontend.
- Directional flow from the Frontend to the Backend via API calls.
- Backend’s calls to the Database, especially via Prisma.
- Internal service interactions between the various NestJS modules if necessary (for instance, auth module communicating with the users module).
- Optionally, showcase external dependencies or services if hinted by the README.

##### Important Architectural Patterns
- Modular Architecture: Display the separation of concerns in the backend (modules like Auth, Post, Users, etc.).
- Containerization: Emphasize that all services run inside Docker containers coordinated by Docker Compose.
- Client-Server Interaction: Clarify the separation between frontend (client) and backend (server) responsibilities.
- Service Abstraction: Show how business logic is encapsulated within services in each module, particularly in the NestJS structure.

##### Technologies, Frameworks, or Libraries
- Back End: NestJS, Prisma, Node.js, and Docker.
- Front End: React with TypeScript, Vite, and Tailwind CSS.
- Tools: Docker Compose for orchestration, and potentially testing frameworks (indicated by spec and e2e files in both frontend and backend).

f. Use additional annotations if needed to mark container startup (using Docker Compose) or build steps indicated in the README.

## Diagram (Mermaid)

```mermaid
flowchart TB

    %% Docker Compose Boundary
    subgraph "Docker Compose"
        %% Frontend Container
        subgraph "Frontend Container"
            FE1["Frontend (React/Vite)"]:::frontend
        end
        %% Backend Container
        subgraph "Backend Container"
            BE1["Backend (NestJS)"]:::backend
            BE1A["Auth Module"]:::module
            BE1B["Post Module"]:::module
            BE1C["Users Module"]:::module
            BE1D["Prisma Integration"]:::prisma
        end
        %% Database Container
        subgraph "Database Container"
            DB["Database (RDBMS)"]:::database
        end
    end

    %% External Client
    Browser["Browser Client"]:::frontend

    %% Configuration Section
    subgraph "Configuration"
        FE_Dock["Frontend Dockerfile"]:::docker
        BE_Dock["Backend Dockerfile"]:::docker
        DC["Docker Compose File"]:::docker
    end

    %% Interactions
    Browser -->|"HTTP/REST"| FE1
    FE1 -->|"API_call"| BE1

    %% Backend internal module interactions
    BE1 -->|"InternalComunication"| BE1A
    BE1 -->|"InternalComunication"| BE1B
    BE1 -->|"InternalComunication"| BE1C
    BE1 -->|"DatabaseQuery"| BE1D
    BE1A -->|"Uses"| BE1C
    BE1D -->|"SQL/Prisma"| DB

    %% Build Configurations
    FE1 -.->|"Built_using"| FE_Dock
    BE1 -.->|"Built_using"| BE_Dock
    FE1 -.->|"Orchestrated_by"| DC
    BE1 -.->|"Orchestrated_by"| DC

    %% Click Events for Component Mapping
    click FE1 "https://github.com/z-fujimori/tema_sns/tree/main/frontend/"
    click BE1 "https://github.com/z-fujimori/tema_sns/tree/main/backend/"
    click BE1A "https://github.com/z-fujimori/tema_sns/tree/main/backend/src/auth/"
    click BE1B "https://github.com/z-fujimori/tema_sns/tree/main/backend/src/post/"
    click BE1C "https://github.com/z-fujimori/tema_sns/tree/main/backend/src/users/"
    click BE1D "https://github.com/z-fujimori/tema_sns/blob/main/backend/prisma/schema.prisma"
    click FE_Dock "https://github.com/z-fujimori/tema_sns/tree/main/frontend/Dockerfile"
    click BE_Dock "https://github.com/z-fujimori/tema_sns/tree/main/backend/Dockerfile"
    click DC "https://github.com/z-fujimori/tema_sns/blob/main/docker-compose.yaml"
    click Browser "https://github.com/z-fujimori/tema_sns/blob/main/frontend/src/main.tsx"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef backend fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef module fill:#FCF3CF,stroke:#F1C40F,stroke-width:2px;
    classDef prisma fill:#FADBD8,stroke:#E74C3C,stroke-width:2px;
    classDef database fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef docker fill:#D6EAF8,stroke:#5DADE2,stroke-width:2px;
```
