# joacdc/ecoloop- architecture

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

- Interactive diagram: https://gitdiagram.com/joacdc/ecoloop-
- Repository: https://github.com/joacdc/ecoloop-

## Overview

##### Project type and purpose
- Ecoloop is a containerized full-stack web application for managing and visualizing recycling container locations.
- Frontend: HTML/CSS/JavaScript served from Flask templates and static files.
- Backend: Python + Flask providing a CRUD API for “Contenedor” objects.
- Database: MongoDB (NoSQL document store).
- Infrastructure: Docker Compose orchestrating a Flask container and a MongoDB container.
- External service: Google Maps API for map display.

##### File structure
- Top-level:
- README.md (project overview)
- docker-compose.yml (defines services: app, mongod)
- app/ folder:
- Dockerfile (builds the Flask app image)
- connection.py (MongoClient setup)
- Contenedor.py & Ubicacion.py (domain/business logic classes)
- app.py (Flask application entrypoint, route definitions)
- requeriments.txt (Python dependencies)
- static/ (JS, CSS assets)
- templates/ (Jinja2 HTML templates: index, CRUD forms)

##### README for additional insights
- Confirms technology stack: Flask, MongoDB, Docker Compose, Google Maps API.
- Details the user flows: map visualization, CRUD on containers.
- Specifies host: localhost:5000.

##### Main components and relationships
a. Components
- Browser (client)
- Frontend assets (HTML templates, CSS, JS)
- Flask backend
- Business logic modules (Contenedor, Ubicacion)
- MongoDB database
- Google Maps API (external)
- Docker Compose network
b. Interactions
1. User opens browser → sends HTTP request to Flask on port 5000.
2. Flask routes render Jinja2 templates and/or serve JSON data.
3. Backend calls business logic (Contenedor.Ubicacion) → uses connection.py to query/update MongoDB.
4. Frontend JS calls Google Maps API to fetch map tiles and geolocation data.
5. Docker network isolates and connects the Flask and MongoDB containers.
c. Architectural patterns
- Layered MVC-style separation:
– Model: Contenedor.py & Ubicacion.py + MongoDB
– View: Jinja2 templates + static assets
– Controller: Flask route handlers in app.py
- Containerization: one service per container, networked via Docker Compose.
d. Key technologies
- Python 3 + Flask
- PyMongo / MongoClient
- Docker & Docker Compose
- Google Maps API
- HTML5, CSS3, vanilla JavaScript

## Diagram (Mermaid)

```mermaid
flowchart TB
    classDef backend fill:#cce5ff,stroke:#000;
    classDef datastore fill:#d4edda,stroke:#060;
    classDef external fill:#ffe5b4,stroke:#a60;
    classDef client fill:#e2e3e5,stroke:#666;

    Browser["Browser"]:::client
    GoogleMaps["Google Maps API"]:::external

    subgraph "Docker Compose"
        direction TB

        subgraph "Flask App Container"
            direction TB
            AppPy["app.py\n(Flask Routes)"]:::backend
            Contenedor["Contenedor.py"]:::backend
            Ubicacion["Ubicacion.py"]:::backend
            Connection["connection.py"]:::backend
            Reqs["requeriments.txt"]:::backend

            subgraph "Templates"
                direction TB
                Index["index.html"]:::backend
                Agregar["agregar_contenedor.html"]:::backend
                Editar["editar_contenedor.html"]:::backend
                Eliminar["eliminar_contenedor.html"]:::backend
            end

            subgraph "Static Assets"
                direction TB
                Script["script.js"]:::backend
                Style["style.css"]:::backend
                StyleAdd["style_agregar_contenedor.css"]:::backend
            end
        end

        subgraph "MongoDB Container"
            DB["MongoDB\n(collection: contenedores)"]:::datastore
        end
    end

    Browser -->|HTTP 5000| AppPy
    AppPy --> Contenedor
    AppPy --> Ubicacion
    AppPy --> Connection
    Connection -->|TCP 27017| DB
    AppPy -->|serves| Index
    AppPy -->|serves| Agregar
    AppPy -->|serves| Editar
    AppPy -->|serves| Eliminar
    Browser -->|loads JS/CSS| Script
    Browser -->|loads CSS| Style
    Browser -->|loads CSS| StyleAdd
    Browser -->|renders HTML| Index
    Browser -->|renders HTML| Agregar
    Browser -->|renders HTML| Editar
    Browser -->|renders HTML| Eliminar
    Browser -->|JS calls| GoogleMaps

    click Index "https://github.com/joacdc/ecoloop-/blob/main/app/templates/index.html"
    click Agregar "https://github.com/joacdc/ecoloop-/blob/main/app/templates/agregar_contenedor.html"
    click Editar "https://github.com/joacdc/ecoloop-/blob/main/app/templates/editar_contenedor.html"
    click Eliminar "https://github.com/joacdc/ecoloop-/blob/main/app/templates/eliminar_contenedor.html"
    click Script "https://github.com/joacdc/ecoloop-/blob/main/app/static/JS/script.js"
    click Style "https://github.com/joacdc/ecoloop-/blob/main/app/static/style.css"
    click StyleAdd "https://github.com/joacdc/ecoloop-/blob/main/app/static/style_agregar_contenedor.css"
    click AppPy "https://github.com/joacdc/ecoloop-/blob/main/app/app.py"
    click Contenedor "https://github.com/joacdc/ecoloop-/blob/main/app/Contenedor.py"
    click Ubicacion "https://github.com/joacdc/ecoloop-/blob/main/app/Ubicacion.py"
    click Connection "https://github.com/joacdc/ecoloop-/blob/main/app/connection.py"
    click Reqs "https://github.com/joacdc/ecoloop-/blob/main/app/requeriments.txt"
    click Dockerfile "https://github.com/joacdc/ecoloop-/tree/main/app/Dockerfile"
    click Compose "https://github.com/joacdc/ecoloop-/blob/main/docker-compose.yml"
    click Readme "https://github.com/joacdc/ecoloop-/blob/main/README.md"

    class Browser client
    class GoogleMaps external
    class AppPy,Contenedor,Ubicacion,Connection,Reqs backend
    class DB datastore
    class Index,Agregar,Editar,Eliminar,Script,Style,StyleAdd backend
```
