# 1pt-co/1pt architecture

> Architecture diagram of the GitHub repository 1pt-co/1pt, 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/1pt-co/1pt
- Repository: https://github.com/1pt-co/1pt

## Overview

##### Main Components
- Frontend Application: A React-based SPA residing in the “src” and “public” directories. This includes the App.js, several pages (Dashboard, Home, 404, Redirect), components (Header, InfoRow, LongURL, etc.), and styling files.
- Backend API: Although the backend isn’t part of this repository, its existence is crucial. It is a PHP-based API hosted externally (endpoint provided in the README) that accepts URL creation requests (e.g., via /addURL) and manages the data.
- MySQL Database: The README informs us that the backend stores redirects in a MySQL database. Although external, it’s an essential system component.
- Optional: Although not directly in the source, the info.1pt.co service (which prepares metadata previews) is an extension to this architecture.

##### Relationships and Interactions
- Users open a browser and load the React application from the public/index.html.
- The React app (frontend) provides multiple pages. For instance, the Home page for entering long URLs, a Redirect page that handles the redirection logic, and an Info or Dashboard page that displays metadata.
- The API, in turn, interacts with the MySQL database to store and retrieve URL mapping information.
- Once the API responds with the short URL, the frontend processes and presents the information back to the user.
- There is an optional flow for metadata preview using a special “info” prepended URL, which is a derivation of the shortened URL leading to additional information before redirection.

##### Relevant Technologies/Frameworks
- React: Mentioned by the presence of “src/App.js”, “src/index.js”, and components.
- CSS/SCSS: Files in “src/styles” and CSS modules in components.
- PHP API: Referenced in the README as the backend technology.
- MySQL: Used for storing URL redirects.
- Additional: The project uses package management (package.json/package-lock.json) indicating Node.js/JavaScript tooling for the frontend.

##### Essential Elements
– React Frontend (with subdivisions if needed to indicate pages, components, static assets)
– PHP Backend API
– MySQL Database
– User’s Web Browser (client)
– User interactions from the Browser to the React Application.
– API requests from the React Application to the PHP API.
– Data flow between the PHP API and MySQL Database.
- Notes or legends indicating key HTTP methods (like POST /addURL) and data exchanges.

## Diagram (Mermaid)

```mermaid
graph TD
    browser("User's Web Browser"):::browser

    subgraph "React Frontend"
        FE("React Frontend Application"):::frontend
        FE1("UI Components"):::frontend
        FE2("Pages"):::frontend
        FE3("Static Assets"):::frontend
        FE -->|"contains"| FE1
        FE -->|"contains"| FE2
        FE -->|"contains"| FE3
    end

    backend("PHP API Endpoint"):::backend
    database("MySQL Database"):::database
    external("info.1pt.co Metadata Service"):::external

    browser -->|"Loads"| FE
    FE -->|"POST/addURL"| backend
    backend -->|"Stores_URL_Mappings"| database
    FE ---|"GET_Metadata"| external

    click FE "https://github.com/1pt-co/1pt/tree/react/src"
    click FE1 "https://github.com/1pt-co/1pt/tree/react/src/components"
    click FE2 "https://github.com/1pt-co/1pt/tree/react/src/pages"
    click FE3 "https://github.com/1pt-co/1pt/tree/react/public"

    classDef browser fill:#f9e79f,stroke:#000,stroke-width:2px;
    classDef frontend fill:#aed6f1,stroke:#000,stroke-width:2px;
    classDef backend fill:#a9dfbf,stroke:#000,stroke-width:2px;
    classDef database fill:#ffe082,stroke:#000,stroke-width:2px;
    classDef external fill:#d7bde2,stroke:#000,stroke-width:2px;
```
