# nahiavazquez/globetrek architecture

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

- Interactive diagram: https://gitdiagram.com/nahiavazquez/globetrek
- Repository: https://github.com/nahiavazquez/globetrek

## Overview

##### Main Components
a. Frontend (User Interface)
- Represented by the “globetrek” directory.
- Built using React (with supporting files like package.json, public folder, and numerous components including login & registration flows).
- Interacts with the backend via the Gateway.

b. Gateway
- Found in the “gateway” directory.
- Acts as a central routing point (using FastAPI with uvicorn on port 8888 as per launch command).
- Routes API requests to the respective microservices.

c. Microservices (Backend):
- Microservice for User Management:
- Located in “backend”.
- Uses FastAPI to provide RESTful endpoints.
- Uses PostgreSQL (as per README mentions) for storage.
- Contains CRUD operations for users, authentication tokens, and schema definitions.
- Microservice for Itinerary and Destination Management:
- Found in “nodeAPI”.
- Created with Node.js (based on package.json, Dockerfile, and usage instructions).
- Uses MongoDB for itinerary and destination collections.
- Also integrates with Ollama (external service) for generating personalized itineraries.

d. External Dependencies and Infrastructure:
- Databases: PostgreSQL (for users) and MongoDB (for itineraries and destinations).
- Ollama: External AI model for custom itinerary generation.
- Docker & Docker Compose: Containers are used to deploy the various components.
- Additional tools like Python, NodeJS are noted in the README for local development.

##### Relationships and Interactions
- The Frontend sends requests to the Gateway.
- The Gateway then forwards these requests to the appropriate microservice:
- User requests are forwarded to the FastAPI-based user management service (backend).
- Itinerary and destination requests are sent to the Node.js service (nodeAPI).
- Each microservice accesses its corresponding database (e.g., PostgreSQL for users, MongoDB for itineraries/destinations).
- When a user requests a personalized itinerary, the backend interacts with the external Ollama service to process or generate itinerary details.

##### Architectural Patterns and Design Principles
- Microservices architecture: The separation of functionalities into distinct deployable services.
- API Gateway Pattern: The use of a gateway to abstract and route client requests to the correct microservice.
- Containerization: Use of Docker and related deployment files (Dockerfile in several directories, docker-compose.yaml) to ensure portability and environment consistency.
- Separation of concerns: Each service (backend, nodeAPI, gateway, and frontend) handles distinct responsibilities.

##### Relevant Technologies, Frameworks, and Libraries
- Backend: FastAPI (Python) and uvicorn; PostgreSQL.
- Itineraries/Destinations Service: Node.js, Express (likely from the use of package.json), and MongoDB.
- Frontend: React (with JavaScript/TypeScript components, yarn for package management).
- Docker: Containerization (with Dockerfiles and docker-compose setup).
- External Software: Ollama (for AI-based itinerary customization).

##### Specific Elements
- “Frontend (React)” for the UI.
- “API Gateway (FastAPI)” – label its role in routing.
- “User Service (FastAPI)” – label and note its dependency on PostgreSQL.
- “Itinerary & Destination Service (Node.js)” – note its dependency on MongoDB.
- “Ollama Service” – as an external service for generating personalized itineraries.
- Containers for each microservice (possibly encapsulated in Docker containers).
- Database servers vs. application services.
- Annotations for protocols or ports can be added (e.g., HTTP, port 8000 for user management, port 8888 for the gateway).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        FE["Frontend (React UI)"]:::frontend
        click FE "https://github.com/nahiavazquez/globetrek/tree/main/GlobeTrek/globetrek"
    end

    %% API Routing Layer
    subgraph "API Routing"
        GW["API Gateway (FastAPI)"]:::gateway
        click GW "https://github.com/nahiavazquez/globetrek/tree/main/GlobeTrek/gateway"
    end

    %% Backend Services Layer
    subgraph "Backend Services"
        US["User Service (FastAPI)"]:::service
        click US "https://github.com/nahiavazquez/globetrek/tree/main/GlobeTrek/backend"
        ID["Itinerary & Destination Service (Node.js)"]:::service
        click ID "https://github.com/nahiavazquez/globetrek/tree/main/GlobeTrek/nodeAPI"
    end

    %% Data Layer
    subgraph "Data Layer"
        DB1["PostgreSQL (User DB)"]:::db
        DB2["MongoDB (Itinerary & Destination DB)"]:::db
    end

    %% External Services
    subgraph "External Services"
        OLL["Ollama Service"]:::external
    end

    %% Connections between layers
    FE -->|"HTTP"| GW
    GW -->|"user_requests"| US
    GW -->|"itinerary_destination_requests"| ID
    US -->|"CRUD_operations"| DB1
    ID -->|"data_operations"| DB2
    ID -->|"generate_itinerary"| OLL

    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef gateway fill:#ffa07a,stroke:#000,stroke-width:2px;
    classDef service fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef db fill:#f0e68c,stroke:#000,stroke-width:2px;
    classDef external fill:#ffb6c1,stroke:#000,stroke-width:2px;
```
