# Mnemly - Quiz Question Generator
A FastAPI application that generates multiple-choice quiz questions using AI, with support for both direct text input and Weaviate-based document retrieval.
## Features
- **Text-based Generation**: Create quiz questions from any text content
- **Search-based Generation**: Retrieve documents from Weaviate and generate questions
- **Two-step Workflow**: Search documents first, then select which ones to use for generation
- **Question Management**: View, organize, and tag questions in a table format
- **CSV Export**: Export all questions with metadata to CSV
- **Modern UI**: Bootstrap-based interface with HTMX for dynamic interactions
## Tech Stack
- **Backend**: FastAPI with SQLAlchemy (SQLite)
- **AI**: DSPy with Anthropic Claude for question generation
- **Search**: Weaviate vector database for document retrieval
- **Frontend**: HTMX + Bootstrap for interactive UI
- **Package Management**: uv for dependency management
## Installation
1. **Clone the repository**:
```bash
git clone
cd memly
```
2. **Install dependencies with uv**:
```bash
uv install
```
3. **Set up environment variables**:
```bash
cp .env.example .env
# Edit .env with your API keys and configuration
```
4. **Run the application**:
```bash
uv run uvicorn app.main:app --reload
```
5. **Open your browser**:
Navigate to `http://localhost:8000`
## Configuration
Create a `.env` file with the following variables:
```env
# Anthropic API Configuration
ANTHROPIC_MODEL_NAME=claude-sonnet-4-20250514
ANTHROPIC_API_KEY=your_anthropic_api_key_here
# Weaviate Configuration
WEAVIATE_URL=your_weaviate_cluster_url
WEAVIATE_API_KEY=your_weaviate_api_key
WEAVIATE_COLLECTION_NAME=your_collection_name
WEAVIATE_TEXT_FIELD=text_field_name
```
## Usage
### Generate Questions from Text
1. Go to the "Generate" tab
2. Select "From Text"
3. Paste your content in the text area
4. Choose the number of questions
5. Click "Generate Questions"
### Generate Questions from Search
1. Go to the "Generate" tab
2. Select "From Search"
3. Enter your search query
4. Choose number of results to retrieve
5. Click "Search Documents"
6. Review retrieved documents and select which ones to use
7. Choose number of questions and click "Generate Questions"
### Manage Questions
- **View Questions**: Browse all questions in table format
- **Filter by Tags**: Use tag buttons to filter questions
- **Add Tags**: Click "Add Tag" on any question
- **Export**: Click "Export CSV" to download all questions
## API Endpoints
- `GET /` - Home dashboard
- `GET /questions` - Questions table view
- `GET /generate` - Question generation interface
- `POST /api/generate-from-text` - Generate from text input
- `POST /api/search-documents` - Search Weaviate for documents
- `POST /api/generate-from-retrieved` - Generate from selected documents
- `GET /api/export-csv` - Export questions to CSV
## Database Schema
### Questions Table
- `id` - Primary key
- `content` - Question text
- `correct_answer` - A, B, C, or D
- `option_a/b/c/d` - Answer options
- `source_text` - Original source content
- `search_query` - Search query used (if applicable)
- `created_at` - Timestamp
### Tags Table
- `id` - Primary key
- `name` - Tag name
- `color` - Display color
## Development
### Project Structure
```
memly/
� app/
� � main.py # FastAPI application
� � models/
� � � database.py # SQLAlchemy models
� � � schemas.py # Pydantic models
� � services/
� � � question_generator.py # DSPy question generation
� � � question_service.py # Database operations
� � � weaviate_service.py # End-to-end search+generation
� � � weaviate_retriever.py # Document search only
� � routers/
� � � api.py # API endpoints
� � templates/ # Jinja2 HTML templates
� static/ # Static assets
� .env # Environment variables
� pyproject.toml # Dependencies
```
### Key Components
- **Question Generation**: Uses DSPy with Anthropic Claude for structured generation
- **Document Retrieval**: WeaviateRM for semantic search
- **Database Layer**: Service pattern with Pydantic validation
- **Frontend**: HTMX for dynamic interactions without JavaScript frameworks
## Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request
## License
[Add your license here]