Skip to content

aahadaazar/smart-notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Smart Note Project

Smart Note Project is a full-stack note intelligence app that turns raw notes into structured knowledge. You can paste unstructured text, generate a concise summary with topic tags, persist the note, and later retrieve related notes through semantic search.

The project is intentionally simple at the UI layer and more interesting in the data flow: local LLM summarization with Ollama, structured note storage in Supabase, vector indexing in Pinecone, and a FastAPI service that coordinates the whole pipeline.

What The App Does

1. Summarize notes

The user pastes free-form note text into the React app. The backend sends that text to Ollama, asks for a structured JSON response, and returns:

  • a generated summary
  • a list of extracted tags

2. Persist note metadata

After summarization, the backend stores the original note content, generated summary, and tags in Supabase.

3. Build vector representations

The backend generates an embedding for the original note text with Ollama and upserts it into Pinecone using the Supabase note ID as the vector ID.

4. Search semantically

When a user searches, the backend embeds the query, retrieves similar vectors from Pinecone, then hydrates full note records from Supabase and returns ranked matches to the frontend.

Architecture

flowchart LR
    U[User] --> F[React + Vite Frontend]
    F -->|POST /api/summarize| B[FastAPI Backend]
    F -->|POST /api/search| B

    B --> O[Ollama]
    B --> S[Supabase]
    B --> P[Pinecone]

    O -->|summary + tags| B
    O -->|embeddings| B
    B -->|store note record| S
    B -->|upsert/query vectors| P
    S -->|note rows| B
    P -->|similar ids + scores| B
    B --> F
Loading

Request Flows

Summarization flow

sequenceDiagram
    participant UI as Frontend
    participant API as FastAPI
    participant LLM as Ollama
    participant DB as Supabase
    participant VS as Pinecone

    UI->>API: POST /api/summarize { content }
    API->>LLM: summarize prompt
    LLM-->>API: { summary, tags }
    API->>DB: insert note record
    DB-->>API: inserted note id
    API->>LLM: embed original note
    LLM-->>API: embedding vector
    API->>VS: upsert vector by note id
    API-->>UI: { summary, tags }
Loading

Search flow

sequenceDiagram
    participant UI as Frontend
    participant API as FastAPI
    participant LLM as Ollama
    participant VS as Pinecone
    participant DB as Supabase

    UI->>API: POST /api/search { query, top_k }
    API->>LLM: embed query
    LLM-->>API: query embedding
    API->>VS: similarity search
    VS-->>API: note ids + scores
    API->>DB: fetch matching note rows
    DB-->>API: full note records
    API-->>UI: ranked results
Loading

Repository Structure

smart-note-project/
├── README.md
├── backend/
│   ├── main.py
│   ├── pyproject.toml
│   ├── README.md
│   ├── models/
│   │   ├── search.py
│   │   └── summarize.py
│   ├── routes/
│   │   ├── search.py
│   │   ├── search_test.py
│   │   └── summarize.py
│   └── services/
│       ├── ollama_client.py
│       ├── supabase_client.py
│       └── vector_store.py
└── frontend/
    ├── package.json
    ├── vite.config.ts
    ├── README.md
    └── src/
        ├── App.tsx
        ├── main.tsx
        ├── components/
        │   └── Navbar.tsx
        ├── lib/
        │   └── api.ts
        └── pages/
            ├── search.tsx
            └── summarizer.tsx

Tech Stack

Frontend

  • React 19
  • TypeScript
  • Vite
  • React Router
  • Axios
  • Tailwind CSS v4

Backend

  • Python 3.12+
  • FastAPI
  • Uvicorn
  • Pydantic

AI And Data Services

  • Ollama for local LLM inference and embeddings
  • Supabase for note persistence
  • Pinecone for vector storage and similarity search

Current Project Design

Frontend responsibilities

  • Provide a summarization screen
  • Provide a semantic search screen
  • Call the backend through a single API client
  • Render summaries, tags, and search results

Backend responsibilities

  • Expose REST endpoints
  • Build prompts for Ollama
  • Parse structured summary output
  • Store note records in Supabase
  • Create embeddings
  • Upsert and query vectors in Pinecone

Data responsibilities

  • Supabase stores canonical note data
  • Pinecone stores retrieval vectors keyed by note ID
  • Ollama provides both summarization and embeddings

Backend Modules

backend/main.py

  • creates the FastAPI app
  • configures CORS for the local Vite dev server
  • mounts the summarize and search routers

backend/routes/summarize.py

  • accepts note content
  • calls Ollama for summary and tags
  • inserts the note into Supabase
  • generates an embedding and stores it in Pinecone

backend/routes/search.py

  • embeds the search query
  • queries Pinecone for similar note IDs
  • fetches full note records from Supabase
  • returns ranked results

backend/services/ollama_client.py

  • builds the summarization prompt
  • calls the llama3 chat model
  • parses JSON-like output
  • generates embeddings with all-minilm

backend/services/supabase_client.py

  • loads environment variables
  • initializes the shared Supabase client

backend/services/vector_store.py

  • loads Pinecone configuration
  • creates the index if it does not already exist
  • exposes the shared index handle and upsert helper

Frontend Modules

frontend/src/pages/summarizer.tsx

  • collects raw note input
  • sends note text to the backend
  • renders the returned summary and tags

frontend/src/pages/search.tsx

  • captures a search query
  • requests semantically similar notes
  • renders note content and tags for each hit

frontend/src/lib/api.ts

  • centralizes HTTP calls to the backend
  • uses VITE_API_URL when provided
  • falls back to http://localhost:8000/api

Local Development Setup

Prerequisites

  • Node.js 20+
  • npm
  • Python 3.12+
  • uv for Python dependency management
  • Ollama installed locally
  • Supabase project with a notes table
  • Pinecone account and API key

1. Clone the project

git clone <your-repo-url>
cd smart-note-project

2. Install frontend dependencies

cd frontend
npm install
cd ..

3. Install backend dependencies

cd backend
pip install uv
uv sync
cd ..

4. Pull required Ollama models

ollama pull llama3
ollama pull all-minilm

5. Configure backend environment variables

Create backend/.env:

SUPABASE_URL=your_supabase_project_url
SUPABASE_KEY=your_supabase_service_or_api_key
PINECONE_API_KEY=your_pinecone_api_key
PINECONE_INDEX=smart-notes
PINECONE_ENVIRONMENT=us-east-1

6. Configure frontend environment variables

Create frontend/.env if you want to override the API base URL:

VITE_API_URL=http://localhost:8000/api

7. Create the Supabase table

The backend expects a notes table compatible with this schema:

create table notes (
  id uuid primary key default gen_random_uuid(),
  content text not null,
  summary text not null,
  tags text[] not null default '{}',
  created_at timestamptz not null default now()
);

8. Run the backend

cd backend
uv run python main.py

The API will be available at:

  • http://localhost:8000
  • http://localhost:8000/docs

9. Run the frontend

cd frontend
npm run dev

The frontend dev server will be available at http://localhost:5173.

API Reference

GET /

Basic health check.

Response:

{
  "message": "Hello!"
}

POST /api/summarize

Summarizes note content, extracts tags, saves the note, and indexes it for search.

Request:

{
  "content": "FastAPI is a modern Python framework for building APIs."
}

Response:

{
  "summary": "FastAPI is a modern Python API framework focused on speed and developer productivity.",
  "tags": ["python", "fastapi", "api"]
}

POST /api/search

Embeds a query, retrieves similar note vectors, and returns hydrated note records.

Request:

{
  "query": "python api framework",
  "top_k": 3
}

Response:

{
  "results": [
    {
      "id": "note-id",
      "content": "FastAPI is a modern Python framework for building APIs.",
      "tags": ["python", "fastapi", "api"],
      "score": 0.82
    }
  ]
}

Production Considerations

This repo already demonstrates a strong architecture direction, but a production deployment should tighten a few areas:

  • Move secrets into a real secret manager instead of local .env files
  • Replace permissive local-only CORS config with environment-specific settings
  • Add authentication and user-scoped note ownership
  • Add request validation limits for note size and query size
  • Add structured logging, tracing, and metrics
  • Add retry and timeout policies around external services
  • Make summarization and indexing asynchronous jobs for better latency and resilience
  • Add database migrations instead of relying on manual schema creation
  • Add test coverage for route behavior and service failure modes
  • Add CI for linting, type-checking, tests, and build verification

Known Gaps In The Current Codebase

These are worth knowing up front if you plan to extend the project:

  • The frontend is functional but intentionally minimal
  • The backend uses print-based logging rather than structured observability
  • The summarize path does not fail the request if Pinecone indexing fails
  • Ollama response parsing is tolerant but not schema-enforced
  • There is no auth, rate limiting, or multi-tenant isolation yet
  • There are no automated tests wired into the repo today
  • backend/routes/search_test.py is a standalone experiment script, not an app route
  • The backend starts external clients at import time, so invalid env config can fail startup early

Suggested Roadmap

If you want to turn this into a stronger portfolio or product repo, these are the highest-leverage next steps:

  1. Add authentication and per-user note collections.
  2. Introduce background jobs for summarization and indexing.
  3. Add note history, editing, and re-indexing workflows.
  4. Return summaries in search results to improve scanability.
  5. Add filtering by tags and created date.
  6. Add tests for the API and a mocked integration layer for Ollama, Supabase, and Pinecone.
  7. Containerize the app with Docker Compose for one-command local setup.
  8. Add deployment manifests for the frontend and backend.

Demo Checklist

If you are reviewing the repo, this is the fastest way to validate it:

  1. Start Ollama and pull llama3 and all-minilm.
  2. Configure Supabase and Pinecone.
  3. Run the backend on port 8000.
  4. Run the frontend on port 5173.
  5. Create a note through the Summarize page.
  6. Search for related concepts from the Search page.

Contributing

Contributions are easiest when they preserve the current separation of concerns:

  • UI and routing changes in frontend/src
  • API contracts in backend/models
  • HTTP behavior in backend/routes
  • external service logic in backend/services

For larger changes, prefer adding documentation for:

  • new environment variables
  • schema changes
  • external dependency assumptions
  • failure and retry behavior

License

No license file is currently included in this repository. If you plan to publish or accept external contributions, add a license explicitly.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors