# ramanbhandari/vamoose architecture

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

- Interactive diagram: https://gitdiagram.com/ramanbhandari/vamoose
- Repository: https://github.com/ramanbhandari/vamoose

## Overview

##### Main Components
- Frontend Application:
- Located in the “frontend” directory.
- Built in Next.js using TypeScript, Tailwind CSS, and features a robust component structure (e.g., pages, layout, stores, utilities).
- Includes state management (via stores) for chat, trips, notifications, etc.
- Uses API clients (see the “frontend/utils/apiClient.ts”) and web sockets (socketClient.ts) for real-time interactions.
- Backend Server:
- Found in the “server” directory.
- Implements a REST API with multiple controllers handling endpoints for expenses, trips, invites, itinerary events, notifications, polls, etc.
- Organized using an MVC-like pattern: controllers, models, middleware, and services.
- Uses Prisma (see “server/prisma” and “schema.prisma”) for database interactions and migration scripts.
- Also includes a socket server (server/src/socketServer.ts) for real-time communication.
- Databases & Data Persistence:
- The database layer is abstracted through Prisma; you may have support for both relational (e.g., PostgreSQL) and NoSQL (as seen in “server/src/db/mongo.ts”) databases.
- Migrations and schema updates are tracked within the “server/prisma/migrations” folder.
- External Services & CI/CD:
- GitHub Actions workflows (in “.github/workflows”) are used for CI, security, deployment, and notifications.
- Docker-related files (Dockerfile and docker-compose.yml) indicate containerized deployment for both frontend and backend.

##### Relationships and Interactions
- The Frontend serves as the client interface (rendering pages, handling user interactions, and making API calls to the backend).
- Communication between the frontend and backend is done using REST APIs and WebSocket connections (for live chat, notifications, etc.).
- The backend exposes endpoints for each key feature (trip planning, expense splitting, itinerary management, location services, polls, and more) and leverages middleware for request validation and error handling.
- The backend interacts with one or more databases to persist user data, trip details, messages, etc.
- Load testing components and reports (present under “server/src/tests/load”) indicate that performance and scalability considerations have been taken into account.
- CI/CD pipelines (e.g., “deploy-frontend.yml”, “push_dockerhub.yml”) automate deployment of the containerized images.

##### Architectural Patterns and Key Design Principles
- Separation of Concerns: The clear divide between the frontend and backend, with dedicated API routes and controller logic.
- MVC Patterns on the Backend: Controllers, Models, and Middleware are separated to manage API logic and validations.
- Component-Based UI on the Frontend: The UI is built with reusable React components organized into directories (for chat, trips, navigation, etc.).
- Microservice-Like Modules: Although it is a monolith in terms of deployment, the backend is modular, with different controllers and services handling distinct features.
- Use of containers and CI/CD: Dockerfiles and GitHub Actions workflows help manage reproducible builds and automated testing.

## Diagram (Mermaid)

```mermaid
graph TD
  %% CI/CD & Deployment Layer
  subgraph "CI/CD & Deployment"
    cd1["CI/CD Pipelines (GitHub Actions)"]
    docker1["Frontend Dockerfile"]
    docker2["Backend Dockerfile"]
    docker3["Docker Compose"]
  end

  %% Frontend Layer
  subgraph "Frontend Layer"
    fe1["Frontend Application (Next.js UI)"]
    fe2["Pages & Components"]
    fe3["State Management (Stores)"]
    fe4["Utilities: API Client"]
    fe5["Utilities: Socket Client"]
  end

  %% Backend Layer
  subgraph "Backend Layer"
    be1["Backend Server (Express)"]
    be2["REST API Controllers"]
    be3["Services"]
    be4["Middleware"]
    be5["Socket Server"]
    be6["Database - Prisma ORM"]
    be7["Prisma Migrations"]
    be8["Database - Mongo Integration"]
    be9["Load Testing"]
  end

  %% Deployment Connections
  cd1 --> docker1
  cd1 --> docker2
  cd1 --> docker3
  docker1 --> fe1
  docker2 --> be1
  docker3 --> fe1
  docker3 --> be1

  %% Frontend Internal Flow
  fe1 --> fe2
  fe1 --> fe3
  fe1 --> fe4
  fe1 --> fe5

  %% Frontend to Backend Communication
  fe4 ---|"APIRequests"| be2
  fe5 ---|"WSConnection"| be5

  %% Backend Internal Flow
  be1 -->|"Routes"| be2
  be2 -->|"Uses"| be3
  be2 -->|"Uses"| be4
  be3 -->|"DBQuery"| be6
  be2 -->|"PersistData"| be6
  be2 -->|"NoSQL"| be8
  be1 ---|"TestedBy"| be9

  %% Click Events for Frontend
  click fe1 "https://github.com/ramanbhandari/vamoose/tree/dev/frontend"
  click fe2 "https://github.com/ramanbhandari/vamoose/tree/dev/frontend/app"
  click fe3 "https://github.com/ramanbhandari/vamoose/tree/dev/frontend/stores"
  click fe4 "https://github.com/ramanbhandari/vamoose/blob/dev/frontend/utils/apiClient.ts"
  click fe5 "https://github.com/ramanbhandari/vamoose/blob/dev/frontend/utils/socketClient.ts"

  %% Click Events for Backend
  click be1 "https://github.com/ramanbhandari/vamoose/blob/dev/server/src/app.ts"
  click be2 "https://github.com/ramanbhandari/vamoose/tree/dev/server/src/controllers"
  click be5 "https://github.com/ramanbhandari/vamoose/blob/dev/server/src/socketServer.ts"

  %% Click Events for Database & ORM
  click be6 "https://github.com/ramanbhandari/vamoose/blob/dev/server/prisma/schema.prisma"
  click be7 "https://github.com/ramanbhandari/vamoose/tree/dev/server/prisma/migrations"
  click be8 "https://github.com/ramanbhandari/vamoose/blob/dev/server/src/db/mongo.ts"

  %% Click Events for Deployment
  click cd1 "https://github.com/ramanbhandari/vamoose/tree/dev/.github/workflows"
  click docker1 "https://github.com/ramanbhandari/vamoose/tree/dev/frontend/Dockerfile"
  click docker2 "https://github.com/ramanbhandari/vamoose/tree/dev/server/Dockerfile"
  click docker3 "https://github.com/ramanbhandari/vamoose/blob/dev/docker-compose.yml"

  %% Styles
  classDef frontend fill:#AEDFF7,stroke:#1E81CE,stroke-width:2px;
  classDef backend fill:#C1E1C1,stroke:#2E8B57,stroke-width:2px;
  classDef db fill:#FFE6A7,stroke:#FF8C00,stroke-width:2px;
  classDef infra fill:#E0E0E0,stroke:#7D7D7D,stroke-width:2px;

  class fe1,fe2,fe3,fe4,fe5 frontend;
  class be1,be2,be3,be4,be5,be9 backend;
  class be6,be7,be8 db;
  class cd1,docker1,docker2,docker3 infra;
```
