Afelu Memory is a multilingual operations assistant for small businesses. It turns conversations into durable business memory, retrieves the right context in later sessions, and converts time-sensitive commitments into clear next actions.
Built for the CockroachDB × AWS Hackathon: Build with Agentic Memory.
Small-business knowledge often lives in chat threads and in the owner's head: a customer's delivery promise, a supplier price change, or a minimum-margin rule. Ordinary chat assistants lose that context between sessions. Afelu Memory preserves only durable, useful facts and shows how recalled memories influence each response.
- A business owner describes a customer promise, supplier change, or operating rule.
- Amazon Titan Text Embeddings V2 converts the message into a 1,024-dimension vector.
- CockroachDB stores the memory event, structured metadata, embedding, tasks, and audit records in one system of record.
- A later request performs tenant-scoped semantic retrieval through a CockroachDB prefix-column vector index.
- Amazon Nova Lite receives the retrieved context through the Bedrock Converse API and returns a response plus an optional durable memory or follow-up task.
- The application records which memories influenced the run, making the agent's behavior inspectable.
Browser
|
v
Next.js application on AWS
|-- Amazon Bedrock Converse --> Amazon Nova Lite
|-- Amazon Bedrock InvokeModel --> Titan Text Embeddings V2
`-- PostgreSQL wire protocol --> CockroachDB Cloud
|-- structured memory and tasks
|-- VECTOR(1024) embeddings
`-- tenant-prefixed distributed vector index
The runtime never sends database or AWS credentials to the browser. tenant_id is the prefix column of the semantic index and is constrained in every retrieval query.
- Next.js 15, React 19, and TypeScript
- Amazon Bedrock with the EU Nova Lite inference profile
- Amazon Titan Text Embeddings V2
- CockroachDB Cloud for persistent state and distributed vector search
- CockroachDB Cloud Managed MCP Server for schema inspection and operational verification
- AWS hosting for the functional application
- Node.js 20–24
- A CockroachDB Cloud cluster
- AWS credentials with permission to invoke the configured Bedrock models in
eu-west-1
npm install
cp .env.example .env.localSet DATABASE_URL to a TLS-enabled CockroachDB connection string. Keep the verified defaults for:
AWS_REGION=eu-west-1
BEDROCK_CHAT_MODEL_ID=eu.amazon.nova-lite-v1:0
BEDROCK_EMBEDDING_MODEL_ID=amazon.titan-embed-text-v2:0
AFELU_DEMO_MODE=falseOn AWS, set DATABASE_SECRET_ID instead of DATABASE_URL. The SSR compute role reads the connection URL from AWS Secrets Manager at runtime, so the credential is not written into Amplify build artifacts.
Use ccloud to open the cluster SQL shell:
ccloud cluster sql <cluster-name>Apply db/schema.sql in that shell or with the CockroachDB SQL client and a privileged migration identity:
cockroach sql --url "$DATABASE_URL" --file db/schema.sqlThen start the application:
npm run devOpen http://localhost:3000.
db/schema.sql creates:
memory_events: durable facts, source text, importance, timestamps, and 1,024-dimension embeddingstasks: open, completed, or cancelled follow-up workagent_runs: retrieved memory IDs and outcome flags for each runaudit_log: tenant-scoped operational audit recordstenants: workspace identity and locale
The semantic index is defined as:
VECTOR INDEX memory_events_semantic_idx
(tenant_id, embedding vector_cosine_ops)CockroachDB must have vector indexing enabled before applying the schema. Use a privileged migration identity for schema changes and a separate least-privilege identity for the application runtime.
AFELU_DEMO_MODE=true is an explicit local-only presentation mode with synthetic data and deterministic responses. It is never enabled implicitly. The judged deployment must use AFELU_DEMO_MODE=false with live CockroachDB and Bedrock integrations.
npm run typecheck
npm run lint
npm run build
npm audit --omit=devFor an end-to-end check, enter a durable fact, start a later conversation, and verify that:
- a row and vector were written to
memory_events; - the later response reports at least one retrieved memory;
- the corresponding
agent_runsrow contains the retrieved memory ID; - any requested follow-up appears in
tasks.
The Managed MCP connection can be kept read-only for this inspection.
- Use IAM Identity Center for administrators and an IAM role for the deployed workload.
- Grant only
bedrock:InvokeModelfor the models used by the application. - Store
DATABASE_URLin a server-side secret store; never expose it throughNEXT_PUBLIC_*variables. - On Amplify Hosting, attach a least-privilege SSR compute role and store the database URL in AWS Secrets Manager.
- Use TLS for every CockroachDB connection.
- Use synthetic business data in the public demo.
- Add authenticated tenant membership and authorization checks before admitting external workspaces.