# mahdi015/mediapost-front architecture

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

- Interactive diagram: https://gitdiagram.com/mahdi015/mediapost-front
- Repository: https://github.com/mahdi015/mediapost-front

## Overview

##### Project type and purpose
- This is a single-page front-end web application (built in Vue 3 + TypeScript) that allows users to upload photos, videos, and files.
- It uses Supabase as a Backend-as-a-Service for authentication, database/storage, and is deployed (via Netlify) as a static site.

##### Main components
a. Browser / Client
- Vue SPA (App.vue, Pages, Components)
- UI Components: Home.vue, CreatePost.vue, PostCard.vue
b. API Layer (src/functions/api.ts)
- Encapsulates all calls to Supabase
- Exposes methods like uploadFile(), fetchPosts(), authenticateUser()
c. Supabase Client (src/lib/supabaseClient.ts)
- Configured with Supabase URL and anon key (from .env)
d. Supabase Services (external)
- Auth Service
- Database (Post metadata)
- Storage (media files)
e. Hosting/CDN
- Netlify (serving the built SPA)

##### Relationships and Data Flows
- Browser → Vue Components: user interactions trigger component methods.
- Vue Components → API Layer: components import and call functions in src/functions/api.ts.
- API Layer → Supabase Client: each function calls supabaseClient to perform RPCs (auth, db CRUD, storage).
- Supabase Client → Supabase Services: the client library makes HTTP requests to Supabase endpoints.
- Supabase Services → Supabase Client → Browser: responses flow back through the same chain.
- Hosting Pipeline: GitHub → Netlify CI → build (npm run build) → deploy static assets (public/* + dist) to CDN.

##### Architectural Patterns & Design Principles
- Clear separation of concerns:
- Presentation layer (Vue components)
- Service/API layer (wrapper functions)
- Infrastructure (Supabase as BaaS)
- Single-page application architecture
- Environment-based configuration (.env for Supabase keys)
- Module structure: grouping by feature (Pages/, Components/) vs. by technical role (lib/, functions/)

##### Relevant Technologies & Frameworks
- Vue 3 with Composition API (main.ts, App.vue)
- TypeScript for type safety (src/types/*.ts)
- Supabase JS client for backend interactions
- Netlify for hosting
- SCSS for styling (global.scss)
- Build/config: Babel, webpack (vue.config.js), ESLint, tsconfig.json

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Browser / Client"
        B1["public/index.html"]:::infra
        B2["src/main.ts"]:::app
        B3["src/App.vue"]:::app
    end

    subgraph "Presentation Layer"
        P1["src/Pages/Home.vue"]:::ui
        P2["src/components/CreatePost.vue"]:::ui
        P3["src/components/PostCard.vue"]:::ui
        P4["src/assets/global.scss"]:::infra
        P5["src/assets/images/"]:::infra
    end

    subgraph "API Layer"
        API["src/functions/api.ts"]:::app
    end

    subgraph "Supabase Client"
        Client["src/lib/supabaseClient.ts"]:::client
        Env[".env"]:::infra
        EnvTypes["src/types/environment.d.ts"]:::app
    end

    subgraph "Type Definitions"
        T1["src/types/types.ts"]:::app
        T2["src/vue-timeago3.d.ts"]:::app
        T3["src/shims-vue.d.ts"]:::app
    end

    subgraph "Supabase Services (External)"
        SA["Auth Service"]:::service
        SD["Database"]:::service
        SS["Storage"]:::service
    end

    subgraph "Build & Tooling Configuration"
        Bld1["vue.config.js"]:::infra
        Bld2["babel.config.js"]:::infra
        Bld3["tsconfig.json"]:::infra
        Bld4[".eslintrc.js"]:::infra
    end

    subgraph "Hosting/CDN"
        GH["GitHub Repo"]:::infra
        NetlifyCI["Netlify CI/CD"]:::infra
        CDN["Netlify CDN"]:::infra
    end

    B1 -->|"loads"| B2
    B2 -->|"renders"| B3
    B3 -->|"uses"| P1
    B3 -->|"uses"| P2
    B3 -->|"uses"| P3

    P1 -->|"calls fetchPosts()/uploadFile()"| API
    P2 -->|"calls fetchPosts()/uploadFile()"| API
    P3 -->|"calls fetchPosts()/uploadFile()"| API

    API -->|"executes supabase.from().select()"| Client

    Client -->|"HTTP REST/gRPC"| SA
    Client -->|"HTTP REST/gRPC"| SD
    Client -->|"HTTP REST/gRPC"| SS

    Env -->|"provides keys"| Client
    EnvTypes -->|"type defs"| Client

    GH -->|"push code"| NetlifyCI
    NetlifyCI -->|"build & deploy"| CDN

    classDef ui fill:#ccffcc,stroke:#006600
    classDef app fill:#cce5ff,stroke:#004085
    classDef client fill:#e6f7ff,stroke:#3399cc
    classDef service fill:#ffe6cc,stroke:#cc6600
    classDef infra fill:#f2f2f2,stroke:#666666

    click B1 "https://github.com/mahdi015/mediapost-front/blob/master/public/index.html"
    click B2 "https://github.com/mahdi015/mediapost-front/blob/master/src/main.ts"
    click B3 "https://github.com/mahdi015/mediapost-front/blob/master/src/App.vue"
    click P1 "https://github.com/mahdi015/mediapost-front/blob/master/src/Pages/Home.vue"
    click P2 "https://github.com/mahdi015/mediapost-front/blob/master/src/components/CreatePost.vue"
    click P3 "https://github.com/mahdi015/mediapost-front/blob/master/src/components/PostCard.vue"
    click P4 "https://github.com/mahdi015/mediapost-front/blob/master/src/assets/global.scss"
    click P5 "https://github.com/mahdi015/mediapost-front/tree/master/src/assets/images/"
    click API "https://github.com/mahdi015/mediapost-front/blob/master/src/functions/api.ts"
    click Client "https://github.com/mahdi015/mediapost-front/blob/master/src/lib/supabaseClient.ts"
    click Env "https://github.com/mahdi015/mediapost-front/blob/master/.env"
    click EnvTypes "https://github.com/mahdi015/mediapost-front/blob/master/src/types/environment.d.ts"
    click T1 "https://github.com/mahdi015/mediapost-front/blob/master/src/types/types.ts"
    click T2 "https://github.com/mahdi015/mediapost-front/blob/master/src/vue-timeago3.d.ts"
    click T3 "https://github.com/mahdi015/mediapost-front/blob/master/src/shims-vue.d.ts"
    click Bld1 "https://github.com/mahdi015/mediapost-front/blob/master/vue.config.js"
    click Bld2 "https://github.com/mahdi015/mediapost-front/blob/master/babel.config.js"
    click Bld3 "https://github.com/mahdi015/mediapost-front/blob/master/tsconfig.json"
    click Bld4 "https://github.com/mahdi015/mediapost-front/blob/master/.eslintrc.js"
```
