A personal notes app with an AI assistant that answers questions from your own notes (RAG) and can call tools to search notes, past chats, and the web.
Status: completed, no longer actively maintained.
View Demo
·
Report Bug
·
Request Feature
Table of Contents
Synapse is a personal knowledge assistant that turns notes into a queryable knowledge base. Users create notes, the system generates embeddings in the background, and the AI service answers questions using RAG. It is a small polyglot microservices project with clear boundaries between product features, AI infrastructure, and asynchronous work: each service owns its own runtime, its own database, and its own reason for existing.
The core path:
Login
↓
Create / manage notes
↓
Generate embeddings (async)
↓
Ask questions about personal notes
↓
Retrieve relevant notes (hybrid search)
↓
Generate a streamed, grounded AI answer
| Component | Stack | Responsibility |
|---|---|---|
| Auth | Hono + better-auth on Bun | Authentication and user identity, JWT issuance via cookie, JWKS exposure |
| Notes | Java Spring Boot | Note domain APIs + PostgreSQL persistence, JWT verification via JWKS |
| AI Service | Hono on Node.js | RAG, embeddings, streaming generation, agent tools, JWT verification via JWKS |
| Gateway | Kong | Edge routing and rate limiting |
| Client | React + Vite + TanStack Router/Query + shadcn | User interface |
| Database | Neon (serverless PostgreSQL) + pgvector | One logical database per service, shared Neon project |
| Async | Google Cloud Pub/Sub | Decoupled event delivery (note.created) |
| Deployment | Google Cloud Run | Serverless, scale-to-zero hosting for every service |
There is no RBAC layer: a valid JWT is enough to authorize a request, since every user only accesses their own data. This was a deliberate scope decision (see ADR-0005).
Each service owns its own logical database. All three live inside a single shared Neon project as separate logical databases, not separate physical clusters.
flowchart TB
subgraph Client
UI["React + Vite<br/>TanStack Router/Query + shadcn"]
end
subgraph Gateway
KONG["Kong Gateway<br/>Routing · Rate Limiting"]
end
subgraph Services
AUTH["Auth Service<br/>Hono + better-auth · Bun<br/>Issues JWT via cookie<br/>Exposes JWKS"]
NOTES["Notes Service<br/>Spring Boot<br/>CRUD · Verifies JWT via JWKS"]
AI["AI Service<br/>Hono · Node.js<br/>RAG · Agent tools<br/>Verifies JWT via JWKS"]
end
subgraph NeonProject["Neon Project - shared instance, isolated logical DBs"]
direction LR
AUTHDB[("auth_db")]
NOTESDB[("notes_db")]
AIDB[("ai_db<br/>+ pgvector")]
end
TOPIC([" Pub/Sub: note.created "])
GEMINI["Gemini API<br/>(Google AI Studio)"]
UI -->|HTTPS| KONG
KONG --> AUTH
KONG --> NOTES
KONG --> AI
NOTES -.->|fetch JWKS, cached| AUTH
AI -.->|fetch JWKS, cached| AUTH
AUTH --> AUTHDB
NOTES --> NOTESDB
AI --> AIDB
NOTES -->|publish| TOPIC
TOPIC -->|"consume at /pubsub/note-events"| AI
AI -->|embed + generate| GEMINI
style Client fill:#1e293b,stroke:#3b82f6,color:#fff
style Gateway fill:#1e293b,stroke:#f59e0b,color:#fff
style AUTH fill:#1e293b,stroke:#ef4444,color:#fff
style NOTES fill:#1e293b,stroke:#22c55e,color:#fff
style AI fill:#1e293b,stroke:#a855f7,color:#fff
style NeonProject fill:#0a0f1a,stroke:#475569,color:#94a3b8
style GEMINI fill:#0f172a,stroke:#8b5cf6,color:#fff
| Layer | What it does |
|---|---|
| Client | Login, notes management, and chat UI |
| Kong | Single entry point; request routing and rate limiting (JWT verification happens downstream, not at Kong, see ADR-0002) |
| Auth Service | Owns authentication, issues JWT via HTTP-only cookie, exposes JWKS |
| Notes Service | Owns notes CRUD and the Notes database; verifies JWT via JWKS |
| AI Service | Owns retrieval, embeddings, generation, and agent tools; verifies JWT via JWKS |
| Auth DB / Notes DB / AI DB | Data owned by the matching service (the AI DB holds pgvector embeddings) |
| Pub/Sub | Async boundary for note.created |
Request flow (RAG chat example):
- The client sends a request through Kong.
- AI Service verifies the JWT locally using a JWKS public key cached from Auth.
- The model decides whether to call tools.
searchNotesruns hybrid retrieval (full-text + vector, fused with Reciprocal Rank Fusion) against the AI service's own database. - Retrieved notes are used as context for the answer.
- The response is streamed back to the client.
Async flow:
note.created
↓
Pub/Sub
↓
AI Service (/pubsub/note-events)
↓
AI DB / pgvector
The AI service separates provider access (keys and models) from product features (chat, titles, embeddings).
chat / title / embeddings
↓
providers/ai-studio.ts (getChatModel, getTitleModel, getEmbeddingModel)
↓
providers/router.ts (pick(task) → healthy key + model)
↓
Google AI Studio (Gemini)
The router holds several API keys and an ordered fallback chain of models for each task (chat, title, embed). When a (key, model) pair hits a rate limit or quota error, it is put on a cooldown and the next healthy pair is used. This logic has a unit test in services/ai/src/providers/router.test.ts.
note
↓
embedding (768 dimensions)
↓
AI DB / pgvector (HNSW index, cosine distance)
↓
hybrid retrieval (PostgreSQL full-text rank + vector, Reciprocal Rank Fusion)
↓
fallback to recent notes when nothing matches
↓
prompt context
↓
streamed answer
The chat model can call three tools: searchNotes, searchChatHistories, and searchWeb, and decides which ones to use for each question.
The AI service and Notes service both verify JWTs independently, without calling the Auth service on every request:
request
↓
resource service (Notes or AI)
↓
JWKS cache
↓
local JWT signature verification
- The AI service uses
josewith a module-levelcreateRemoteJWKSet(). - The Notes service uses Spring Security's OAuth2 Resource Server, following the same fetch-cache-verify model.
If the Auth service is briefly unavailable, Notes and AI keep verifying tokens signed with keys they already cached. A newly rotated signing key needs a successful JWKS refresh first.
Synapse is designed to be runnable locally before any cloud deployment.
curl -fsSL https://bun.sh/install | bash- Node.js (LTS)
- Java 21+
- Docker & Docker Compose
- A Google AI Studio (Gemini) API key
- A Neon project (optional, local PostgreSQL + pgvector is included in Docker Compose)
- Clone the repo
git clone https://github.com/wynn-nguyen-dev/Synapse.git
cd Synapse- Configure environment variables for each service
cp services/ai/.env.example services/ai/.env
# set the Gemini API key(s), database URL, JWKS URL, Pub/Sub settings
# repeat for services/auth and services/notes where an example file exists- Start the backend stack (PostgreSQL + pgvector, Pub/Sub emulator, migrations, Auth, AI, Notes, Kong)
docker compose up -d- Start the client
cd client
npm install
npm run devMinimum smoke test:
sign in
→ create a note
→ embedding generated (via Pub/Sub)
→ ask a question
→ retrieve the relevant note
→ receive a grounded AI answer
The application was deployed to Google Cloud Run with Neon as the database and Google Cloud Pub/Sub for events, and the client on Vercel. Each Cloud Run service runs with min-instances: 0 (scale-to-zero), trading occasional cold-start latency for near-zero idle cost. Deployment is a manual workflow in .github/workflows/deploy-showcase.yaml.
- Sign in and create a few notes.
- Open the chat and ask a question that your notes can answer, ideally using different words than the note.
- Ask something your notes do not cover and see how the assistant responds.
- Ask a question that needs earlier conversation or the web to see the other tools.
ADR-0001: Runtime chosen per workload, not standardized
Status: Accepted
Context: The system spans distinct workload types: a lightweight auth service, a data-heavy core domain, and an AI service dependent on a specific SDK ecosystem.
Decision: Auth runs on Bun; Notes runs on Java Spring Boot; the AI service runs on Node.js.
Consequences: Each service gets a runtime suited to it (fast cold-start vs. enterprise reliability vs. AI SDK maturity), at the cost of managing multiple build/tooling pipelines.
ADR-0002: JWT verification at the resource service
Status: Accepted
Notes and AI verify JWTs independently via a JWKS public key fetched from Auth and cached, instead of calling Auth on every request or verifying at Kong.
Why: Resource servers keep working during a temporary Auth outage as long as the signing key is already cached; services stay loosely coupled and language-agnostic in how they verify tokens.
Trade-off: Each service instance maintains its own JWKS cache, and a newly rotated key requires a successful refresh before it can be used. Verification logic is duplicated across Notes and AI rather than centralized at Kong.
ADR-0003: Google Cloud Pub/Sub for async events
Status: Accepted
Context: Synchronous embedding generation blocked the Notes service on the AI service's response, coupling note-creation latency to the Gemini API response time.
Decision: Use Google Cloud Pub/Sub for note.created events, since all services already run on Cloud Run and benefit from a managed, serverless-native messaging layer.
Consequences: No message broker to operate manually, at the cost of coupling to one cloud provider's messaging semantics. Retry and dead-letter handling were not built.
ADR-0004: Neon + Cloud Run instead of self-managed Kubernetes
Status: Accepted
Context: A full local Kubernetes setup (kind) was built and tested first: Dockerfiles, manifests, ConfigMaps, Kong-on-k8s routing, and DNS-based service discovery. Running that same setup on GKE 24/7 would incur real compute cost even when idle, disproportionate to the project's scale.
Decision: Deploy all services to Google Cloud Run (pay-per-request, scale-to-zero) with Neon as a serverless PostgreSQL provider.
Consequences: Near-zero idle cost and no cluster to maintain, at the cost of less fine-grained control over networking and scheduling. The kind setup remains in infra/k8s as a reference because it directly informed this decision.
ADR-0005: No RBAC in current scope
Status: Accepted
Context: The project's core value is the RAG and agent experience, not access control granularity, and every user only accesses their own notes.
Decision: Skip role-based access control; a valid JWT alone is sufficient to authorize a request.
Consequences: Simpler auth logic; revisiting RBAC would be a deliberate future decision rather than an oversight.
ADR-0006: Kong as the single gateway across all services
Status: Accepted
Context: With services written in different languages, a language-agnostic entry point avoids duplicating routing and rate-limiting logic per service.
Decision: Kong routes requests to all backend services; JWT verification itself happens downstream at each resource service (see ADR-0002), not at Kong.
Consequences: Centralized routing and a single base URL for the client; verification logic is duplicated across Notes and AI, accepted as a reasonable trade-off for service independence.
This project was completed as a case study and stopped before the following were done:
- No evaluation suite. Retrieval and answer quality were checked by hand, not measured.
- Light test coverage. Only the model router has a unit test.
- No notification or reminder service. The Pub/Sub design could support it, but it was never built.
- No retry or dead-letter handling for failed
note.createdevents. - No RBAC, by design (ADR-0005).
- Cold starts on Cloud Run make the first request after idle slow.
This project is no longer actively maintained, but feedback is welcome.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch
- Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Nguyên (Wynn) - @wynn-nguyen-dev
Project Link: https://github.com/wynn-nguyen-dev/Synapse
AI coding assistants were used during development. Architecture, service boundaries, and the retrieval design were decided by the author, and changes were read and tested before merging.