Services
Lariv employs a hybrid architecture where the core logic and real-time UI interactions occur in the Python/Django layer, but heavy workloads or stateful long-running background processes are delegated to internal microservices.
The services/ Directory
Services are typically implemented in other languages suitable for high concurrency, primarily Go (Golang), and are located in the /services root directory.
This directory is structured similarly to /plugins but for standalone applications rather than Django apps.
Async Workload Delegation
A prime example is the delegation of AI tasks. When a plugin requires AI completion from an external provider (like Gemini): 1. The synchronous UI Django thread cannot wait safely for a 15-second generation. 2. The payload is enqueued into an internal SQLite queue shared with the internal Go sidecar service. 3. The Go microservice independently consumes the queue, processes the long-running generation via the LLM provider, and updates the shared state. 4. The client browser running the HTMX frontend simply polls the Django representation of that queue object via HTMX to get the final result.
This prevents tying up ASGI worker threads and removes heavy third-party SDK dependencies (like LangChain) from the Python environment.
Service Integration
Usually, a simple wrapper Django app sits inside the services/ directory alongside the external service source code (e.g., apps.py and services.py). This Python wrapper app handles booting up the underlying external service via subprocess or utils.run_exe during the Django ready() phase.