# ancientkingg/oculite architecture

> Architecture diagram of the GitHub repository ancientkingg/oculite, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ancientkingg/oculite
- Repository: https://github.com/ancientkingg/oculite

## Overview

##### High-Level Architecture Overview
First, represent the three main decoupled components:
- Frontend (Vue.js client)
- Backend (Rust/Rocket server)
- Monitors (Independent services)

##### Component Breakdown

a. Frontend Layer:
- Core Vue components (Dashboard, Category views)
- Services layer (categoryService, itemTrackerService, statsService)
- Layout components
- Router
- State management

b. Backend Layer:
- API Controllers (category.rs, itemtracker.rs, stats.rs)
- Services layer (services/*.rs)
- Persistence layer (persist/*.rs)
- Database connection (PostgreSQL)

c. Monitors Layer:
- AutoDoc monitor
- Example monitor
- Extension point for future monitors

##### Data Flow Representation

- Frontend → Backend API calls
- Backend → Monitor API calls
- Backend → Database interactions
- Monitor → External Services calls

##### Specific Implementation Details

Technical details in annotations:
**Frontend:**
- Vue.js 3
- PrimeVue components
- Vite build system
- TypeScript

**Backend:**
- Rust/Rocket framework
- SQLX for database operations
- REST API endpoints
- PostgreSQL database

**Monitors:**
- Standardized REST API interface
- Language-agnostic implementation
- JSON response schema

##### Key Interactions

Following flows:
##### User interaction flow
- User → Frontend → Backend → Database
##### Monitor data collection flow
- Backend → Monitors → External Sources
##### Data aggregation flow
- Monitors → Backend → Database → Frontend

##### Additional Elements

Include:
- API endpoint specifications
- Database schema representation
- Authentication flow (if implemented)
- Monitoring/scheduling mechanisms

##### Notes for Implementation Details

Annotations for:
- REST API endpoints
- Database tables
- Monitor API contract
- Configuration requirements
- Deployment considerations

##### The clear separation of concerns between components

Remember to include all critical environment variables and configuration points as noted in the README:
- DATABASE_URL
- VITE_API_BASE_URL
- API_BASE_URL
- API_TOKEN

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef monitor fill:#e67e22,stroke:#d35400,color:white
    classDef database fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef api fill:#9b59b6,stroke:#8e44ad,color:white

    %% Frontend Layer
    subgraph Frontend
        VueClient["Vue.js Client"]
        
        subgraph Components
            Dashboard["Dashboard"]
            CategoryView["Category View"]
            ItemTracker["Item Tracker"]
            Layout["Layout Components"]
        end

        subgraph FrontendServices
            CategoryService["Category Service"]
            ItemTrackerService["Item Tracker Service"]
            StatsService["Stats Service"]
        end

        Router["Router"]
        State["State Management"]
    end

    %% Backend Layer
    subgraph Backend
        RocketServer["Rust/Rocket Server"]
        
        subgraph Controllers
            CategoryController["Category Controller"]
            ItemTrackerController["Item Tracker Controller"]
            StatsController["Stats Controller"]
        end

        subgraph Services
            BackendCategoryService["Category Service"]
            NotificationService["Notification Service"]
        end

        subgraph Persistence
            CategoryPersist["Category Persistence"]
            ItemTrackerPersist["Item Tracker Persistence"]
            NotificationPersist["Notification Persistence"]
            StatsPersist["Stats Persistence"]
        end

        DB[(PostgreSQL)]
    end

    %% Monitors Layer
    subgraph Monitors
        AutoDocMonitor["AutoDoc Monitor"]
        ExampleMonitor["Example Monitor"]
        FutureMonitors["Future Monitors"]
    end

    %% External Services
    ExternalServices["External Services"]

    %% Relationships
    VueClient --> Components
    Components --> FrontendServices
    FrontendServices --> Router
    Router --> State

    FrontendServices --> RocketServer
    RocketServer --> Controllers
    Controllers --> Services
    Services --> Persistence
    Persistence --> DB

    RocketServer --> Monitors
    Monitors --> ExternalServices

    %% Click events
    click Dashboard "https://github.com/ancientkingg/oculite/blob/master/client/src/views/Dashboard.vue"
    click CategoryView "https://github.com/ancientkingg/oculite/blob/master/client/src/views/pages/Category.vue"
    click ItemTracker "https://github.com/ancientkingg/oculite/blob/master/client/src/components/ItemTracker.vue"
    click CategoryService "https://github.com/ancientkingg/oculite/blob/master/client/src/services/categoryService.ts"
    click ItemTrackerService "https://github.com/ancientkingg/oculite/blob/master/client/src/services/itemTrackerService.ts"
    click StatsService "https://github.com/ancientkingg/oculite/blob/master/client/src/services/statsService.ts"
    click Layout "https://github.com/ancientkingg/oculite/tree/master/client/src/layout"
    click Router "https://github.com/ancientkingg/oculite/blob/master/client/src/router/index.ts"
    click CategoryController "https://github.com/ancientkingg/oculite/blob/master/server/src/api/category.rs"
    click ItemTrackerController "https://github.com/ancientkingg/oculite/blob/master/server/src/api/itemtracker.rs"
    click StatsController "https://github.com/ancientkingg/oculite/blob/master/server/src/api/stats.rs"
    click BackendCategoryService "https://github.com/ancientkingg/oculite/blob/master/server/src/services/category.rs"
    click NotificationService "https://github.com/ancientkingg/oculite/blob/master/server/src/services/notification.rs"
    click CategoryPersist "https://github.com/ancientkingg/oculite/blob/master/server/src/persist/category.rs"
    click ItemTrackerPersist "https://github.com/ancientkingg/oculite/blob/master/server/src/persist/itemtracker.rs"
    click NotificationPersist "https://github.com/ancientkingg/oculite/blob/master/server/src/persist/notification.rs"
    click StatsPersist "https://github.com/ancientkingg/oculite/blob/master/server/src/persist/stats.rs"
    click DB "https://github.com/ancientkingg/oculite/blob/master/server/migrations/01_oculite.sql"
    click AutoDocMonitor "https://github.com/ancientkingg/oculite/blob/master/monitors/autodoc/src/index.ts"
    click ExampleMonitor "https://github.com/ancientkingg/oculite/blob/master/monitors/monitor-example/src/index.ts"

    %% Apply classes
    class VueClient,Components,FrontendServices,Router,State frontend
    class RocketServer,Controllers,Services,Persistence backend
    class AutoDocMonitor,ExampleMonitor,FutureMonitors monitor
    class DB database
    class ExternalServices api
```
