# freddysongg/cafexpress architecture

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

- Interactive diagram: https://gitdiagram.com/freddysongg/cafexpress
- Repository: https://github.com/freddysongg/cafexpress

## Overview

##### Project Type and Purpose
- This project is a full-stack application that provides AI-powered café recommendations and itinerary planning for café enthusiasts.
- The system leverages user data, sentiment analysis, and external APIs (Google Places and Yelp Fusion) to provide personalized recommendations, while also supporting user profiles and networking.

##### File Structure to Determine Architectural Components
- The top-level directories separate concerns clearly:
- /frontend: Contains a React-driven application (using Vite, TypeScript, Tailwind, etc.) which handles the user interface and user interactions.
- /backend: A Node.js-based server (written in TypeScript) with further modular organization:
- The src/ directory breaks down various technical aspects:
▪ /config: Database, Redis, and other configuration files.
▪ /routes: API endpoints for authentication, café data, review generation, recommendations, user profiles, preferences, etc.
▪ /services: Business logic implementations, including integration with external APIs and internal recommendation logic.
▪ /schemas and /middleware: Used to validate requests, define data models, and secure endpoints.
▪ /drizzle: Contains SQL migration files and metadata that relate to PostgreSQL database interactions.
▪ /utils: Utility methods for logging, math, scoring, similarity, and validation.
- Configuration files (in the root and inside backend and frontend) and documentation files (under backend/docs) support CI/CD (via GitHub actions) and code quality (linting, formatting).

##### README for Additional Insights
- The README confirms that the frontend is built using React and deployed on Vercel.
- The backend is powered by Node.js (with hints of Python/Flask mentioned in the README, though file contents show a TypeScript-based Node.js service – treat this as an integration note or possible multi-language backend).
- The project uses PostgreSQL as its primary database, and external integrations include Google Places and Yelp Fusion APIs.
- Additional integrations include Redis (as seen in config and likely for caching) and a containerized environment (Dockerfiles, docker-compose in backend).

## Diagram (Mermaid)

```mermaid
flowchart TD
    F["React Frontend (Deployed on Vercel)"]:::frontend
    BE["Node.js Backend API"]:::backend
    F -->|"HTTP/REST"| BE

    subgraph "Backend Components"
        AR["API Routes"]:::routes
        MW["Middleware"]:::middleware
        BL["Business Logic / Services"]:::services
        CN["Configurations"]:::config
        SC["Data Validation & Schemas"]:::schemas
        UT["Utilities"]:::utils
    end

    BE -->|"routes"| AR
    AR -->|"uses"| MW
    MW -->|"invokes"| BL
    BL -->|"logs & utils"| UT

    BL -->|"queries"| DB["PostgreSQL DB (Drizzle Migrations)"]:::database
    BL -->|"caches"| RC["Redis Cache"]:::redis
    BL -->|"fetches"| GP["Google Places API"]:::external
    BL -->|"fetches"| YF["Yelp Fusion API"]:::external

    CI["CI/CD Workflows (GitHub Actions)"]:::cicd
    CI -->|"deploys"| BE
    CI -->|"builds"| F

    %% Click Events
    click F "https://github.com/freddysongg/cafexpress/tree/production//frontend"
    click BE "https://github.com/freddysongg/cafexpress/blob/production//backend/src/app.ts"
    click BE "https://github.com/freddysongg/cafexpress/blob/production//backend/src/server.ts"
    click AR "https://github.com/freddysongg/cafexpress/tree/production//backend/src/routes"
    click BL "https://github.com/freddysongg/cafexpress/tree/production//backend/src/services"
    click CN "https://github.com/freddysongg/cafexpress/tree/production//backend/src/config"
    click SC "https://github.com/freddysongg/cafexpress/tree/production//backend/src/schemas"
    click MW "https://github.com/freddysongg/cafexpress/tree/production//backend/src/middleware"
    click UT "https://github.com/freddysongg/cafexpress/tree/production//backend/src/utils"
    click DB "https://github.com/freddysongg/cafexpress/tree/production//backend/drizzle"
    click RC "https://github.com/freddysongg/cafexpress/tree/production//backend/src/config"
    click CI "https://github.com/freddysongg/cafexpress/tree/production//.github/workflows"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef routes fill:#FFFACD,stroke:#000,stroke-width:1px;
    classDef middleware fill:#FFDAB9,stroke:#000,stroke-width:1px;
    classDef services fill:#E6E6FA,stroke:#000,stroke-width:1px;
    classDef config fill:#F0E68C,stroke:#000,stroke-width:1px;
    classDef schemas fill:#FAFAD2,stroke:#000,stroke-width:1px;
    classDef utils fill:#F5DEB3,stroke:#000,stroke-width:1px;
    classDef database fill:#FFB6C1,stroke:#000,stroke-width:1px;
    classDef redis fill:#FFE4B5,stroke:#000,stroke-width:1px;
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5;
    classDef cicd fill:#D8BFD8,stroke:#000,stroke-width:1px;
```
