MOS is a lightweight memory infrastructure service for LLM applications. It provides long-term memory storage, semantic retrieval over embeddings, prompt context construction, and memory expiration support.
The service is implemented as a Node.js + TypeScript backend with PostgreSQL + pgvector for vector search, and a small Flask embedding microservice using Sentence Transformers.
- Store user-scoped memories with importance, category, and optional expiration
- Perform semantic search using pgvector embeddings
- Build contextual prompt content from relevant memories
- Compress memory text blocks for prompt efficiency
- Docker Compose support for local deployment
src/— backend source codepython-service/— embedding servicescripts/— database schema and migration filesdocker-compose.yml— local container orchestrationDockerfile— backend production imagedocs/DOCS.md— full documentation
docker compose up --buildThen use the API at http://localhost:3000.
- Install Node dependencies:
npm install- Start PostgreSQL with
pgvectorinstalled. - Initialize the database:
createdb mos
psql -d mos -f scripts/setup-db.sql
psql -d mos -f scripts/migration-003-add-expiration.sql- Start the embedding service:
cd python-service
pip install -r requirements.txt
python app.py- Start the backend:
npm run devThe Compose stack starts:
postgres(pgvector/pgvector:pg16-latest)embedding(Python Flask embedding service)backend(Node.js MOS API)
Default database connection values:
- user:
postgres - password:
password - database:
mos
If this is the first time starting Docker Compose, the initial schema from scripts/setup-db.sql is applied automatically.
POST /memories— create a memoryGET /memories/:userId— list active memories for a userPUT /memories/:id— update memory importanceDELETE /memories/:id— delete a memory
POST /search— semantic search over memoriesPOST /context— build a prompt context string from relevant memoriesPOST /compress— combine text blocks into a compressed string
scripts/setup-db.sqlsets up the basememoriestable and vector extensionscripts/migration-003-add-expiration.sqladdsexpires_atplus expiration filtering
For an existing database, run migrations manually with psql. Fresh Docker Compose setups only apply the base schema automatically.
See docs/DOCS.md for a complete guide, including detailed API examples, environment configuration, and migration instructions.