# ritog09/planova architecture

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

- Interactive diagram: https://gitdiagram.com/ritog09/planova
- Repository: https://github.com/ritog09/planova

## Overview

##### Main Components
- Frontend: The structure within the “frontend” directory clearly shows a React.js application that uses Tailwind CSS. It has dedicated pages (for signing in/up, new trip creation, trip history, viewing trips), utility folders, and component libraries.
- Backend/API: The “api” directory is a Node.js/Express.js service. It includes controllers for authentication and trips, middleware for JSON Web Tokens, models for users and trips (which likely map to MongoDB collections), and organized routes.
- Database: Planova uses MongoDB as indicated in the README. This can be represented as a separate data storage component.
- External Services: Highlight integrations with the Google Places API and Gemini AI API (as well as the Photo API for real-time images). These should be shown as external systems interacting with the backend.
- Additional Components: Although not explicitly seen as separate services, the environment configuration (.env) and utility modules indicate support services (error handling, configuration, etc.) that are part of the backend’s infrastructure.

##### Diagraming the Interactions and Flow
- A clear separation between “Frontend” and “Backend”:
- Frontend (React application) handles user interactions, displays AI trip planning, and communicates with the backend through API calls.
- Within the Backend, break down the modules:
- Controllers (authController, tripController): These handle request processing.
- Middleware (JWT handling): Secure endpoints and control access.
- Models (user.model.js, trip.model.js): Represent database schemas.
- Routes: Connect endpoints to corresponding controllers.
- Utilities (error handling): Support debugging and error management.
- Connections from the Backend to External APIs:
- Google Places API for obtaining location data.
- Gemini AI API for AI-powered itinerary generation.
- A connection to a Photo API (as described in the README).
- ISOLATION of configuration details (.env) which influence how components interact (API keys, database URI, JWT key).

##### Representing Technical Stack & Architectural Patterns
- "React Frontend" for the client-facing application.
- "Express.js Server" for the backend logic.
- "External APIs" for Google Places, Gemini AI, and Photo API.
- Frontend sends HTTP requests to the backend (sign up, signing in, fetching trip data).
- Backend communicates with MongoDB for data operations.
- Backend makes API calls to external services to fetch or process AI recommendations.
- Patterns: The typical Model-View-Controller (MVC) pattern in the backend can be annotated (models, controllers, routes) as well as the separation of concerns between the presentation layer (React) and backend API logic.

##### Additional Details for the Engineer
- Configuration aspects where necessary, especially indicating the role of environment variables in connecting to external systems (such as API keys and URI strings).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    UB["User Browser"]:::default

    %% Frontend Layer
    subgraph "Frontend"
        RF["React Frontend"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend"
        ES["Express.js API Server"]:::backend
        %% Backend Modules
        subgraph "Backend Modules"
            AR["Auth Routes"]:::module
            TC["Trip Routes"]:::module
            AC["Authentication Controller"]:::module
            TRC["Trip Controller"]:::module
            JWT["JWT Middleware"]:::module
            UM["User Model"]:::module
            TM["Trip Model"]:::module
            EH["Error Handling Utility"]:::module
            ENV["Environment Configuration"]:::module
        end
    end

    %% External Services and Database
    MDB["MongoDB Database"]:::database
    GPA["Google Places API"]:::external
    GAI["Gemini AI API"]:::external
    PA["Photo API"]:::external

    %% Connections
    UB -->|"visits"| RF
    RF -->|"APIcall"| ES

    %% Backend internal connections
    ES -->|"routes"| AR
    ES -->|"routes"| TC
    ES -->|"config"| JWT
    ES -->|"config"| EH
    ES -->|"config"| ENV
    AR -->|"handles"| AC
    TC -->|"handles"| TRC
    ES -->|"data"| UM
    ES -->|"data"| TM

    %% External connections from Express Server
    ES -->|"CRUD"| MDB
    ES -->|"fetch"| GPA
    ES -->|"fetch"| GAI
    ES -->|"fetch"| PA

    %% Styling Classes
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#ffe5b4,stroke:#ff8c00,stroke-width:2px;
    classDef external fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef module fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef default fill:#ffffff,stroke:#000000,stroke-width:1px;

    %% Click Events
    click RF "https://github.com/ritog09/planova/tree/main/frontend/"
    click ES "https://github.com/ritog09/planova/tree/main/api/"
    click AC "https://github.com/ritog09/planova/blob/main/api/controllers/authController.js"
    click TRC "https://github.com/ritog09/planova/blob/main/api/controllers/tripController.js"
    click JWT "https://github.com/ritog09/planova/blob/main/api/middleware/jwt.js"
    click UM "https://github.com/ritog09/planova/blob/main/api/models/user.model.js"
    click TM "https://github.com/ritog09/planova/blob/main/api/models/trip.model.js"
    click AR "https://github.com/ritog09/planova/blob/main/api/routes/auth.route.js"
    click TC "https://github.com/ritog09/planova/blob/main/api/routes/trip.route.js"
    click EH "https://github.com/ritog09/planova/blob/main/api/utils/createError.js"
    click ENV "https://github.com/ritog09/planova/blob/main/api/.env"
```
