A simple, secure note-taking API built with FastAPI and SQLModel, featuring JWT authentication, AI-powered features, and a well-organized codebase.
- JWT Authentication - Secure user authentication with JSON Web Tokens
- Note Management - Create, read, update, and delete notes with ownership control
- Public Notes - Share notes publicly while keeping private notes secure
- User System - User registration and management with password hashing
- Tag & Keyword System - Organize notes with tags and keywords
- RESTful API - Clean, documented API endpoints
- SQLite Database - Lightweight database with SQLModel ORM
- Auto Documentation - Interactive API docs at
/docs
- Auto-Summarize - Generate concise summaries of your notes
- Content Extension - Expand notes with AI-generated insights
- Translation - Translate notes to any language
- Auto-Tagging - AI suggests relevant tags and categories
- Keyword Extraction - Automatically extract key terms and topics
- Sentiment Analysis - Analyze emotional tone of notes
- Related Notes - Find connections between your notes
src/
├── api/ # API endpoints
│ ├── auth.py # Authentication endpoints (login, user info)
│ ├── notes.py # Note CRUD + AI features (summarize, extend, translate, etc.)
│ ├── tags.py # Tag and keyword management endpoints
│ ├── users.py # User management
│ └── health.py # Health check endpoint
├── models/ # Data models
│ ├── note.py # Note models (Note, NoteBase, NoteResponse)
│ ├── user.py # User models (User, UserBase, UserResponse)
│ └── tag.py # Tag and Keyword models with association tables
├── database/ # Database layer
│ ├── connection.py # Database connection and session management
│ ├── note_crud.py # CRUD operations for notes
│ ├── user_crud.py # CRUD operations for users
│ ├── tag_crud.py # CRUD operations for tags
│ └── keyword_crud.py # CRUD operations for keywords
├── utils/ # Utility functions
│ ├── auth.py # Password hashing and verification
│ └── jwt.py # JWT token creation and verification
├── config/ # Configuration
│ └── settings.py # Application settings and environment variables
└── main.py # FastAPI app setup and router registration
- Clone the repository
- Install dependencies:
pip install -r requirements.txt- Run the application:
uvicorn src.main:app --reloadThe API will be available at http://localhost:8000
POST /auth/login- User login and JWT token generationGET /auth/me- Get current user information (requires authentication)
POST /user/create- Create a new user accountGET /user/list- List all users (requires authentication)
GET /notes- Get all notes (requires authentication)POST /notes/create- Create a new note (requires authentication)GET /notes/{id}- Get a specific note (requires authentication, ownership check)PUT /notes/{id}- Update a note (requires authentication, ownership required)DELETE /notes/{id}- Delete a note (requires authentication, ownership required)GET /notes/public- Get all public notes (no authentication required)
GET /notes/{id}/summarize- Generate AI summary of a noteGET /notes/{id}/extend- Extend note content with AI insightsGET /notes/{id}/translate/{target_language}- Translate note to target languageGET /notes/{id}/auto-tag- Get AI-suggested tags and categoriesGET /notes/{id}/keywords- Extract keywords and main topicsGET /notes/{id}/sentiment- Analyze emotional sentimentGET /notes/{id}/related- Find related notes
GET /tags- Get all tags for current userPOST /tags- Create a new tagDELETE /tags/{tag_id}- Delete a tagGET /notes/{note_id}/tags- Get all tags for a notePOST /notes/{note_id}/tags/{tag_id}- Add tag to noteDELETE /notes/{note_id}/tags/{tag_id}- Remove tag from note
GET /keywords- Get all keywords for current userPOST /keywords- Create a new keywordDELETE /keywords/{keyword_id}- Delete a keywordGET /notes/{note_id}/keywords- Get all keywords for a notePOST /notes/{note_id}/keywords/{keyword_id}- Add keyword to noteDELETE /notes/{note_id}/keywords/{keyword_id}- Remove keyword from note
GET /health- Health check endpoint
The API uses JWT (JSON Web Tokens) for authentication:
- Create a user:
POST /user/create - Login to get token:
POST /auth/loginwith form datausernameandpassword - Use the token: Include
Authorization: Bearer <token>header in protected requests
Tokens expire after 30 minutes (configurable via ACCESS_TOKEN_EXPIRE_MINUTES).
JustNotes integrates with a local LLM API for AI-powered features:
- Local LLM Server: Runs on
http://localhost:1234/api/v1/chat - Model: Uses
google/gemma-3n-e4bfor all AI operations - Privacy: All AI processing happens locally, no data sent to external services
- Features: Summarization, content extension, translation, auto-tagging, keyword extraction, sentiment analysis, and note relationship discovery
- Install and run a local LLM server (e.g., LM Studio, Ollama)
- Configure it to listen on
http://localhost:1234 - Load the
google/gemma-3n-e4bmodel - AI features will automatically become available
- Password Hashing - Uses bcrypt for secure password storage
- JWT Tokens - Secure token-based authentication
- Ownership Control - Users can only modify their own notes, tags, and keywords
- Public/Private Notes - Granular access control for note visibility
- Input Validation - Pydantic models for request/response validation
- User Isolation - Tags and keywords are user-specific
The application uses environment variables for configuration. Create a .env file:
DATABASE_URL=sqlite:///db.sqlite
SECRET_KEY=your-secret-key-change-in-production
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
APP_NAME=JustNotes
APP_VERSION=0.0.1
APP_DESCRIPTION=JustNotes is a simple note-taking appInteractive API documentation is available at:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
The codebase follows FastAPI best practices with:
- Separation of concerns - API, models, database, utils clearly separated
- Dependency injection - Database sessions and CRUD instances via FastAPI DI
- Modular CRUD operations - Separate files for each model (note_crud.py, user_crud.py, tag_crud.py, keyword_crud.py)
- Type safety - Comprehensive type hints and Pydantic validation
- Clean architecture - Modular components with clear responsibilities
- Many-to-many relationships - Tags and keywords linked to notes via association tables
JustNotes includes full Docker support for easy deployment and development.
- Clone and setup:
git clone https://github.com/DatMayo/JustNotes.git
cd JustNotes
cp .env.example .env
# Edit .env with your settings- Production deployment:
docker-compose up -d- Development with hot reload:
docker-compose -f .docker/docker-compose.dev.yml up- Dockerfile: Multi-stage build with Python 3.11 slim
- docker-compose.yml: Production-ready with health checks
- .docker/: Separate development and production configurations
- .dockerignore: Optimized build context
All configuration is handled through environment variables with JUSTNOTES_ prefix:
# Database
JUSTNOTES_DATABASE_URL=sqlite:///app/data/db.sqlite
# JWT Security
JUSTNOTES_SECRET_KEY=your-secret-key-change-in-production
JUSTNOTES_ALGORITHM=HS256
JUSTNOTES_ACCESS_TOKEN_EXPIRE_MINUTES=30
# Application
JUSTNOTES_APP_NAME=JustNotes
JUSTNOTES_APP_VERSION=0.0.1
JUSTNOTES_APP_DESCRIPTION=JustNotes is a simple note-taking app
# Environment
JUSTNOTES_ENVIRONMENT=production
JUSTNOTES_DEBUG=false
JUSTNOTES_HOST=0.0.0.0
JUSTNOTES_PORT=8000
JUSTNOTES_RELOAD=false# Build image
docker build -t justnotes .
# Run container
docker run -p 8000:8000 -v $(pwd)/data:/app/data justnotes
# Development with reload
docker-compose -f .docker/docker-compose.dev.yml up --build
# Production deployment
docker-compose -f .docker/docker-compose.prod.yml up -d
# View logs
docker-compose logs -f
# Stop containers
docker-compose down- SQLite database stored in
./data/directory - Automatic volume mounting for data persistence
- Database survives container restarts
- Built-in health check endpoint at
/health - Automatic container restart on failure
- Monitoring ready for production deployment
This project is licensed under the MIT License - see the LICENSE file for details.