# borys1no/drakon architecture

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

- Interactive diagram: https://gitdiagram.com/borys1no/drakon
- Repository: https://github.com/borys1no/drakon

## Overview

##### Main Components
- Frontend (React + Vite):
- The primary codebase lives in the src directory. Here you have components for various views (Home, Checkout, Dashboard, ProtectedRoute, etc.) along with a considerable assets structure for images, fonts, and styles.
- The project uses contexts (like CartContext and authContext) to manage state, which implies a component-based and possibly centralized state-management design.

- Backend (Firebase Functions & Hosting):
- The “functions” folder holds backend logic written in Node.js that powers server-side operations (authentication middleware, API endpoints, etc.).
- Files such as firebase.json, .firebaserc, and the .firebase directory reveal Firebase Hosting and deployment configurations.
- The GitHub workflows indicate continuous integration/deployment processes with Firebase.

- Infrastructure/Deployment:
- The presence of configuration files (firebase.json, vite.config.js, eslint.config.js) shows separate concerns for bundling, hosting, and code quality.
- GitHub workflows (.github/workflows) are part of the deployment pipeline.

##### Relationships and Interactions
- The browser (client) loads the React application from Firebase Hosting.
- The React application interacts with Firebase backend services through the implemented API endpoints in the “functions” folder.
- External services (Firebase Authentication, possibly Firestore or Realtime Database if used even implicitly) should be represented as part of the backend ecosystem.

##### Architectural Patterns and Technologies
- Client-Server separation is clear: the frontend is a single page application (SPA) built with React, while backend operations are implemented in serverless functions.
- The project leverages modern build tools and hot module replacement (HMR) provided by Vite as indicated in the README.
- It uses ESLint for code quality and SWC/Babel plugins depending on the chosen React plugin (as mentioned in the readme).
- The CI/CD pipelines via GitHub actions that deploy to Firebase Hosting are an important architectural element.

##### Diagramming Tools and Detail Level
- That labels (e.g., “Auth”, “Checkout”, “Products Management”) are clearly defined.
- Don’t shy away from capturing every important element—even if that means separating the frontend into multiple sub-components and a separate section for Firebase configurations and workflows.

## Diagram (Mermaid)

```mermaid
graph TD
    %% External
    Browser["Browser"]:::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        ReactApp["React Application"]:::frontend
        subgraph "UI Components"
            Home["Home View"]:::frontend
            Checkout["Checkout Page"]:::frontend
            Dashboard["Dashboard/Admin"]:::frontend
            Products["Products/Storefront"]:::frontend
            Auth["Auth Components (Login/Register)"]:::frontend
        end
        subgraph "State & Assets"
            CartCtx["Cart Context"]:::frontend
            AuthCtx["Auth Context"]:::frontend
            Assets["Static Assets"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend Layer"
        FFunctions["Firebase Functions"]:::backend
        subgraph "Function Modules"
            API["API Endpoints (index.js)"]:::backend
            AuthMW["Auth Middleware"]:::backend
        end
        FirebaseSvc["Firebase Services (Auth/Database)"]:::backend
    end

    %% Deployment & CI/CD Layer
    subgraph "Deployment & CI/CD"
        FirebaseConfig["Firebase Config (firebase.json)"]:::deployment
        Firebaserc["Firebase Config (.firebaserc)"]:::deployment
        FirebaseHosting["Firebase Hosting (.firebase/)"]:::deployment
        ViteConfig["Vite Config (vite.config.js)"]:::deployment
        ESLintConfig["ESLint Config (eslint.config.js)"]:::deployment
        GitHubWorkflows["GitHub Workflows"]:::deployment
    end

    %% Connections between layers
    Browser -->|"loads"| ReactApp
    ReactApp -->|"renders"| Home
    ReactApp -->|"renders"| Checkout
    ReactApp -->|"renders"| Dashboard
    ReactApp -->|"renders"| Products
    ReactApp -->|"renders"| Auth
    ReactApp -->|"manages"| CartCtx
    ReactApp -->|"manages"| AuthCtx
    ReactApp -->|"loads"| Assets

    ReactApp -->|"calls"| API
    API -->|"securedBy"| AuthMW
    ReactApp -->|"integrates"| FirebaseSvc

    %% Deployment connections
    ViteConfig -->|"builds"| ReactApp
    ESLintConfig -->|"checks"| ReactApp
    GitHubWorkflows -->|"deploys"| FirebaseHosting
    GitHubWorkflows -->|"triggers"| ViteConfig
    FirebaseConfig -->|"configures"| FirebaseSvc
    Firebaserc -->|"configures"| FirebaseSvc

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#0056b3,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef deployment fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;

    %% Click Events for Frontend Components
    click ReactApp "https://github.com/borys1no/drakon/tree/master/src/"
    click Home "https://github.com/borys1no/drakon/blob/master/src/components/home/Home.jsx"
    click Checkout "https://github.com/borys1no/drakon/blob/master/src/components/Checkout/Checkout.jsx"
    click Dashboard "https://github.com/borys1no/drakon/tree/master/src/components/dashboard/"
    click Products "https://github.com/borys1no/drakon/blob/master/src/components/Productos/Products.jsx"
    click Auth "https://github.com/borys1no/drakon/tree/master/src/components/auth/"
    click CartCtx "https://github.com/borys1no/drakon/blob/master/src/contexts/CartContext.jsx"
    click AuthCtx "https://github.com/borys1no/drakon/blob/master/src/contexts/authContext/index.jsx"
    click Assets "https://github.com/borys1no/drakon/tree/master/src/assets/"

    %% Click Events for Backend Components
    click FFunctions "https://github.com/borys1no/drakon/tree/master/functions/"
    click API "https://github.com/borys1no/drakon/blob/master/functions/index.js"
    click AuthMW "https://github.com/borys1no/drakon/blob/master/functions/authMiddleware.js"

    %% Click Events for Deployment & CI/CD Components
    click ViteConfig "https://github.com/borys1no/drakon/blob/master/vite.config.js"
    click ESLintConfig "https://github.com/borys1no/drakon/blob/master/eslint.config.js"
    click GitHubWorkflows "https://github.com/borys1no/drakon/tree/master/.github/workflows/"
    click FirebaseConfig "https://github.com/borys1no/drakon/blob/master/firebase.json"
    click Firebaserc "https://github.com/borys1no/drakon/blob/master/.firebaserc"
    click FirebaseHosting "https://github.com/borys1no/drakon/tree/master/.firebase/"
```
