# paultibe/cruz architecture

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

- Interactive diagram: https://gitdiagram.com/paultibe/cruz
- Repository: https://github.com/paultibe/cruz

## Overview

##### Main Components

Frontend Layer:
- Next.js Application (Primary client-side component)
- Pages: Home, Login, Ride, Swipe, and History
- Components directory for reusable elements
- PWA capabilities (due to presence of sw.js and manifest.json)

Backend Layer:
- TypeScript Server
- Endpoints directory, specifically Google Places integration
- Custom endpoints under 'others' directory

External Services:
- Firebase (indicated by firebase.ts in frontend/lib)
- Google Places API (indicated by google-places.ts endpoint)

##### Relationships and Data Flow

- Client-Server Communication:
→ Frontend to Backend API endpoints
→ Backend to Google Places API
→ Frontend to Firebase services directly

##### Specific Implementation Details

- Blue: Frontend components (Next.js pages and components)
- Green: Backend services (TypeScript server)
- Orange: External services (Firebase, Google Places)
- Purple: API endpoints and data flow

##### Architecture Patterns to Highlight

- Client-Server Architecture
- Progressive Web App Architecture (PWA)
- Microservices-like approach with separate frontend/backend
- API-First Design

##### Technical Stack Indicators

Technology badges or labels for:
- Next.js
- TypeScript
- Firebase
- Google Places API
- Tailwind CSS (noted from configuration files)

##### Deployment Flow

A deployment section showing:
- Vercel deployment (indicated by vercel.json)
- Frontend/Backend separation

**[Client Layer (Next.js + PWA)]**
- ↕
**[API Layer (TypeScript Backend)]**
- ↕
**[External Services Layer]**

Special Considerations:

##### PWA Features
- Service worker architecture
- Offline capabilities
- Manifest integration

##### Authentication Flow
- Firebase auth integration
- Login page flow

##### Data Flow
- Ride-related data flow
- History tracking
- Swipe functionality

Remember to:
- Keep components modular and clearly separated
- Clear boundaries between frontend, backend, and external services
- Notes for key architectural decisions
- Scalability points
- Security boundaries and authentication flows

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        NextApp["Next.js Application"]
        click NextApp "https://github.com/paultibe/cruz/tree/main/frontend/app/"
        
        subgraph Pages
            Home["Home Page"]
            click Home "https://github.com/paultibe/cruz/blob/main/frontend/app/page.tsx"
            Login["Login Page"]
            click Login "https://github.com/paultibe/cruz/blob/main/frontend/app/login/page.tsx"
            Ride["Ride Page"]
            click Ride "https://github.com/paultibe/cruz/blob/main/frontend/app/ride/page.tsx"
            Swipe["Swipe Page"]
            click Swipe "https://github.com/paultibe/cruz/blob/main/frontend/app/swipe/page.tsx"
            History["History Page"]
            click History "https://github.com/paultibe/cruz/blob/main/frontend/app/history/page.tsx"
        end
        
        Components["Reusable Components"]
        click Components "https://github.com/paultibe/cruz/tree/main/frontend/app/components/"
        
        PWA["PWA Features"]
        ServiceWorker["Service Worker"]
        click ServiceWorker "https://github.com/paultibe/cruz/blob/main/frontend/public/sw.js"
        Manifest["PWA Manifest"]
        click Manifest "https://github.com/paultibe/cruz/blob/main/frontend/public/manifest.json"
        
        Styles["Global Styles"]
        click Styles "https://github.com/paultibe/cruz/blob/main/frontend/app/globals.css"
        TailwindConfig["Tailwind Config"]
        click TailwindConfig "https://github.com/paultibe/cruz/blob/main/frontend/tailwind.config.ts"
        
        FirebaseClient["Firebase Client"]
        click FirebaseClient "https://github.com/paultibe/cruz/blob/main/frontend/lib/firebase.ts"
    end
    
    subgraph Server
        TSServer["TypeScript Server"]
        click TSServer "https://github.com/paultibe/cruz/blob/main/backend/src/server.ts"
        
        GooglePlacesAPI["Google Places Integration"]
        click GooglePlacesAPI "https://github.com/paultibe/cruz/blob/main/backend/src/endpoints/google-places.ts"
        
        OtherEndpoints["Additional Endpoints"]
        click OtherEndpoints "https://github.com/paultibe/cruz/tree/main/backend/src/others/"
    end
    
    subgraph ExternalServices
        Firebase[(Firebase Services)]
        GooglePlaces[(Google Places API)]
    end
    
    subgraph Deployment
        Vercel["Vercel Deployment"]
        click Vercel "https://github.com/paultibe/cruz/blob/main/vercel.json"
    end
    
    %% Relationships
    NextApp --> Pages
    NextApp --> Components
    NextApp --> PWA
    PWA --> ServiceWorker
    PWA --> Manifest
    NextApp --> Styles
    NextApp --> TailwindConfig
    NextApp --> FirebaseClient
    
    Pages --> TSServer
    TSServer --> GooglePlacesAPI
    TSServer --> OtherEndpoints
    
    FirebaseClient --> Firebase
    GooglePlacesAPI --> GooglePlaces
    
    NextApp --> Vercel
    TSServer --> Vercel
    
    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white
    classDef deployment fill:#9b59b6,stroke:#8e44ad,color:white
    classDef pwa fill:#1abc9c,stroke:#16a085,color:white
    
    class NextApp,Pages,Components,Styles,TailwindConfig,FirebaseClient frontend
    class TSServer,GooglePlacesAPI,OtherEndpoints backend
    class Firebase,GooglePlaces external
    class Vercel deployment
    class PWA,ServiceWorker,Manifest pwa
```
