# frikishaan/tiny-crm architecture

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

- Interactive diagram: https://gitdiagram.com/frikishaan/tiny-crm
- Repository: https://github.com/frikishaan/tiny-crm

## Overview

##### Project Type and Purpose
- This project is an open-source CRM application called “Tiny CRM” built with Laravel and Filament PHP.
- Its purpose is to provide a CRM system with modules for managing accounts, contacts, deals, leads, products, and users. The project leverages Filament PHP to deliver an admin panel/dashboard experience.

##### File Structure
- The top-level directories (app, config, database, public, resources, routes) indicate a standard Laravel MVC structure.
- The “app” directory contains Controllers, Models, Events, Enums, Providers, and additional features (like Observers and Listeners) which reveal the modularity and event-driven aspects of the design.
- The “app/Filament” directory holds the Filament-specific files (pages, resources, widgets) used to define the admin panel interface and resource CRUD operations.
- The “public” and “resources” directories contain assets (CSS, JS, etc.) that support the frontend.
- Routing is handled by files in the “routes” directory indicating separation of API, web, and console commands.
- The database folder (migrations, factories, seeders) clearly shows the persistence layer using a relational database (configured for PostgreSQL).

##### README for Additional Insights
- The README confirms the tech stack (PHP, Laravel, Filament PHP) and indicates that this is a full-stack web application.
- It includes instructions for installing dependencies, running migrations, and seeding the database, affirming the importance of the database layer.
- The screenshot reference suggests a strong UI component in the admin dashboard.

a. Frontend Client:
- Represented by the browser or client devices accessing the Tiny CRM UI.
- Connects to the Laravel backend which serves pages (e.g., Filament dashboard, login page, etc.).

b. Laravel Web Server / Backend:
- Handle HTTP requests routed via “routes/web.php” (and “routes/api.php” for API endpoints, if any).
- Contains Controllers in “app/Http/Controllers” that mediate between the incoming requests and business logic.
- The Middleware layer (in “app/Http/Middleware”) handles authentication, CSRF protection, and other HTTP concerns.

c. Filament Admin Panel:
- A specialized module within the backend for admin interface and dashboard functionalities.
- It includes Filament Pages, Resources, Widgets, and Panels as seen in the “app/Filament” directory.
- This component manages CRUD operations for resources such as accounts, contacts, deals, leads, products, and users.

d. Business Logic & Domain Layer:
- Models (in “app/Models”) represent the core entities of the CRM (Account, Contact, Deal, etc.).
- Enums (in “app/Enums”) define constants for statuses (like DealStatus, LeadStatus, etc.).
- Observers, Listeners, and Events (e.g., in “app/Observers” and “app/Events”) capture domain events and process business logic (like rollup aggregations for sales).

e. Persistence / Database:
- The database layer is managed via Laravel’s migrations, seeders, and factories.
- A PostgreSQL database is used (as configured in the provided .env example).
- The Models interact with the relational database using Laravel’s ORM (Eloquent).

f. Assets & Frontend Build Process:
- The “public” and “resources” directories contain the compiled assets (JS, CSS, etc.) built with tools like Vite and Tailwind CSS.
- These assets are served to the browser to render the UI.

##### Relationships and Interactions
- Routing layer (web routes, api routes, console commands) as part of the backend entry points.
- Controllers interacting with models and the database.
- Demonstrate the admin panel (Filament) as an integral part of the Laravel application, handling user interactions for CRM functionalities.
- Event listeners and observers connecting to model events – which in turn may trigger further business logic or background jobs.
- If needed, include a component for storage/logging as part of the operational or debugging layer.

##### Architectural Patterns and Design Principles
- MVC Pattern: Emphasize that the project is organized around Model, View, and Controller components.
- Event-Driven Architecture: Indicate that events and observers are used for decoupled background processing (e.g., real-time updates or sales rollup operations).
- Modular and Extensible Design via Filament: The Filament-specific resources allow easy extension of the admin panel functionalities.
- Separation of Frontend and Backend: Although they reside in the same application, clearly delineate the UI (assets and view templates) from the business logic and persistence layers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Assets["Assets (Public/Resources)"]:::asset
    Browser["Browser (Frontend Client)"]:::frontend
    Assets -->|"fetches"| Browser

    Backend["Laravel Web Server / Backend"]:::backend
    Browser -->|"HTTP_Request"| Backend

    subgraph "Laravel Web Server / Backend"
        Routing["Routing Layer (routes/web.php & routes/api.php)"]:::routing
        Middleware["Middleware (app/Http/Middleware)"]:::middleware
        Controllers["Controllers (app/Http/Controllers)"]:::controller
        Filament["Filament Admin Panel (app/Filament)"]:::admin
        Business["Models & Enums (app/Models, app/Enums)"]:::business
        EventSys["Event System (app/Events, app/Listeners, app/Observers)"]:::eventsys
    end

    Routing -->|"routes_to"| Middleware
    Routing -->|"routes_to"| Controllers
    Routing -->|"routes_to"| Filament
    Controllers -->|"calls"| Business
    Business -->|"triggers"| EventSys

    Database["Database (PostgreSQL)"]:::database
    Business -->|"stores_in"| Database
    Filament -->|"CRUD_for"| Business

    click Assets "https://github.com/frikishaan/tiny-crm/blob/main/public/index.php"
    click Browser "https://github.com/frikishaan/tiny-crm/blob/main/resources/views/welcome.blade.php"
    click Routing "https://github.com/frikishaan/tiny-crm/blob/main/routes/web.php"
    click Middleware "https://github.com/frikishaan/tiny-crm/blob/main/app/Http/Middleware/Authenticate.php"
    click Controllers "https://github.com/frikishaan/tiny-crm/blob/main/app/Http/Controllers/Controller.php"
    click Filament "https://github.com/frikishaan/tiny-crm/tree/main/app/Filament"
    click Business "https://github.com/frikishaan/tiny-crm/blob/main/app/Models/Account.php"
    click EventSys "https://github.com/frikishaan/tiny-crm/blob/main/app/Events/DealQualified.php"
    click Database "https://github.com/frikishaan/tiny-crm/tree/main/database"

    classDef frontend fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef backend fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef admin fill:#FFECB3,stroke:#FBC02D,stroke-width:2px;
    classDef business fill:#D1C4E9,stroke:#673AB7,stroke-width:2px;
    classDef database fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef routing fill:#FFE0B2,stroke:#E65100,stroke-width:2px;
    classDef middleware fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
    classDef controller fill:#DCEDC8,stroke:#558B2F,stroke-width:2px;
    classDef eventsys fill:#F8BBD0,stroke:#AD1457,stroke-width:2px;
    classDef asset fill:#B2EBF2,stroke:#006064,stroke-width:2px;
```
