# manuurc12-hash/examen-segundo-parcial---manejo-de-datos architecture

> Architecture diagram of the GitHub repository manuurc12-hash/examen-segundo-parcial---manejo-de-datos, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos
- Repository: https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos

## Overview

This repository processes sales data into category-and-month revenue totals, with a sequential implementation and separate Hadoop-style mapper/reducer scripts. Loader scripts import processed output into PostgreSQL, which a FastAPI service exposes through read and write endpoints. The source excerpts do not show a job orchestrator wiring the mapper to the reducer, so that connection is omitted; the README is empty.

Main entry points: [`app/mapper.py`](https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/mapper.py) (Revenue mapper), [`app/reducer.py`](https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/reducer.py) (Revenue reducer), [`app/cargar_resultados.py`](https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/cargar_resultados.py) (File results loader), [`app/cargar_directo.py`](https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/cargar_directo.py) (Direct file loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_aggregation["Revenue aggregation"]
  node_mapper["Revenue mapper<br/>[mapper.py]"]
  node_reducer["Revenue reducer<br/>[reducer.py]"]
  node_sequential["Sequential aggregator<br/>[secuencial.py]"]
end

subgraph group_loading["Result loading"]
  node_load_results["File results loader"]
  node_load_direct["Direct file loader<br/>[cargar_directo.py]"]
  node_load_hadoop["Hadoop loader"]
  node_database[("PostgreSQL results")]
end

subgraph group_service["Results API"]
  node_api["Results API<br/>[main.py]"]
end

node_operator(("Data operator"))
node_csv_stream["CSV input stream"]
node_result_file["MapReduce output file"]
node_hadoop_output["Hadoop output"]

node_operator -->|"requests"| node_api
node_api -->|"reads and writes"| node_database
node_csv_stream -->|"reads stream"| node_mapper
node_mapper -.->|"emits records"| node_reducer
node_reducer -.->|"emits totals"| node_result_file
node_csv_stream -->|"reads CSV"| node_sequential
node_result_file -->|"reads records"| node_load_results
node_result_file -->|"reads records"| node_load_direct
node_hadoop_output -->|"reads output"| node_load_hadoop
node_load_results -->|"inserts rows"| node_database
node_load_direct -->|"inserts rows"| node_database
node_load_hadoop -->|"inserts rows"| node_database

click node_mapper "https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/mapper.py"
click node_reducer "https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/reducer.py"
click node_sequential "https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/secuencial.py"
click node_load_results "https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/cargar_resultados.py"
click node_load_direct "https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/cargar_directo.py"
click node_load_hadoop "https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/cargar_definitivo.py"
click node_api "https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/main.py"

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_mapper,node_reducer,node_sequential toneBlue
class node_load_results,node_load_direct,node_load_hadoop,node_database toneAmber
class node_api toneMint
class node_operator,node_csv_stream,node_result_file,node_hadoop_output toneIndigo
```

## Components

### Revenue aggregation

- [Revenue mapper](https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/mapper.py): `app/mapper.py`
- [Revenue reducer](https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/reducer.py): `app/reducer.py`
- [Sequential aggregator](https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/secuencial.py): `app/secuencial.py`

### Result loading

- [File results loader](https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/cargar_resultados.py): `app/cargar_resultados.py`
- [Direct file loader](https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/cargar_directo.py): `app/cargar_directo.py`
- [Hadoop loader](https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/cargar_definitivo.py): `app/cargar_definitivo.py`
- **PostgreSQL results**

### Results API

- [Results API](https://github.com/manuurc12-hash/examen-segundo-parcial---manejo-de-datos/blob/main/app/main.py): `app/main.py`

### Other components

- **Data operator**
- **CSV input stream**
- **MapReduce output file**
- **Hadoop output**

## Connections

- Data operator → Results API: requests (evidence: `app/main.py`)
- Results API → PostgreSQL results: reads and writes (evidence: `app/main.py`)
- CSV input stream → Revenue mapper: reads stream (evidence: `app/mapper.py`)
- Revenue mapper → Revenue reducer: emits records
- Revenue reducer → MapReduce output file: emits totals
- CSV input stream → Sequential aggregator: reads CSV (evidence: `app/secuencial.py`)
- MapReduce output file → File results loader: reads records (evidence: `app/cargar_resultados.py`)
- MapReduce output file → Direct file loader: reads records (evidence: `app/cargar_directo.py`)
- Hadoop output → Hadoop loader: reads output (evidence: `app/cargar_definitivo.py`)
- File results loader → PostgreSQL results: inserts rows (evidence: `app/cargar_resultados.py`)
- Direct file loader → PostgreSQL results: inserts rows (evidence: `app/cargar_directo.py`)
- Hadoop loader → PostgreSQL results: inserts rows (evidence: `app/cargar_definitivo.py`)
