engine

package
v0.29.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2025 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger *slog.Logger

Logger is global since we will need it everywhere

Functions

func DeleteFile

func DeleteFile(filePath string) error

DeleteFile deletes a folder (or file) and everything in that folder

Types

type LogEntry added in v0.23.0

type LogEntry struct {
	Level   string                 `json:"level"`
	Message string                 `json:"message"`
	Attrs   map[string]interface{} `json:"attrs"`
}

LogEntry represents a log entry from the frontend

type ServerHandler

type ServerHandler struct {
	DB           database.Repository
	Echo         *echo.Echo
	ServerConfig config.ServerConfig
}

ServerHandler will inject the variables needed into routes

func (*ServerHandler) AddDocumentTag added in v0.21.4

func (serverHandler *ServerHandler) AddDocumentTag(c echo.Context) error

AddDocumentTag adds a tag to a document @Summary Add tag to document @Description Associate a tag with a document @Tags Tags @Accept json @Produce json @Param ulid path string true "Document ULID" @Param tagId body int true "Tag ID" @Success 200 {object} map[string]interface{} @Failure 400 {object} map[string]interface{} @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/documents/{ulid}/tags [post]

func (*ServerHandler) AddDocumentViewRoutes

func (serverHandler *ServerHandler) AddDocumentViewRoutes() error

AddDocumentViewRoutes adds all of the current documents to an echo route

func (*ServerHandler) CleanDatabase

func (serverHandler *ServerHandler) CleanDatabase(c echo.Context) error

CleanDatabase checks all documents and removes entries for missing files, and moves orphaned files (not in database) back to ingress for reprocessing @Summary Clean database @Description Remove database entries for missing files and move orphaned files to ingress @Tags Admin @Accept json @Produce json @Success 200 {object} map[string]interface{} "Job created with jobId" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /clean [post]

func (*ServerHandler) CreateFolder

func (serverHandler *ServerHandler) CreateFolder(context echo.Context) error

CreateFolder creates a folder in the document tree @Summary Create a new folder @Description Create a new folder in the document filesystem @Tags Folders @Accept json @Produce json @Param folder query string true "Folder name" @Param path query string true "Parent path" @Success 200 {string} string "Full folder path created" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /folder [post]

func (*ServerHandler) CreateTag added in v0.21.4

func (serverHandler *ServerHandler) CreateTag(c echo.Context) error

CreateTag creates a new tag @Summary Create a new tag @Description Create a new tag @Tags Tags @Accept json @Produce json @Param tag body database.Tag true "Tag object" @Success 201 {object} database.Tag @Failure 400 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/tags [post]

func (*ServerHandler) DeleteFile

func (serverHandler *ServerHandler) DeleteFile(context echo.Context) error

DeleteFile deletes a folder or file from the database (and all children if folder) (and on disc and from bleve search if document) @Summary Delete a file or folder @Description Deletes a document or folder from the system, including database entry and physical file @Tags Documents @Accept json @Produce json @Param id query string false "Document ULID" @Param path query string false "File path relative to document root" @Success 200 {string} string "Document Deleted" or "Folder Deleted" @Failure 404 {object} map[string]interface{} "File not found" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /document [delete]

func (*ServerHandler) DeleteTag added in v0.21.4

func (serverHandler *ServerHandler) DeleteTag(c echo.Context) error

DeleteTag deletes a tag @Summary Delete a tag @Description Delete a tag and remove it from all documents @Tags Tags @Accept json @Produce json @Param id path int true "Tag ID" @Success 204 @Failure 400 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/tags/{id} [delete]

func (*ServerHandler) GetAboutInfo

func (serverHandler *ServerHandler) GetAboutInfo(c echo.Context) error

GetAboutInfo returns information about the application configuration @Summary Get application information @Description Retrieve information about the application configuration, version, and database @Tags Admin @Accept json @Produce json @Success 200 {object} map[string]interface{} "Application information" @Router /about [get]

func (*ServerHandler) GetActiveJobs

func (serverHandler *ServerHandler) GetActiveJobs(c echo.Context) error

GetActiveJobs retrieves all currently running or pending jobs @Summary Get active jobs @Description Retrieve all jobs that are currently running or pending @Tags Jobs @Accept json @Produce json @Success 200 {array} database.Job "List of active jobs" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /jobs/active [get]

func (*ServerHandler) GetAllDimensions added in v0.21.4

func (serverHandler *ServerHandler) GetAllDimensions(c echo.Context) error

GetAllDimensions returns all dimension definitions with their values @Summary Get all dimensions @Description Retrieve all dimension types and their possible values @Tags Dimensions @Accept json @Produce json @Success 200 {array} database.DimensionWithValues @Failure 500 {object} map[string]interface{} @Router /api/dimensions [get]

func (*ServerHandler) GetAllTags added in v0.21.4

func (serverHandler *ServerHandler) GetAllTags(c echo.Context) error

GetAllTags returns all available tags @Summary Get all tags @Description Retrieve all tags in the system @Tags Tags @Accept json @Produce json @Success 200 {array} database.Tag @Failure 500 {object} map[string]interface{} @Router /api/tags [get]

func (*ServerHandler) GetDocument

func (serverHandler *ServerHandler) GetDocument(context echo.Context) error

GetDocument will return a document by ULID @Summary Get a document by ID @Description Retrieve document details by ULID @Tags Documents @Accept json @Produce json @Param id path string true "Document ULID" @Success 200 {object} database.Document "Document details" @Failure 404 {object} map[string]interface{} "Document not found" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /document/{id} [get]

func (*ServerHandler) GetDocumentDimensions added in v0.21.4

func (serverHandler *ServerHandler) GetDocumentDimensions(c echo.Context) error

GetDocumentDimensions returns dimension values for a specific document @Summary Get document dimensions @Description Get all dimension values assigned to a document @Tags Dimensions @Accept json @Produce json @Param ulid path string true "Document ULID" @Success 200 {object} map[string]database.DimensionValue @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/documents/{ulid}/dimensions [get]

func (*ServerHandler) GetDocumentFileSystem

func (serverHandler *ServerHandler) GetDocumentFileSystem(context echo.Context) error

GetDocumentFileSystem will scan the document folder and get the complete tree to send to the frontend @Summary Get document filesystem tree @Description Retrieve the complete document folder structure as a tree @Tags Documents @Accept json @Produce json @Success 200 {object} fullFileSystem "Complete filesystem tree" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /documents/filesystem [get]

func (*ServerHandler) GetDocumentTags added in v0.21.4

func (serverHandler *ServerHandler) GetDocumentTags(c echo.Context) error

GetDocumentTags returns all tags for a specific document @Summary Get document tags @Description Get all tags associated with a document @Tags Tags @Accept json @Produce json @Param ulid path string true "Document ULID" @Success 200 {array} database.Tag @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/documents/{ulid}/tags [get]

func (*ServerHandler) GetDocumentThumbnail added in v0.19.5

func (serverHandler *ServerHandler) GetDocumentThumbnail(context echo.Context) error

GetDocumentThumbnail serves the thumbnail image for a document @Summary Get document thumbnail @Description Get a thumbnail image for a document by its ID @Tags Documents @Produce image/jpeg @Param id path string true "Document ULID" @Success 200 {file} binary "Thumbnail image" @Failure 404 {object} map[string]string "Thumbnail not found" @Failure 500 {object} map[string]string "Internal server error" @Router /api/document/{id}/thumbnail [get]

func (*ServerHandler) GetFolder

func (serverHandler *ServerHandler) GetFolder(context echo.Context) error

GetFolder fetches all the documents in the folder @Summary Get folder contents @Description Retrieve all documents in a specific folder @Tags Folders @Accept json @Produce json @Param folder path string true "Folder name" @Success 200 {array} database.Document "List of documents in folder" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /folder/{folder} [get]

func (*ServerHandler) GetJob

func (serverHandler *ServerHandler) GetJob(c echo.Context) error

GetJob retrieves a job by ID @Summary Get job by ID @Description Retrieve details of a specific job by its ID @Tags Jobs @Accept json @Produce json @Param id path string true "Job ID (ULID)" @Success 200 {object} database.Job "Job details" @Failure 400 {object} map[string]interface{} "Invalid job ID" @Failure 404 {object} map[string]interface{} "Job not found" @Router /jobs/{id} [get]

func (*ServerHandler) GetLatestDocuments

func (serverHandler *ServerHandler) GetLatestDocuments(context echo.Context) error

GetLatestDocuments gets the latest documents that were ingressed @Summary Get latest documents @Description Retrieve the most recently ingested documents with pagination @Tags Documents @Accept json @Produce json @Param page query int false "Page number (default: 1)" @Success 200 {object} map[string]interface{} "Paginated documents with metadata" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /documents/latest [get]

func (*ServerHandler) GetRecentJobs

func (serverHandler *ServerHandler) GetRecentJobs(c echo.Context) error

GetRecentJobs retrieves recent jobs with pagination @Summary Get recent jobs @Description Retrieve a list of recent jobs with pagination @Tags Jobs @Accept json @Produce json @Param limit query int false "Number of jobs to return (default: 20)" @Param offset query int false "Offset for pagination (default: 0)" @Success 200 {array} database.Job "List of jobs" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /jobs [get]

func (*ServerHandler) GetWordCloud

func (serverHandler *ServerHandler) GetWordCloud(c echo.Context) error

GetWordCloud returns the top N most frequent words for word cloud visualization @Summary Get word cloud data @Description Retrieve the top N most frequent words from all documents for word cloud visualization @Tags WordCloud @Accept json @Produce json @Param limit query int false "Maximum number of words to return (default: 100, max: 500)" @Success 200 {object} map[string]interface{} "Word cloud data with words, metadata, and count" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /wordcloud [get]

func (*ServerHandler) IngestDocumentWithSteps

func (serverHandler *ServerHandler) IngestDocumentWithSteps(filePath string, db database.Repository, jobID ulid.ULID, fileNum, totalFiles int) error

IngestDocumentWithSteps processes a document through explicit steps with progress tracking Step 1: Calculate hash and create initial database record Step 2: Move file to documents folder and verify hash Step 3: Extract text and update search/wordcloud

func (*ServerHandler) InitializeSchedules

func (serverHandler *ServerHandler) InitializeSchedules(db database.Repository)

InitializeSchedules starts all the cron jobs (currently just one)

func (*ServerHandler) LogFromFrontend added in v0.23.0

func (serverHandler *ServerHandler) LogFromFrontend(c echo.Context) error

LogFromFrontend receives and logs messages from the frontend using slog @Summary Log from frontend @Description Accept log entries from the frontend and log them using slog with proper structure @Tags Admin @Accept json @Produce json @Param logEntry body LogEntry true "Log entry from frontend" @Success 200 {object} map[string]string "Log entry recorded" @Failure 400 {object} map[string]string "Invalid log format" @Router /api/log [post]

func (*ServerHandler) MoveDocuments

func (serverHandler *ServerHandler) MoveDocuments(context echo.Context) error

MoveDocuments will accept an API call from the frontend to move a document or documents @Summary Move documents to a new folder @Description Move one or more documents to a different folder in the document tree @Tags Documents @Accept json @Produce json @Param folder query string true "Target folder path" @Param id query []string true "Document ULID(s) to move" @Success 200 {string} string "Ok" @Failure 400 {object} map[string]interface{} "Bad request" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /document/move [patch]

func (*ServerHandler) RecalculateWordCloud

func (serverHandler *ServerHandler) RecalculateWordCloud(c echo.Context) error

RecalculateWordCloud triggers a full recalculation of word frequencies @Summary Recalculate word cloud @Description Trigger a full recalculation of word frequencies from all documents @Tags WordCloud @Accept json @Produce json @Success 200 {object} map[string]interface{} "Recalculation started" @Router /wordcloud/recalculate [post]

func (*ServerHandler) ReindexSearchDocuments

func (serverHandler *ServerHandler) ReindexSearchDocuments(context echo.Context) error

ReindexSearchDocuments reindexes all documents for full-text search @Summary Reindex search documents @Description Rebuild the full-text search index for all documents @Tags Search @Accept json @Produce json @Success 200 {object} map[string]interface{} "Reindex successful" @Failure 500 {object} map[string]interface{} "Reindex failed" @Router /search/reindex [post]

func (*ServerHandler) RemoveDocumentDimension added in v0.21.4

func (serverHandler *ServerHandler) RemoveDocumentDimension(c echo.Context) error

RemoveDocumentDimension removes a dimension value from a document @Summary Remove document dimension @Description Remove a dimension value assignment from a document @Tags Dimensions @Accept json @Produce json @Param ulid path string true "Document ULID" @Param dimensionName path string true "Dimension name" @Success 204 @Failure 400 {object} map[string]interface{} @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/documents/{ulid}/dimensions/{dimensionName} [delete]

func (*ServerHandler) RemoveDocumentTag added in v0.21.4

func (serverHandler *ServerHandler) RemoveDocumentTag(c echo.Context) error

RemoveDocumentTag removes a tag from a document @Summary Remove tag from document @Description Remove a tag association from a document @Tags Tags @Accept json @Produce json @Param ulid path string true "Document ULID" @Param tagId path int true "Tag ID" @Success 204 @Failure 400 {object} map[string]interface{} @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/documents/{ulid}/tags/{tagId} [delete]

func (*ServerHandler) RunIngestNow

func (serverHandler *ServerHandler) RunIngestNow(c echo.Context) error

RunIngestNow triggers the ingestion process manually @Summary Trigger document ingestion @Description Manually trigger the document ingestion process to process files in the ingress folder @Tags Admin @Accept json @Produce json @Success 200 {object} map[string]interface{} "Job created with job ID" @Router /ingest [post]

func (*ServerHandler) SearchDocuments

func (serverHandler *ServerHandler) SearchDocuments(context echo.Context) error

SearchDocuments will take the search terms and search all documents using PostgreSQL full-text search @Summary Search documents @Description Search all documents using PostgreSQL full-text search @Tags Search @Accept json @Produce json @Param term query string true "Search term" @Success 200 {object} fullFileSystem "Search results" @Success 204 "No results found" @Failure 404 {string} string "Empty search term" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /search [get]

func (*ServerHandler) SetDocumentDimension added in v0.21.4

func (serverHandler *ServerHandler) SetDocumentDimension(c echo.Context) error

SetDocumentDimension sets a dimension value for a document @Summary Set document dimension @Description Set or update a dimension value for a document @Tags Dimensions @Accept json @Produce json @Param ulid path string true "Document ULID" @Param dimension body object true "Dimension assignment" @Success 200 {object} map[string]interface{} @Failure 400 {object} map[string]interface{} @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/documents/{ulid}/dimensions [post]

func (*ServerHandler) StartupChecks

func (serverHandler *ServerHandler) StartupChecks() error

StartupChecks performs all the checks to make sure everything works

func (*ServerHandler) UpdateTag added in v0.21.4

func (serverHandler *ServerHandler) UpdateTag(c echo.Context) error

UpdateTag updates an existing tag @Summary Update a tag @Description Update tag properties @Tags Tags @Accept json @Produce json @Param id path int true "Tag ID" @Param tag body database.Tag true "Tag object" @Success 200 {object} database.Tag @Failure 400 {object} map[string]interface{} @Failure 404 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/tags/{id} [put]

func (*ServerHandler) UploadDocuments

func (serverHandler *ServerHandler) UploadDocuments(context echo.Context) error

UploadDocuments handles documents uploaded from the frontend @Summary Upload a document @Description Upload a new document file to the ingress folder for processing @Tags Documents @Accept multipart/form-data @Produce json @Param path formData string false "Upload path (relative to ingress folder)" @Param file formData file true "Document file to upload" @Success 200 {string} string "Path to uploaded file" @Failure 400 {object} map[string]interface{} "Bad request" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /document/upload [post]

func (*ServerHandler) ViewDocument added in v0.29.0

func (serverHandler *ServerHandler) ViewDocument(context echo.Context) error

ViewDocument serves the actual document file by ULID @Summary View/download a document file @Description Serve the actual document file for viewing or download @Tags Documents @Produce application/pdf,image/png,image/jpeg,application/octet-stream @Param ulid path string true "Document ULID" @Success 200 {file} binary "Document file" @Failure 404 {object} map[string]interface{} "Document not found" @Failure 500 {object} map[string]interface{} "Internal server error" @Router /document/view/{ulid} [get]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL