# bharathraj0643/phonoria architecture

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

- Interactive diagram: https://gitdiagram.com/bharathraj0643/phonoria
- Repository: https://github.com/bharathraj0643/phonoria

## Overview

##### Project Type and Purpose
- This is a full-stack e-commerce web application (“Ecommerce”).
- The frontend is a React SPA built with Vite and deployed on Vercel.
- The backend is a Node.js API (likely Express) deployed via Fly.io.

##### File Structure Analysis
Top-level:
- .github/workflows – CI/CD definitions for both frontend (Vercel) and backend (Fly.io).
- backend/ – Node.js API service.
- frontend/ – React UI client.
backend/:
- src/ – app.js, index.js, constants, utils (api-error & api-response), db module.
- backend-tech-stack.md – lists frameworks and libraries.
- fly-deploy/ – Dockerfile and fly.toml configs for dev/test/prod.
frontend/:
- src/ – main.jsx, App.jsx, Layout, components, assets, constants/env.js.
- vite.config.js, vercel.json – build and deployment config.
- frontend-tech-stack.md – tech overview.

##### Key Insights from README
- Minimal README with live URL: https://phonoria.vercel.app/

##### Main System Components
A. React Frontend (Client)
- Runs in user’s browser.
- Hosted on Vercel.
- Routes (App.jsx → Layout → pages, 404).
- Calls backend API endpoints.
B. Node.js Backend API
- Exposes RESTful endpoints (src/app.js, src/index.js).
- Business logic, error/response wrappers.
- Database adapter (src/db/index.js).
C. Database
- Likely PostgreSQL or MongoDB (check backend/env.sample).
- Managed externally or via Fly.io add-on.
D. CI/CD / Deployment
- GitHub Actions triggers on push/PR.
- Frontend jobs deploy to Vercel.
- Backend jobs build Docker image, deploy to Fly.io (dev/test/prod).
E. Environment & Config
- env.sample in both frontend and backend for secrets/config.
- fly.toml for Fly.io environments.
- vercel.json for frontend routing/build settings.

##### Relationships & Data Flows
- User’s Browser → (HTTPS) → Vercel-served React SPA
- React SPA → (HTTPS API calls) → Fly.io Node.js service
- Node.js service → (DB client) → Database
- GitHub Actions → (build/deploy) → Vercel & Fly.io

##### Architectural Patterns & Principles
- Layered Architecture in backend:
- Routing → Controllers (app.js) → Services/DB → Utils (errors/responses).
- Separation of Concerns:
- Frontend vs Backend clear boundary.
- Config & secrets externalized (env files).
- Containerization: backend runs in Docker.

- Deployment overlays: indicate “Deployed on Vercel” vs “Deployed on Fly.io”.
- Versioning: note separate dev/test/prod environments for backend.

## Diagram (Mermaid)

```mermaid
flowchart TD
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#004D40
    classDef backend fill:#E8F5E9,stroke:#1B5E20,color:#2E7D32
    classDef db fill:#FFF3E0,stroke:#E65100,color:#BF360C
    classDef cicd fill:#ECEFF1,stroke:#455A64,color:#263238
    classDef external fill:#F3E5F5,stroke:#6A1B9A,color:#4A148C

    subgraph "CI/CD Pipeline"
        direction TB
        FEWorkflow["Frontend Workflow\n(.github/workflows/vercel-feat-frontend-discord.yml)"]:::cicd
        BEDev["Backend Dev Workflow\n(.github/workflows/fly-deploy-discord-backend-dev.yml)"]:::cicd
        BETest["Backend Test Workflow\n(.github/workflows/fly-deploy-discord-backend-test.yml)"]:::cicd
        BEProd["Backend Prod Workflow\n(.github/workflows/fly-deploy-discord-backend-prod.yml)"]:::cicd
    end

    subgraph "Deployment Targets"
        direction TB
        Vercel["Vercel CDN / Hosting"]:::frontend
        FlyIO["Fly.io Container Platform"]:::backend
    end

    subgraph "Application"
        direction TB
        UserBrowser["User Browser\n(React SPA)"]:::frontend
        ReactFE["React Frontend\n(Vite)"]:::frontend
        NodeAPI["Node.js API Service"]:::backend
        DB["Database\n(PostgreSQL/MongoDB)"]:::db
    end

    %% Connections
    FEWorkflow -->|"on push|deploy to"| Vercel
    BEDev -->|"on push|build & deploy to"| FlyIO
    BETest -->|"on push|build & deploy to"| FlyIO
    BEProd -->|"on push|build & deploy to"| FlyIO

    UserBrowser -->|"HTTPS"| Vercel
    Vercel -->|"serves SPA"| ReactFE
    ReactFE -->|"HTTPS API calls"| NodeAPI
    NodeAPI -->|"DB protocol"| DB
    FlyIO -->|hosts| NodeAPI

    %% Click Events
    click ReactFE "https://github.com/bharathraj0643/phonoria/blob/main/frontend/src/main.jsx"
    click NodeAPI "https://github.com/bharathraj0643/phonoria/blob/main/backend/src/index.js"
    click DB "https://github.com/bharathraj0643/phonoria/blob/main/backend/src/db/index.js"
    click FEWorkflow "https://github.com/bharathraj0643/phonoria/blob/main/.github/workflows/vercel-feat-frontend-discord.yml"
    click BEDev "https://github.com/bharathraj0643/phonoria/blob/main/.github/workflows/fly-deploy-discord-backend-dev.yml"
    click BETest "https://github.com/bharathraj0643/phonoria/blob/main/.github/workflows/fly-deploy-discord-backend-test.yml"
    click BEProd "https://github.com/bharathraj0643/phonoria/blob/main/.github/workflows/fly-deploy-discord-backend-prod.yml"
    click FlyIO "https://github.com/bharathraj0643/phonoria/tree/main/backend/fly-deploy/"

    %% Styling
    class UserBrowser,ReactFE,Vercel frontend
    class NodeAPI,FlyIO backend
    class DB db
    class FEWorkflow,BEDev,BETest,BEProd cicd
```
