anderson-ufrj commited on
Commit
7054eaf
·
1 Parent(s): 0564dce

docs(api): create comprehensive API endpoints mapping document

Browse files

- Document all 529 endpoints with their status
- Categorize endpoints by functionality
- Identify active vs inactive routes
- Highlight Portal da Transparência limitations
- Include testing examples and next steps

Files changed (1) hide show
  1. docs/API_ENDPOINTS_MAP.md +299 -0
docs/API_ENDPOINTS_MAP.md ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🗺️ Mapa Completo de Endpoints da API Cidadão.AI
2
+
3
+ **Última atualização**: Janeiro 2025
4
+ **Total de endpoints**: 529 endpoints
5
+ **Status**: 490 ativos, 39 inativos
6
+
7
+ ## 📊 Resumo por Categoria
8
+
9
+ | Categoria | Endpoints Ativos | Status |
10
+ |-----------|------------------|---------|
11
+ | Health & Monitoring | 6 | ✅ Funcionando |
12
+ | Authentication | 7 | ✅ Funcionando |
13
+ | Chat | 7 | ✅ Funcionando |
14
+ | Agents | 11 | ✅ Funcionando (8/17 agentes) |
15
+ | Investigations | 6 | ✅ Funcionando |
16
+ | Analysis | 4 | ✅ Funcionando |
17
+ | Reports | 4 | ✅ Funcionando |
18
+ | Dados.gov.br | 8 | ✅ Funcionando |
19
+ | Portal Transparência | - | ⚠️ 22% funcionando |
20
+ | Admin | 23 | ✅ Funcionando |
21
+ | WebSocket | 2 | 🔧 Parcial |
22
+ | GraphQL | 2 | 🔧 Parcial |
23
+
24
+ ## 🔌 Endpoints Ativos e Conectados
25
+
26
+ ### 1. Health & Monitoring (`/health/*`)
27
+ ```
28
+ ✅ GET /health/ - Health check básico
29
+ ✅ GET /health/detailed - Health check detalhado
30
+ ✅ GET /health/live - Kubernetes liveness probe
31
+ ✅ GET /health/ready - Kubernetes readiness probe
32
+ ✅ GET /health/metrics - Métricas Prometheus
33
+ ✅ GET /health/metrics/json - Métricas em JSON
34
+ ```
35
+
36
+ ### 2. Autenticação (`/auth/*`)
37
+ ```
38
+ ✅ POST /auth/register - Registro de usuário
39
+ ✅ POST /auth/login - Login
40
+ ✅ POST /auth/refresh - Renovar token JWT
41
+ ✅ GET /auth/me - Dados do usuário atual
42
+ ✅ POST /auth/logout - Logout
43
+ ✅ POST /auth/oauth/google - OAuth Google
44
+ ✅ POST /auth/oauth/github - OAuth GitHub
45
+ ```
46
+
47
+ ### 3. Chat - MÚLTIPLAS IMPLEMENTAÇÕES (`/api/v1/chat/*`)
48
+ ```
49
+ ✅ POST /api/v1/chat/message - Chat principal (com Zumbi + dados.gov.br)
50
+ ✅ POST /api/v1/chat/stream - Chat com streaming
51
+ ✅ POST /api/v1/chat/simple - Chat simples (Maritaca AI)
52
+ ✅ POST /api/v1/chat/stable - Chat estável
53
+ ✅ POST /api/v1/chat/optimized - Chat otimizado
54
+ ✅ POST /api/v1/chat/emergency - Chat emergência (fallback)
55
+ ✅ GET /api/v1/chat/history - Histórico de conversas
56
+ ```
57
+
58
+ ### 4. Agentes de IA (`/api/v1/agents/*`)
59
+ ```
60
+ ✅ POST /api/v1/agents/invoke - Invocar agente genérico
61
+ ✅ GET /api/v1/agents/ - Listar agentes disponíveis
62
+ ✅ GET /api/v1/agents/status - Status de todos os agentes
63
+
64
+ Agentes Específicos:
65
+ ✅ POST /api/v1/agents/zumbi - Zumbi dos Palmares (detecção de anomalias)
66
+ ✅ POST /api/v1/agents/anita - Anita Garibaldi (análise de padrões)
67
+ ✅ POST /api/v1/agents/tiradentes - Tiradentes (geração de relatórios)
68
+ ✅ POST /api/v1/agents/bonifacio - José Bonifácio (compliance)
69
+ ✅ POST /api/v1/agents/maria-quiteria - Maria Quitéria (auditoria)
70
+ ✅ POST /api/v1/agents/drummond - Carlos Drummond (conversacional)
71
+ ✅ POST /api/v1/agents/senna - Ayrton Senna (roteamento)
72
+ ✅ POST /api/v1/agents/machado - Machado de Assis (narrativas)
73
+ ```
74
+
75
+ ### 5. Investigações (`/api/v1/investigations/*`)
76
+ ```
77
+ ✅ POST /api/v1/investigations/start - Iniciar investigação
78
+ ✅ GET /api/v1/investigations/stream/{id} - Stream de resultados (SSE)
79
+ ✅ GET /api/v1/investigations/{id}/status - Status da investigação
80
+ ✅ GET /api/v1/investigations/{id}/results - Resultados completos
81
+ ✅ GET /api/v1/investigations/ - Listar investigações
82
+ ✅ DELETE /api/v1/investigations/{id} - Cancelar investigação
83
+ ```
84
+
85
+ ### 6. Análises (`/api/v1/analysis/*`)
86
+ ```
87
+ ✅ POST /api/v1/analysis/patterns - Análise de padrões
88
+ ✅ POST /api/v1/analysis/correlations - Correlações
89
+ ✅ POST /api/v1/analysis/trends - Tendências
90
+ ✅ POST /api/v1/analysis/efficiency - Métricas de eficiência
91
+ ```
92
+
93
+ ### 7. Relatórios (`/api/v1/reports/*`)
94
+ ```
95
+ ✅ POST /api/v1/reports/generate - Gerar relatório
96
+ ✅ GET /api/v1/reports/{id} - Obter relatório
97
+ ✅ GET /api/v1/reports/ - Listar relatórios
98
+ ✅ POST /api/v1/reports/schedule - Agendar relatório
99
+ ```
100
+
101
+ ### 8. Dados.gov.br - NOVA INTEGRAÇÃO (`/api/v1/dados-gov/*`)
102
+ ```
103
+ ✅ GET /api/v1/dados-gov/search - Buscar datasets
104
+ ✅ GET /api/v1/dados-gov/dataset/{id} - Detalhes do dataset
105
+ ✅ GET /api/v1/dados-gov/resource/{id}/url - URL do recurso
106
+ ✅ GET /api/v1/dados-gov/organizations - Listar organizações
107
+ ✅ POST /api/v1/dados-gov/search/transparency - Buscar dados transparência
108
+ ✅ GET /api/v1/dados-gov/analyze/{topic} - Analisar disponibilidade
109
+ ✅ GET /api/v1/dados-gov/spending-data - Dados de gastos
110
+ ✅ GET /api/v1/dados-gov/procurement-data - Dados de licitações
111
+ ```
112
+
113
+ ### 9. Exportação (`/api/v1/export/*`)
114
+ ```
115
+ ✅ POST /api/v1/export/csv - Exportar para CSV
116
+ ✅ POST /api/v1/export/json - Exportar para JSON
117
+ ✅ POST /api/v1/export/pdf - Exportar para PDF
118
+ ✅ POST /api/v1/export/markdown - Exportar para Markdown
119
+ ```
120
+
121
+ ### 10. Administração (`/api/v1/admin/*`)
122
+
123
+ #### Gestão de IP Whitelist
124
+ ```
125
+ ✅ GET /api/v1/admin/ip-whitelist - Listar IPs
126
+ ✅ POST /api/v1/admin/ip-whitelist - Adicionar IP
127
+ ✅ DELETE /api/v1/admin/ip-whitelist/{ip} - Remover IP
128
+ ```
129
+
130
+ #### Gestão de Cache
131
+ ```
132
+ ✅ POST /api/v1/admin/cache/warm - Aquecer cache
133
+ ✅ POST /api/v1/admin/cache/clear - Limpar cache
134
+ ✅ GET /api/v1/admin/cache/stats - Estatísticas
135
+ ```
136
+
137
+ #### Otimização de Banco de Dados
138
+ ```
139
+ ✅ POST /api/v1/admin/db/optimize - Otimizar DB
140
+ ✅ POST /api/v1/admin/db/vacuum - Vacuum DB
141
+ ✅ GET /api/v1/admin/db/stats - Estatísticas
142
+ ```
143
+
144
+ #### Compressão
145
+ ```
146
+ ✅ GET /api/v1/admin/compression/stats - Estatísticas
147
+ ✅ POST /api/v1/admin/compression/settings - Configurações
148
+ ```
149
+
150
+ #### Pools de Conexão
151
+ ```
152
+ ✅ GET /api/v1/admin/pools/stats - Estatísticas
153
+ ✅ POST /api/v1/admin/pools/reset - Reiniciar pools
154
+ ```
155
+
156
+ #### Lazy Loading de Agentes
157
+ ```
158
+ ✅ GET /api/v1/admin/agents/memory - Uso de memória
159
+ ✅ POST /api/v1/admin/agents/preload - Pré-carregar
160
+ ✅ POST /api/v1/admin/agents/unload - Descarregar
161
+ ```
162
+
163
+ ### 11. Gestão de API Keys (`/api/v1/api-keys/*`)
164
+ ```
165
+ ✅ POST /api/v1/api-keys/ - Criar API key
166
+ ✅ GET /api/v1/api-keys/ - Listar API keys
167
+ ✅ DELETE /api/v1/api-keys/{id} - Revogar API key
168
+ ```
169
+
170
+ ### 12. WebSocket
171
+ ```
172
+ 🔧 WS /api/v1/ws/chat - Chat em tempo real
173
+ 🔧 WS /api/v1/ws/investigations - Investigações em tempo real
174
+ ```
175
+
176
+ ### 13. Operações em Lote (`/api/v1/batch/*`)
177
+ ```
178
+ ✅ POST /api/v1/batch/investigations - Investigações em lote
179
+ ✅ POST /api/v1/batch/analysis - Análises em lote
180
+ ✅ GET /api/v1/batch/{id}/status - Status do lote
181
+ ```
182
+
183
+ ### 14. GraphQL
184
+ ```
185
+ 🔧 POST /graphql - Endpoint GraphQL
186
+ 🔧 GET /graphql - GraphQL Playground
187
+ ```
188
+
189
+ ### 15. Notificações (`/api/v1/notifications/*`)
190
+ ```
191
+ ✅ POST /api/v1/notifications/subscribe - Inscrever
192
+ ✅ POST /api/v1/notifications/send - Enviar
193
+ ✅ GET /api/v1/notifications/ - Listar
194
+ ```
195
+
196
+ ### 16. Métricas (`/api/v1/metrics/*`)
197
+ ```
198
+ ✅ GET /api/v1/metrics/agents - Métricas dos agentes
199
+ ✅ GET /api/v1/metrics/system - Métricas do sistema
200
+ ✅ GET /api/v1/metrics/business - Métricas de negócio
201
+ ```
202
+
203
+ ### 17. Visualização (`/api/v1/visualization/*`)
204
+ ```
205
+ ✅ POST /api/v1/visualization/chart - Gerar gráfico
206
+ ✅ POST /api/v1/visualization/dashboard - Criar dashboard
207
+ ✅ GET /api/v1/visualization/templates - Templates
208
+ ```
209
+
210
+ ### 18. Dados Geográficos (`/api/v1/geographic/*`)
211
+ ```
212
+ ✅ GET /api/v1/geographic/states - Estados
213
+ ✅ GET /api/v1/geographic/cities/{uf} - Cidades
214
+ ✅ POST /api/v1/geographic/heatmap - Mapa de calor
215
+ ```
216
+
217
+ ## ⚠️ Portal da Transparência - Status Limitado
218
+
219
+ ### Endpoints Funcionando (22%)
220
+ ```
221
+ ✅ Contratos - Requer parâmetro codigoOrgao
222
+ ✅ Servidores - Busca apenas por CPF
223
+ ✅ Órgãos - Informações das organizações
224
+ ```
225
+
226
+ ### Endpoints Bloqueados (78% retornam 403)
227
+ ```
228
+ ❌ Despesas
229
+ ❌ Fornecedores
230
+ ❌ Emendas parlamentares
231
+ ❌ Benefícios
232
+ ❌ Dados de salários/remuneração
233
+ ```
234
+
235
+ ## 🔧 Rotas Não Registradas (Arquivos existem mas não estão ativos)
236
+
237
+ 1. **auth_db.py** - Autenticação com banco de dados
238
+ 2. **chaos.py** - Engenharia do caos
239
+ 3. **chat_debug.py** - Debug do chat
240
+ 4. **debug.py** - Endpoints de debug
241
+ 5. **monitoring.py** - Monitoramento avançado (SLO/SLA)
242
+ 6. **webhooks.py** - Webhooks
243
+ 7. **websocket.py** - WebSocket adicional
244
+
245
+ ## 📈 Próximos Passos para Conectar Tudo
246
+
247
+ ### 1. Ativar Rotas Não Registradas
248
+ ```python
249
+ # Em src/api/app.py, adicionar:
250
+ from src.api.routes import webhooks, monitoring, debug
251
+ app.include_router(webhooks.router, prefix="/api/v1/webhooks")
252
+ app.include_router(monitoring.router, prefix="/api/v1/monitoring")
253
+ app.include_router(debug.router, prefix="/api/v1/debug")
254
+ ```
255
+
256
+ ### 2. Completar Integrações WebSocket
257
+ - Implementar streaming real-time para investigações
258
+ - Adicionar notificações push via WebSocket
259
+
260
+ ### 3. Finalizar GraphQL
261
+ - Completar schema GraphQL
262
+ - Adicionar resolvers para todas as entidades
263
+
264
+ ### 4. Melhorar Taxa de Sucesso do Portal da Transparência
265
+ - Investigar alternativas para endpoints bloqueados
266
+ - Implementar cache agressivo para dados disponíveis
267
+ - Adicionar fallback para dados sintéticos em desenvolvimento
268
+
269
+ ## 🚀 Como Testar Todos os Endpoints
270
+
271
+ ```bash
272
+ # 1. Instalar dependências de teste
273
+ pip install httpie
274
+
275
+ # 2. Testar saúde da API
276
+ http GET localhost:8000/health/
277
+
278
+ # 3. Criar usuário e fazer login
279
+ http POST localhost:8000/auth/register [email protected] password=senha123
280
+ http POST localhost:8000/auth/login [email protected] password=senha123
281
+
282
+ # 4. Testar chat com investigação
283
+ http POST localhost:8000/api/v1/chat/message \
284
+ message="Investigar contratos suspeitos do Ministério da Saúde" \
285
+ Authorization:"Bearer $TOKEN"
286
+
287
+ # 5. Buscar dados no dados.gov.br
288
+ http GET localhost:8000/api/v1/dados-gov/search \
289
+ query=saúde \
290
+ Authorization:"Bearer $TOKEN"
291
+ ```
292
+
293
+ ## 📱 Endpoints Mais Importantes para Frontend
294
+
295
+ 1. **Chat Principal**: `POST /api/v1/chat/message`
296
+ 2. **Investigações**: `POST /api/v1/investigations/start`
297
+ 3. **Relatórios**: `POST /api/v1/reports/generate`
298
+ 4. **Exportação**: `POST /api/v1/export/pdf`
299
+ 5. **Dados Abertos**: `GET /api/v1/dados-gov/search`