AI-engineered flashcard application for language learning with intelligent translation features.
A comprehensive Go REST API with PostgreSQL database integration, OpenAI-powered translations with caching, and Supabase local development setup.
- 🤖 AI Translation Generation - Generate translations on-demand with 1-hour caching
- 📝 Manual Card Creation - Full control over flashcard content
- 🎯 Translation Tracking - Know which fields were AI-generated
- 🌍 Multi-language Support - Any ISO 639-1 language pair
- 📚 Study Mode - Random flashcard selection with optional AI hints
- 🔄 Full CRUD - Complete REST API for flashcard management
The project requires a .env file for local development. This file is already provided when you clone the repository and contains the necessary environment variables:
DB_URL- PostgresQL database connection stringPORT- Application port (defaults to 8080)
Make sure Docker is running, then use the provided Makefile commands:
# Start Supabase local development environment
make db-start
# Run database migrations
make db-up# Run directly
make run
# Or build and run
make build
./.bin/flashcardsThe application will start on http://localhost:10000 (or the port specified in your .env file).
make build- Build the application binarymake run- Run the application directlymake clean- Clean build artifacts
make db-start- Start Supabase local developmentmake db-stop- Stop Supabase local developmentmake db-up- Run database migrations
Full API documentation is available in the OpenAPI specification (v2.0.0).
POST /flashcards/translate- Generate AI translation with caching
POST /flashcards- Create a new flashcard (both question and answer required)GET /flashcards- Get all flashcardsGET /flashcards/{id}- Get a specific flashcard by IDPUT /flashcards/{id}- Update a flashcardDELETE /flashcards/{id}- Delete a flashcardGET /flashcards/random- Get a random flashcard with optional AI hint
GET /health- Application health status
Creating a Flashcard with AI Translation:
-
Generate Translation:
POST /flashcards/translate { "content": "hello", "from_lang": "en", "to_lang": "el" } # Returns: {"translation": "γεια σας", "cached": false} -
Create Flashcard:
POST /flashcards { "question": "hello", "answer": "γεια σας", "question_lang": "en", "answer_lang": "el", "ai_translated_answer": true }
See Testing Guide for more examples.
- Translation Caching: Generated translations are cached for 1 hour
- AI Tracking: Track which fields were AI-generated vs manually entered
- Multi-language: Support for any ISO 639-1 language pair (en, el, fr, de, es, etc.)
- Validation: Smart input validation with helpful error messages
- Study Mode: Random flashcard selection for practice sessions
The application uses environment-based configuration managed through the config package. Key configuration options:
- DB_URL: PostgresQL database connection string (required)
- PORT: Application port (optional, defaults to 8080)
- OPENAI_API_KEY: OpenAI API key for AI translation features (optional)
The project uses PostgresQL with Supabase for local development:
- Local Database: Accessible at
localhost:54322 - Supabase Studio: Available at
http://localhost:54323 - API: Available at
http://localhost:54321
Database schema is managed through SQL migrations located in: supabase/migrations/.