The Eco-It recycling map lets any registered user locate nearby collection infrastructure across the city of Garzón, Colombia. Admins manage this map through a full CRUD API backed by theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/vanegasjoseignacio2-cyber/Eco-It/llms.txt
Use this file to discover all available pages before exploring further.
PuntoReciclaje MongoDB model. Unlike the public-facing endpoint — which only returns points that are both activo: true and visibleToUser: true — the admin endpoints always return every point regardless of its flags, giving administrators a complete view of both published and hidden infrastructure.
Every write operation (create, update, delete, toggle) emits a map:updated Socket.io event to all connected clients, so the public map refreshes in real time for every user currently viewing it without needing to reload the page.
All admin map endpoints are protected by both
verificarToken (JWT validation) and soloAdmin (role check). Calls without a valid admin or superadmin token return 403 Forbidden.Point Types
Eco-It supports five point types, each rendered with a distinct colour and icon on the Leaflet map:tipo value | Label | Colour |
|---|---|---|
recycling | Punto de Reciclaje | #22c55e (green) |
ecobottle | Eco-Botella | #84cc16 (lime) |
truck | Carro Recolector | #14b8a6 (teal) |
container | Contenedor | #10b981 (emerald) |
green_zone | Zona Verde | #4ade80 (light green) |
Point Model Fields
Display name of the collection point. Shown in map popups and the admin sidebar list.
Point category. One of:
recycling, ecobottle, truck, container, green_zone. Defaults to "recycling".WGS-84 latitude coordinate. The admin map UI constrains the viewable area to the Garzón bounding box (
[2.140, -75.690] → [2.240, -75.560]), but the API accepts any valid latitude.WGS-84 longitude coordinate.
Optional free-text description: schedules, accepted materials, special instructions. Displayed in map popups.
Cloudinary
secure_url for a photo of the point. Empty string when no image has been uploaded. The frontend renders images via the Cloudinary React SDK for automatic format and quality optimisation.Master visibility switch. When
false, the point does not appear on the public map and is excluded from the map:updated socket broadcast payload.Secondary visibility flag. A point must have both
activo: true and visibleToUser: true to appear in the public endpoint (GET /api/puntos/public). Admins see points with any combination of these flags.activo vs visibleToUser
Both flags control public visibility, but they serve different purposes:
activois the operational switch. Setting it tofalsemeans the infrastructure is temporarily offline (e.g., a collection truck is not running today). Use the toggle endpoint to flip it quickly.visibleToUseris a publishing control. A point can beactivo: truebutvisibleToUser: falseif it has been created and is being reviewed before going live, or if it should only be visible to administrators for planning purposes.
activo AND visibleToUser. The admin endpoint returns all points unconditionally.API Endpoints
List All Points (Admin)
Returns every recycling point in the database, including inactive and hidden ones, sorted bycreatedAt descending.
Create a Point
Creates a newPuntoReciclaje document. If the imagen field is a non-empty string, the controller uploads it to Cloudinary (folder ecoit_map_points) and stores the returned secure_url instead. After saving, emits map:updated to all clients with the refreshed list of active, visible points.
Name of the collection point.
Point category. Must be one of
recycling, ecobottle, truck, container, green_zone.Latitude (WGS-84 decimal degrees).
Longitude (WGS-84 decimal degrees).
Optional description or instructions.
A base64 data URI (e.g.
data:image/jpeg;base64,...) to upload. Any non-empty value is uploaded to Cloudinary and the field is replaced with the resulting secure_url. Leave empty or omit to store no image.Whether the point is operationally active.
Whether the point should appear on the public map.
Update a Point
Updates one or more fields of an existing point. Supply only the fields you want to change. Ifimagen is provided as a base64 data URI starting with "data:image", the controller uploads it to Cloudinary and replaces the field value with the resulting URL. Emits map:updated after saving.
Delete a Point
Permanently removes the point document from MongoDB. The deletion is irreversible. Emitsmap:updated immediately after so users’ maps stop showing the removed point.
Toggle Active State
Flips theactivo boolean of a point without requiring a full update payload. Equivalent to activo = !activo. This is the fastest way to temporarily hide or re-publish a point. Emits map:updated after saving.
Image Uploads with Cloudinary
Eco-It uses Cloudinary to host all map point images. You do not need to interact with Cloudinary directly — the backend handles the upload transparently.How it works:
- The frontend reads the selected image file as a base64 data URI using
FileReader. - The data URI is sent in the
imagenfield of the create or update request body. - For create (
POST), any non-emptyimagenvalue is passed tocloudinary.uploader.upload(imagen, { folder: "ecoit_map_points" }). For update (PATCH), the controller only uploads when the value starts withdata:image; an existing Cloudinary URL is stored as-is. - The
secure_urlfrom Cloudinary’s response is stored in theimagenfield of the database document. - Subsequent reads return the Cloudinary CDN URL, which the React frontend renders via the
@cloudinary/reactAdvancedImagecomponent for automatic WebP conversion and responsive quality.
PATCH), if you supply a full Cloudinary URL (from a previous upload) in the imagen field, the controller stores it as-is without re-uploading (it only uploads values that start with data:image). For new points (POST), any non-empty imagen value is uploaded to Cloudinary.Frontend Map Component
TheAdminMap.jsx component renders the admin map panel using Leaflet + OpenStreetMap (no API key required). The map is constrained to the Garzón metropolitan area via maxBounds and a minZoom of 13.
Key interactions available in the UI:
Click 'Nuevo Punto'
Opens the form panel on the right side of the map. Fill in the name, type, description, optional image, and coordinates.
Pick coordinates from the map
Click the Seleccionar desde el mapa button to enter placement mode. The cursor changes to a crosshair. Clicking anywhere on the map captures the latitude and longitude into the form automatically.
Save
Clicking Crear punto calls
POST /api/admin/map/points. On success, the new marker appears on the map immediately for all users.