An intelligent, RAG-based legal ecosystem for Algerian law. Features an autonomous AI agent for legal queries, automated monitoring of the Journal Officiel (JORADP), and a step-by-step procedure navigator.
# Hokoki AI
Hokoki AI is a legal AI backend platform built in TypeScript. It provides a REST API for Algerian law retrieval, contract compliance analysis, and legal procedure guidance.
## Project description
Houqouqi AI helps non-specialist users and legal professionals access Algerian law information and compliance guidance through an AI-powered service layer. The backend connects:
- legal document indexing from official Algerian law PDFs,
- vector search and retrieval,
- structured contract compliance analysis,
- step-by-step legal procedure guidance.
The project is designed as a backend service with REST endpoints. It currently includes no frontend client within the repository.
## Folder structure
- `src/main.ts`
- Starts the Elysia server and registers API routes.
- `src/api/`
- `laws/`: endpoints for legal chat and law indexing.
- `contract/`: endpoints for contract analysis and PDF contract processing.
- `procedure/`: endpoints for legal procedure guidance.
- `src/core/`
- `llm.ts`: Groq LLM configuration.
- `embeddings.ts`: embeddings configuration.
- `vectorstore.ts`: Chroma vector store connector.
- `memory.ts`: in-memory session history storage.
- `src/modules/`
- `laws/`: law indexing service, RAG chain, and PDF source catalog.
- `contract/`: compliance chain, prompts, and schemas.
- `procedure/`: procedure classification guide chain and procedures catalog.
- `src/shared/`
- `pdf/`: PDF fetch and parsing utilities.
- `types/`: shared type definitions.
- `src/tests/`
- Unit and integration tests for API controllers, services, and schemas.
## Main functions
- `src/main.ts`
- Bootstraps the app and exposes `/health` plus grouped `/api` routes.
- `src/api/*/*.ts`
- Validation and controller logic for each service area.
- `src/core/llm.ts`
- Uses `ChatGroq` with `llama-3.3-70b-versatile`.
- `src/core/vectorstore.ts`
- Connects to a Chroma vector database using env vars.
- `src/core/memory.ts`
- Maintains per-session chat history in memory.
- `src/shar …