_# Ajatuskumppani - Technical Architecture
This document provides a detailed overview of the technical architecture of the Ajatuskumppani project.
The system is designed as a modular, microservice-based architecture. The core components are:
- AjatusUI: The user-facing application.
- AjatusServer: The central backend service.
- AjatusCore: The AI model and inference engine.
- AjatusMemory: The long-term memory and user profile service.
- AjatusNode: The decentralized compute nodes.
- AjatusAgents: Autonomous agents for specific tasks.
- AjatusToken: The blockchain-based token.
- Authentication: JWT-based authentication with access and refresh tokens.
- API: RESTful API for all standard operations. WebSockets for real-time communication with AjatusUI.
- Database: PostgreSQL with
pgvectorfor structured data and vector embeddings. SQLAlchemy as the ORM. - Caching: Redis for caching frequently accessed data and for message queuing.
- Task Orchestration: Celery for background tasks and for orchestrating the AjatusAgents.
- Model: Fine-tuned version of Mistral 7B Instruct.
- Inference: vLLM for high-throughput serving on GPUs. Ollama as a fallback and for CPU-based inference.
- API: A simple internal API for the AjatusServer to get model completions.
- Embedding Generation: Uses
sentence-transformersto generate embeddings for user interactions. - Vector Storage:
pgvectorfor storing and querying embeddings. FAISS for in-memory indexing and faster retrieval. - User Profile: A service that continuously updates a user's profile based on their interactions and retrieved memories.
- Compute Environment: Docker containers for securely and isolating AI tasks.
- Proof-of-Contribution: A custom algorithm that measures uptime, performance, and task validation to reward nodes.
- Networking: A P2P network for communication between nodes.
- State Management: Zustand for simple and scalable state management.
- API Communication: Axios for REST API calls and the native WebSocket API for real-time updates.
- Styling: Tailwind CSS for a consistent and modern look and feel.
- Contract: An ERC-20 compliant token contract.
- Staking: A staking contract that allows users to lock up their tokens and earn rewards.
- Governance: A governance contract that allows token holders to vote on proposals.
- A user interacts with the AjatusUI.
- The UI sends a request to the AjatusServer.
- The server authenticates the user and processes the request.
- If the request requires AI completion, the server sends a prompt to the AjatusCore.
- The AjatusCore returns the completion to the server.
- The server stores the interaction and its embedding in the AjatusMemory.
- The server returns the response to the UI.
- All communication between services is encrypted with TLS.
- User data is encrypted at rest.
- The AjatusNode uses Docker containers to isolate tasks and prevent malicious code from accessing the host system.
- Regular security audits will be performed.
