Skip to content

A Telegram bot that automatically categorizes financial transactions from receipts, bank statements (CSV/OFX) using AWS services. Extracts and parses data, categorizes expenses with AI, and provides structured output for easy spreadsheet integration.

License

Notifications You must be signed in to change notification settings

dinero-organizer/financial-categorizer-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Financial Categorizer Bot

Sobre

Bot do Telegram que recebe extratos bancários em CSV/OFX, faz o parsing, converte para um formato único de transações, envia ao Google Gemini para categorização e devolve um arquivo CSV com o resultado.

Sumário

Diagrama

flowchart TB
  user[Usuario<br/>Telegram] --> api[Telegram<br/>API]
  api --> bot[Bot<br/>python-telegram-bot]
  bot --> handler[handle_document]

  %% Download para tmp e computa hash
  handler --> tmp[Armazenamento<br/>temporario]
  handler --> hash[SHA-256<br/>do arquivo]

  %% Verifica cache S3
  hash --> cache{Cache S3<br/>chave: user_id e hash}
  cache -->|Sim| get[Baixar CSV<br/>do cache]
  get --> reply[reply_<br/>document]

  %% Se nao estiver em cache, processa normally
  cache -->|Nao| parser{Tipo do<br/>arquivo}
  parser -->|CSV| csv[parse_csv_bank_<br/>statement]
  parser -->|OFX| ofx[parse_ofx_<br/>file]
  csv --> stmt[ParsedBank<br/>Statement]
  ofx --> stmt
  stmt --> map[Mapear p/ JSON<br/>de transacoes]
  map --> ai[Gemini<br/>categorize_with_gemini]
  ai --> result[CSV<br/>categorizado]
  result --> put[Upload CSV<br/>p/ cache S3]
  result --> reply

  subgraph Ambiente
    env[Vars<br/>BOT_TOKEN_TELEGRAM<br/>GOOGLE_API_KEY<br/>DEBUG<br/>APP_ENV<br/>S3_BUCKET_UPLOADS]
    log[Logging]
    clean[Remocao de<br/>temporarios]
  end
  env -.-> bot
  clean -.-> tmp
  log -.-> handler

  classDef small font-size:12px;
  class bot,handler,tmp,csv,ofx,stmt,map,ai,result,reply,env,clean,hash,cache,get,put small;
Loading

Infraestrutura AWS

Infraestrutura AWS

About

A Telegram bot that automatically categorizes financial transactions from receipts, bank statements (CSV/OFX) using AWS services. Extracts and parses data, categorizes expenses with AI, and provides structured output for easy spreadsheet integration.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 8