# edinaldofcs/synexa-api architecture

> Architecture diagram of the GitHub repository edinaldofcs/synexa-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/edinaldofcs/synexa-api
- Repository: https://github.com/edinaldofcs/synexa-api

## Overview

1. **Overall shape**
   - This is a **NestJS / TypeScript backend API**. The app is organized as a set of feature modules under `src/`, with a single bootstrap entry point in `src/main.ts` and a root composition module in `src/app.module.ts`.

2. **Primary runtime boundary**
   - The process is a **server-side Node.js service** exposed through NestJS controllers. There is no sign of a frontend in this repo; the architecture is centered on request handling, business logic, and persistence/integration services.

3. **Feature modules**
   - The main business areas are split into:
     - `admin` — administrative API surface
     - `chat` — conversations and messages
     - `imports` — contact import flows
     - `painel-clients` — client/admin configuration domain, with DTOs for agents, APIs, clients, and intentions
     - `tables` — table-oriented data access plus export endpoints

4. **Controller → service → infrastructure flow**
   - Each feature follows the NestJS pattern: HTTP controllers accept requests, delegate to services, and services call shared infrastructure. This creates a clear separation between transport, domain logic, and persistence/external systems.

5. **Shared persistence layer**
   - `src/common/prisma` contains `PrismaService` and `PrismaModule`, indicating **Prisma is the primary database access layer**. The data model itself is defined in `prisma/schema.prisma`, so the schema is a major architectural boundary.

6. **External service integration**
   - `src/common/supabase` contains `SupabaseService` and `SupabaseModule`, so the app also integrates with **Supabase** as an external backend service. Based on the repo structure, this is likely used for storage/auth/data exchange in one or more feature flows, rather than being the main application runtime.

7. **Input contracts and boundaries**
   - Each domain uses DTOs under its own `dto/` folder, such as `create-*` and `update-*` classes. That means request validation and payload shaping are part of the boundary between API clients and internal services.

8. **Likely data domains**
   - From the naming, the application appears to manage:
     - conversational data (`chat`)
     - imported contacts (`imports`)
     - client/agent/API/intention configuration (`painel-clients`)
     - tabular records and exports (`tables`)
     - administrative actions (`admin`)
   - These are distinct subdomains, but they share the same persistence and service infrastructure.

9. **Export and reporting path**
   - `src/tables/export.controller.ts` suggests a dedicated **export endpoint** separate from the normal tables API. That implies a read-heavy/reporting boundary where data is retrieved from the database and transformed for external consumption.

10. **Deployment and packaging**
   - The repo is containerized with a `Dockerfile` plus `docker-compose.yml` and `docker-compose.dev.yml`, so it supports both local development and production-style runtime packaging. This is a single-service deployment model rather than a multi-service microservice layout.

11. **CI/CD and quality gates**
   - GitHub Actions workflows exist for `ci.yml` and `deploy.yml`, so build/test/deploy automation is part of the architecture. Testing uses Jest, including e2e coverage under `test/`.

12. **What is not present**
   - There is no evidence of message brokers, background job workers, or a separate cache layer in the file tree. The architecture appears to be a **monolithic API service** with modular internal boundaries, backed by Prisma-managed persistence and selective Supabase integration.

Main entry points: [`src/app.module.ts`](https://github.com/edinaldofcs/synexa-api/blob/main/src/app.module.ts) (App module), [`src/common/prisma/prisma.service.ts`](https://github.com/edinaldofcs/synexa-api/blob/main/src/common/prisma/prisma.service.ts) (Prisma service), [`src/tables/tables.service.ts`](https://github.com/edinaldofcs/synexa-api/blob/main/src/tables/tables.service.ts) (Tables service), [`src/admin/admin.service.ts`](https://github.com/edinaldofcs/synexa-api/blob/main/src/admin/admin.service.ts) (Admin service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_main["Bootstrap<br/>nest entrypoint<br/>[main.ts]"]
  node_appmodule["App module<br/>root module<br/>[app.module.ts]"]
  node_appcontroller["App controller<br/>root controller<br/>[app.controller.ts]"]
end

subgraph group_features["Features"]
  node_adminmod["Admin<br/>feature module<br/>[admin.module.ts]"]
  node_adminapi["Admin API<br/>controller"]
  node_adminsvc["Admin service<br/>[admin.service.ts]"]
  node_chatmod["Chat<br/>feature module<br/>[chat.module.ts]"]
  node_chatapi["Chat API<br/>controller<br/>[chat.controller.ts]"]
  node_chatsvc["Chat service<br/>[chat.service.ts]"]
  node_chatdto["Chat DTOs<br/>contracts"]
  node_importsmod["Imports<br/>feature module<br/>[imports.module.ts]"]
  node_importsapi["Imports API<br/>controller"]
  node_importssvc["Imports service<br/>[imports.service.ts]"]
  node_painelmod["Painel clients<br/>feature module"]
  node_painelapi["Painel API<br/>controller"]
  node_painelsvc["Painel service"]
  node_paineledtos["Painel DTOs<br/>contracts"]
  node_tablesmod["Tables<br/>feature module<br/>[tables.module.ts]"]
  node_tablesapi["Tables API<br/>controller"]
  node_exportapi["Export API<br/>controller"]
  node_tablessvc["Tables service<br/>[tables.service.ts]"]
end

subgraph group_shared["Shared"]
  node_commonmod["Common module<br/>shared module<br/>[common.module.ts]"]
  node_prismamod["Prisma module<br/>database module<br/>[prisma.module.ts]"]
  node_primasvc["Prisma service<br/>db access<br/>[prisma.service.ts]"]
  node_supabasemod["Supabase module<br/>integration module<br/>[supabase.module.ts]"]
  node_supabasesvc["Supabase service<br/>integration"]
end

subgraph group_data["Data"]
  node_schema["Prisma schema<br/>data model<br/>[schema.prisma]"]
end

subgraph group_ops["Ops"]
  node_docker["Container build<br/>packaging"]
  node_compose["Compose setup<br/>deployment<br/>[docker-compose.yml]"]
  node_ci["CI workflow<br/>automation<br/>[ci.yml]"]
  node_deploy["Deploy workflow<br/>automation<br/>[deploy.yml]"]
end

node_main -->|"boots"| node_appmodule
node_appmodule -->|"exposes"| node_appcontroller
node_appmodule -->|"imports"| node_commonmod
node_appmodule -->|"imports"| node_adminmod
node_appmodule -->|"imports"| node_chatmod
node_appmodule -->|"imports"| node_importsmod
node_appmodule -->|"imports"| node_painelmod
node_appmodule -->|"imports"| node_tablesmod
node_adminapi -->|"delegates"| node_adminsvc
node_chatapi -->|"delegates"| node_chatsvc
node_importsapi -->|"delegates"| node_importssvc
node_painelapi -->|"delegates"| node_painelsvc
node_tablesapi -->|"delegates"| node_tablessvc
node_exportapi -->|"delegates"| node_tablessvc
node_chatsvc -->|"reads/writes"| node_primasvc
node_importssvc -->|"reads/writes"| node_primasvc
node_painelsvc -->|"reads/writes"| node_primasvc
node_tablessvc -->|"reads/writes"| node_primasvc
node_tablessvc -->|"integrates"| node_supabasesvc
node_prismamod -->|"provides"| node_primasvc
node_supabasemod -->|"provides"| node_supabasesvc
node_commonmod -->|"bundles"| node_prismamod
node_commonmod -->|"bundles"| node_supabasemod
node_primasvc -->|"maps to"| node_schema
node_adminsvc -.->|"reads/writes"| node_primasvc
node_adminsvc -.->|"integrates"| node_supabasesvc
node_chatsvc -.->|"accepts"| node_chatdto
node_importssvc -.->|"uses"| node_primasvc
node_painelsvc -.->|"accepts"| node_paineledtos
node_tablessvc -.->|"queries"| node_schema
node_docker -->|"packages"| node_main
node_compose -->|"runs"| node_docker
node_ci -->|"builds"| node_docker
node_deploy -->|"deploys"| node_compose

click node_main "https://github.com/edinaldofcs/synexa-api/blob/main/src/main.ts"
click node_appmodule "https://github.com/edinaldofcs/synexa-api/blob/main/src/app.module.ts"
click node_appcontroller "https://github.com/edinaldofcs/synexa-api/blob/main/src/app.controller.ts"
click node_adminmod "https://github.com/edinaldofcs/synexa-api/blob/main/src/admin/admin.module.ts"
click node_adminapi "https://github.com/edinaldofcs/synexa-api/blob/main/src/admin/admin.controller.ts"
click node_adminsvc "https://github.com/edinaldofcs/synexa-api/blob/main/src/admin/admin.service.ts"
click node_chatmod "https://github.com/edinaldofcs/synexa-api/blob/main/src/chat/chat.module.ts"
click node_chatapi "https://github.com/edinaldofcs/synexa-api/blob/main/src/chat/chat.controller.ts"
click node_chatsvc "https://github.com/edinaldofcs/synexa-api/blob/main/src/chat/chat.service.ts"
click node_importsmod "https://github.com/edinaldofcs/synexa-api/blob/main/src/imports/imports.module.ts"
click node_importsapi "https://github.com/edinaldofcs/synexa-api/blob/main/src/imports/imports.controller.ts"
click node_importssvc "https://github.com/edinaldofcs/synexa-api/blob/main/src/imports/imports.service.ts"
click node_painelmod "https://github.com/edinaldofcs/synexa-api/blob/main/src/painel-clients/painel-clients.module.ts"
click node_painelapi "https://github.com/edinaldofcs/synexa-api/blob/main/src/painel-clients/painel-clients.controller.ts"
click node_painelsvc "https://github.com/edinaldofcs/synexa-api/blob/main/src/painel-clients/painel-clients.service.ts"
click node_tablesmod "https://github.com/edinaldofcs/synexa-api/blob/main/src/tables/tables.module.ts"
click node_tablesapi "https://github.com/edinaldofcs/synexa-api/blob/main/src/tables/tables.controller.ts"
click node_exportapi "https://github.com/edinaldofcs/synexa-api/blob/main/src/tables/export.controller.ts"
click node_tablessvc "https://github.com/edinaldofcs/synexa-api/blob/main/src/tables/tables.service.ts"
click node_commonmod "https://github.com/edinaldofcs/synexa-api/blob/main/src/common/common.module.ts"
click node_prismamod "https://github.com/edinaldofcs/synexa-api/blob/main/src/common/prisma/prisma.module.ts"
click node_primasvc "https://github.com/edinaldofcs/synexa-api/blob/main/src/common/prisma/prisma.service.ts"
click node_supabasemod "https://github.com/edinaldofcs/synexa-api/blob/main/src/common/supabase/supabase.module.ts"
click node_supabasesvc "https://github.com/edinaldofcs/synexa-api/blob/main/src/common/supabase/supabase.service.ts"
click node_schema "https://github.com/edinaldofcs/synexa-api/blob/main/prisma/schema.prisma"
click node_docker "https://github.com/edinaldofcs/synexa-api/tree/main/Dockerfile"
click node_compose "https://github.com/edinaldofcs/synexa-api/blob/main/docker-compose.yml"
click node_ci "https://github.com/edinaldofcs/synexa-api/blob/main/.github/workflows/ci.yml"
click node_deploy "https://github.com/edinaldofcs/synexa-api/blob/main/.github/workflows/deploy.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_appmodule,node_appcontroller toneBlue
class node_adminmod,node_adminapi,node_adminsvc,node_chatmod,node_chatapi,node_chatsvc,node_chatdto,node_importsmod,node_importsapi,node_importssvc,node_painelmod,node_painelapi,node_painelsvc,node_paineledtos,node_tablesmod,node_tablesapi,node_exportapi,node_tablessvc toneAmber
class node_commonmod,node_prismamod,node_primasvc,node_supabasemod,node_supabasesvc toneMint
class node_schema toneRose
class node_docker,node_compose,node_ci,node_deploy toneIndigo
```

## Components

### Runtime

Bootstrap and application composition

- [Bootstrap](https://github.com/edinaldofcs/synexa-api/blob/main/src/main.ts): nest entrypoint · Starts the NestJS application · `src/main.ts`
- [App module](https://github.com/edinaldofcs/synexa-api/blob/main/src/app.module.ts): root module · Composes the application feature modules · `src/app.module.ts`
- [App controller](https://github.com/edinaldofcs/synexa-api/blob/main/src/app.controller.ts): root controller · Top-level application controller · `src/app.controller.ts`

### Features

Domain modules exposed through Nest controllers

- [Admin](https://github.com/edinaldofcs/synexa-api/blob/main/src/admin/admin.module.ts): feature module · Administrative API surface · `src/admin/admin.module.ts`
- [Admin API](https://github.com/edinaldofcs/synexa-api/blob/main/src/admin/admin.controller.ts): controller · Admin HTTP endpoints · `src/admin/admin.controller.ts`
- [Admin service](https://github.com/edinaldofcs/synexa-api/blob/main/src/admin/admin.service.ts): service · Admin business logic · `src/admin/admin.service.ts`
- [Chat](https://github.com/edinaldofcs/synexa-api/blob/main/src/chat/chat.module.ts): feature module · Conversation and message APIs · `src/chat/chat.module.ts`
- [Chat API](https://github.com/edinaldofcs/synexa-api/blob/main/src/chat/chat.controller.ts): controller · Conversation and message endpoints · `src/chat/chat.controller.ts`
- [Chat service](https://github.com/edinaldofcs/synexa-api/blob/main/src/chat/chat.service.ts): service · Conversation and message logic · `src/chat/chat.service.ts`
- **Chat DTOs**: contracts · Payload contracts for chat requests
- [Imports](https://github.com/edinaldofcs/synexa-api/blob/main/src/imports/imports.module.ts): feature module · Contact import flows · `src/imports/imports.module.ts`
- [Imports API](https://github.com/edinaldofcs/synexa-api/blob/main/src/imports/imports.controller.ts): controller · Import endpoints · `src/imports/imports.controller.ts`
- [Imports service](https://github.com/edinaldofcs/synexa-api/blob/main/src/imports/imports.service.ts): service · Import processing logic · `src/imports/imports.service.ts`
- [Painel clients](https://github.com/edinaldofcs/synexa-api/blob/main/src/painel-clients/painel-clients.module.ts): feature module · Client, agent, API, and intention configuration · `src/painel-clients/painel-clients.module.ts`
- [Painel API](https://github.com/edinaldofcs/synexa-api/blob/main/src/painel-clients/painel-clients.controller.ts): controller · Configuration endpoints · `src/painel-clients/painel-clients.controller.ts`
- [Painel service](https://github.com/edinaldofcs/synexa-api/blob/main/src/painel-clients/painel-clients.service.ts): service · Configuration and domain logic · `src/painel-clients/painel-clients.service.ts`
- **Painel DTOs**: contracts · Contracts for clients, agents, APIs, and intentions
- [Tables](https://github.com/edinaldofcs/synexa-api/blob/main/src/tables/tables.module.ts): feature module · Tabular data and export APIs · `src/tables/tables.module.ts`
- [Tables API](https://github.com/edinaldofcs/synexa-api/blob/main/src/tables/tables.controller.ts): controller · Table data endpoints · `src/tables/tables.controller.ts`
- [Export API](https://github.com/edinaldofcs/synexa-api/blob/main/src/tables/export.controller.ts): controller · Dedicated export endpoint · `src/tables/export.controller.ts`
- [Tables service](https://github.com/edinaldofcs/synexa-api/blob/main/src/tables/tables.service.ts): service · Table querying and export preparation · `src/tables/tables.service.ts`

### Shared

Common infrastructure modules

- [Common module](https://github.com/edinaldofcs/synexa-api/blob/main/src/common/common.module.ts): shared module · Shared infrastructure composition · `src/common/common.module.ts`
- [Prisma module](https://github.com/edinaldofcs/synexa-api/blob/main/src/common/prisma/prisma.module.ts): database module · Provides database access infrastructure · `src/common/prisma/prisma.module.ts`
- [Prisma service](https://github.com/edinaldofcs/synexa-api/blob/main/src/common/prisma/prisma.service.ts): db access · Primary database service · `src/common/prisma/prisma.service.ts`
- [Supabase module](https://github.com/edinaldofcs/synexa-api/blob/main/src/common/supabase/supabase.module.ts): integration module · Provides Supabase integration · `src/common/supabase/supabase.module.ts`
- [Supabase service](https://github.com/edinaldofcs/synexa-api/blob/main/src/common/supabase/supabase.service.ts): integration · Supabase-backed operations · `src/common/supabase/supabase.service.ts`

### Data

Persistence schema and database boundary

- [Prisma schema](https://github.com/edinaldofcs/synexa-api/blob/main/prisma/schema.prisma): data model · Database schema definition · `prisma/schema.prisma`

### Ops

Container and CI/CD packaging

- [Container build](https://github.com/edinaldofcs/synexa-api/tree/main/Dockerfile): packaging · Dockerized service packaging · `Dockerfile`
- [Compose setup](https://github.com/edinaldofcs/synexa-api/blob/main/docker-compose.yml): deployment · Local and production compose definitions · `docker-compose.yml`
- [CI workflow](https://github.com/edinaldofcs/synexa-api/blob/main/.github/workflows/ci.yml): automation · Continuous integration pipeline · `.github/workflows/ci.yml`
- [Deploy workflow](https://github.com/edinaldofcs/synexa-api/blob/main/.github/workflows/deploy.yml): automation · Deployment pipeline · `.github/workflows/deploy.yml`

## Connections

- Bootstrap → App module: boots · Application starts by loading the root module
- App module → App controller: exposes · Root module includes the top-level controller
- App module → Common module: imports · Shares infrastructure across features
- App module → Admin: imports · Composes admin feature
- App module → Chat: imports · Composes chat feature
- App module → Imports: imports · Composes imports feature
- App module → Painel clients: imports · Composes painel clients feature
- App module → Tables: imports · Composes tables feature
- Admin API → Admin service: delegates · Controller passes requests to the service
- Chat API → Chat service: delegates · Controller passes requests to the service
- Imports API → Imports service: delegates · Controller passes requests to the service
- Painel API → Painel service: delegates · Controller passes requests to the service
- Tables API → Tables service: delegates · Controller passes requests to the service
- Export API → Tables service: delegates · Export endpoint reuses the tables service
- Chat service → Prisma service: reads/writes · Chat data is persisted through Prisma
- Imports service → Prisma service: reads/writes · Import flows persist data through Prisma
- Painel service → Prisma service: reads/writes · Configuration data is stored through Prisma
- Tables service → Prisma service: reads/writes · Tabular queries and exports use Prisma
- Tables service → Supabase service: integrates · Tables flows may use Supabase-backed operations
- Prisma module → Prisma service: provides · Prisma module exposes the database service
- Supabase module → Supabase service: provides · Supabase module exposes the integration service
- Common module → Prisma module: bundles · Common module bundles database access
- Common module → Supabase module: bundles · Common module bundles external integration
- Prisma service → Prisma schema: maps to · Database service is backed by the Prisma schema
- Admin service → Prisma service: reads/writes · Admin actions likely touch the database
- Admin service → Supabase service: integrates · Admin flows may call external Supabase services
- Chat service → Chat DTOs: accepts · Chat service is fed by request DTOs
- Imports service → Prisma service: uses · Import processing depends on database access
- Painel service → Painel DTOs: accepts · Configuration service uses feature DTOs
- Tables service → Prisma schema: queries · Tables and exports operate on the database model
- Container build → Bootstrap: packages · Container build packages the application entrypoint
- Compose setup → Container build: runs · Compose definitions run the containerized service
- CI workflow → Container build: builds · CI validates the containerized application
- Deploy workflow → Compose setup: deploys · Deployment workflow uses the composed service definition
