# 42dotmk/klimentohridski architecture

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

- Interactive diagram: https://gitdiagram.com/42dotmk/klimentohridski
- Repository: https://github.com/42dotmk/klimentohridski

## Overview

##### Main Components
- Frontend (Astro): All files under the “astro” directory form the presentation layer. This includes:
– The “src” folder with “pages” (routing for different sections such as blog, services, contact, etc.), “components” (reusable UI blocks like Hero, Button, Navigation, Footer, etc.), and utility functions.
– Styling files (global.css) and configuration files (astro.config.mjs, tailwind.config.mjs, tsconfig.json).
- Backend / Headless CMS (Strapi): All files under the “strapi” folder provide the backend API and content management:
– “src/api” contains different APIs (for “blog”, “page”, “service”, “post”, “contact-information”, “text”, “image”), each with content types, controllers, services, and routes.
– Configuration files (config directory) for the admin panel, database, plugins, server settings, and middlewares.
– Supporting files for migrations, environment settings (.env), and deployment (data-export tarball).
- Database: Although not explicitly visible as a technical component, the Strapi configuration and migrations imply a backend database. (It could be PostgreSQL, MySQL, or SQLite based on your Strapi setup but is abstracted out here.)
- External Services/Environments: The Astro code references a “STRAPI_URL” (configured in an .env file) that establishes connectivity between the frontend and the backend CMS. This interaction is central to the application’s headless CMS model.

##### Relationships and Interactions
- The Astro Frontend fetches content from the Strapi backend via HTTP API calls (using the STRAPI_URL environment variable).
- The UI layer renders pages and components based on dynamic content retrieved from Strapi.
- Within Strapi, various API endpoints (organized under folders like “blog”, “page”, “service”, etc.) serve as the gateways between the underlying database and the frontend.
- Strapi also handles administrative and content management tasks (including data import with the provided tarball, admin account creation, etc.).

##### Architectural Patterns and Design Principles
- Separation of Concerns: A clear split between the frontend (presentation layer using Astro) and backend (content management using Strapi).
- Headless CMS Integration: The backend serves as a headless CMS where content management operations are decoupled from content presentation.
- Modular Design: Both folders are organized in a modular fashion. In Astro, components and pages are clearly separated, and in Strapi, the API endpoints follow a standardized structure (controllers, routes, services, and content-types) that often follows common REST or MVC-like principles.
- Environment Configuration: Utilizing .env to manage different endpoints ensures flexibility and security.

##### Relevant Technologies, Frameworks, and Libraries
- Astro: A modern static site generator for building fast, content-focused frontends.
- Strapi: The headless CMS powering the backend and providing an API for content.
- Tailwind CSS: Referenced by the tailwind.config.mjs and global.css, for styling the Astro frontend.
- TypeScript: Visible via tsconfig.json and type declarations, ensuring type safety across both projects.
- Node.js and npm: Both the Astro and Strapi projects are built upon Node.js, with dependencies managed via npm.
- Any additional libraries or utilities inside the “src/lib” and “src/util” directories within Astro which help manage content and utility tasks.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Astro Frontend Layer
    subgraph "Astro Frontend"
        direction TB
        A_FW["Astro Frontend"]:::frontend

        subgraph "Routing & Views"
            Pages["Pages (Routing & Views)"]:::frontend
        end

        subgraph "UI Components"
            Components["UI Components"]:::frontend
            Layout["Layout Components"]:::frontend
        end

        subgraph "Styling & Configuration"
            AstroConfig["Astro Config"]:::frontend
            TailwindConfig["Tailwind Config"]:::frontend
            TSConfig["TS Config"]:::frontend
            GlobalStyles["Global Styles"]:::frontend
        end

        subgraph "Utility & Library"
            LibCode["Lib Code"]:::frontend
            UtilCode["Util Code"]:::frontend
        end
    end

    %% Strapi Backend Layer
    subgraph "Strapi Backend"
        direction TB
        Backend["Strapi Backend"]:::backend

        subgraph "API Endpoints"
            BlogAPI["Blog API"]:::backend
            PageAPI["Page API"]:::backend
            ServiceAPI["Service API"]:::backend
            PostAPI["Post API"]:::backend
            ContactAPI["Contact Info API"]:::backend
            TextAPI["Text API"]:::backend
            ImageAPI["Image API"]:::backend
        end

        subgraph "Configurations & Support"
            Config["Configuration"]:::backend
            Migrations["Database Migrations"]:::backend
        end

        subgraph "Environment & Deployment"
            EnvSettings["Env Settings"]:::backend
            DataExport["Data Export Tarball"]:::backend
        end
    end

    %% External Database
    Database["Database"]:::database

    %% Internal Connections in Astro Frontend
    A_FW --- Pages
    A_FW --- Components
    A_FW --- AstroConfig
    A_FW --- LibCode

    %% Communication from Frontend to Backend APIs
    Pages -->|"fetchContent"| Backend
    Components -->|"fetchContent"| Backend
    LibCode -->|"callsAPI"| Backend

    %% Connections within Strapi Backend to Database
    Config -->|"DBConnection"| Database
    Migrations -->|"migrateSchema"| Database

    %% Environment configuration linking Frontend and Backend
    EnvSettings -- "configures" --> A_FW

    %% Click Events for Astro Frontend Components
    click A_FW "https://github.com/42dotmk/klimentohridski/tree/main/astro"
    click Pages "https://github.com/42dotmk/klimentohridski/tree/main/astro/src/pages"
    click Components "https://github.com/42dotmk/klimentohridski/tree/main/astro/src/components"
    click Layout "https://github.com/42dotmk/klimentohridski/tree/main/astro/src/components/layout"
    click AstroConfig "https://github.com/42dotmk/klimentohridski/blob/main/astro/astro.config.mjs"
    click TailwindConfig "https://github.com/42dotmk/klimentohridski/blob/main/astro/tailwind.config.mjs"
    click TSConfig "https://github.com/42dotmk/klimentohridski/blob/main/astro/tsconfig.json"
    click GlobalStyles "https://github.com/42dotmk/klimentohridski/blob/main/astro/src/styles/global.css"
    click LibCode "https://github.com/42dotmk/klimentohridski/tree/main/astro/src/lib"
    click UtilCode "https://github.com/42dotmk/klimentohridski/tree/main/astro/src/util"

    %% Click Events for Strapi Backend Components
    click Backend "https://github.com/42dotmk/klimentohridski/tree/main/strapi"
    click BlogAPI "https://github.com/42dotmk/klimentohridski/tree/main/strapi/src/api/blog"
    click PageAPI "https://github.com/42dotmk/klimentohridski/tree/main/strapi/src/api/page"
    click ServiceAPI "https://github.com/42dotmk/klimentohridski/tree/main/strapi/src/api/service"
    click PostAPI "https://github.com/42dotmk/klimentohridski/tree/main/strapi/src/api/post"
    click ContactAPI "https://github.com/42dotmk/klimentohridski/tree/main/strapi/src/api/contact-information"
    click TextAPI "https://github.com/42dotmk/klimentohridski/tree/main/strapi/src/api/text"
    click ImageAPI "https://github.com/42dotmk/klimentohridski/tree/main/strapi/src/api/image"
    click Config "https://github.com/42dotmk/klimentohridski/tree/main/strapi/config"
    click Migrations "https://github.com/42dotmk/klimentohridski/tree/main/strapi/database/migrations"
    click EnvSettings "https://github.com/42dotmk/klimentohridski/blob/main/strapi/.env.example"
    click DataExport "https://github.com/42dotmk/klimentohridski/blob/main/strapi/data-export.tar.gz"

    %% Styles for different layers
    classDef frontend fill:#D0E6A5,stroke:#6DA06F,stroke-width:2px;
    classDef backend fill:#F3E1A0,stroke:#D4A373,stroke-width:2px;
    classDef database fill:#AEDFF7,stroke:#7CB9E8,stroke-width:2px;
```
