{"id":18711352,"url":"https://github.com/bukhavtsov/smart-dictionary","last_synced_at":"2025-04-10T02:41:53.337Z","repository":{"id":219590683,"uuid":"749413995","full_name":"bukhavtsov/smart-dictionary","owner":"bukhavtsov","description":"The Smart Dictionary is a language-learning tool designed to provide real-time translations, word suggestions, and definitions, helping users improve their vocabulary while engaging with foreign texts.","archived":false,"fork":false,"pushed_at":"2024-12-07T22:41:20.000Z","size":102,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T04:12:02.180Z","etag":null,"topics":["ai","authentication","chatgpt","docker","echo","go","golang","jwt","postgres","rest-api"],"latest_commit_sha":null,"homepage":"https://lexihero.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bukhavtsov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-28T14:17:54.000Z","updated_at":"2024-12-26T11:28:11.000Z","dependencies_parsed_at":"2024-04-03T22:25:17.507Z","dependency_job_id":"54dabb73-285b-4c20-aeee-c598c1d35355","html_url":"https://github.com/bukhavtsov/smart-dictionary","commit_stats":null,"previous_names":["bukhavtsov/smart-dictionary"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bukhavtsov%2Fsmart-dictionary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bukhavtsov%2Fsmart-dictionary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bukhavtsov%2Fsmart-dictionary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bukhavtsov%2Fsmart-dictionary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bukhavtsov","download_url":"https://codeload.github.com/bukhavtsov/smart-dictionary/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248144964,"owners_count":21055017,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","authentication","chatgpt","docker","echo","go","golang","jwt","postgres","rest-api"],"created_at":"2024-11-07T12:38:44.977Z","updated_at":"2025-04-10T02:41:53.318Z","avatar_url":"https://github.com/bukhavtsov.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Smart Dictionary\n\nThe **Smart Dictionary** is a language-learning tool designed to provide real-time translations, word suggestions, and definitions, helping users improve their vocabulary while engaging with foreign texts. Built in Go, this project offers an easy-to-use API for word translations and personalized vocabulary tracking, powered by external translation APIs.\n\n## Features\n\n- **Real-time Translation**: Context-aware translation for multiple languages.\n- **Word Definitions**: Fetch definitions for selected words in a variety of languages.\n- **Token-Based Authentication**: JWT-based authentication for secure API access.\n- **Integration with GPT and External APIs**: Leverages GPT models and translation services for high-quality translations.\n- **Dockerized Deployment**: Easily build and run the application with Docker.\n\n## Folder Structure\n\n```bash\nsmart-dictionary/\n├── Dockerfile                  # Docker image configuration\n├── README.md                   # Project documentation\n├── cmd/\n│   └── main.go                 # Main application entry point\n├── db/\n│   └── init.sql                # Database initialization script\n├── docker-compose.yaml         # Docker Compose configuration\n├── go.mod                      # Go module file\n├── go.sum                      # Go module dependencies\n└── internal/\n    ├── domain/                 # Core domain logic\n    │   ├── auth.go             # Authentication domain logic\n    │   ├── chat_gpt.go         # GPT model integration\n    │   ├── languages.go        # Supported languages definitions\n    │   ├── token.go            # JWT token handling\n    │   ├── translation.go      # Translation domain logic\n    │   └── translation_request.go # Translation request handling\n    ├── infrastructure/         # Repositories and external service integration\n    │   ├── auth_repository.go  # User authentication repository\n    │   ├── mochi_api.go        # Mochi API integration for translations\n    │   └── translator_repository.go # Translation repository\n    ├── middleware/             # Middleware for handling requests\n    │   └── auth.go             # JWT authentication middleware\n    ├── server/                 # Server-related code\n    │   └── translator_server.go # HTTP server and API routes\n    └── usecase/                # Application services and business logic\n        ├── auth_service.go     # Authentication service\n        └── jwt.go              # JWT-related business logic\n```\n\n## Getting Started\n\n### Prerequisites\n\nTo run this project locally, you'll need:\n\n- **Go** (version 1.18 or higher)\n- **Docker** (for containerized deployment)\n- **PostgreSQL** (as the database engine)\n\n### Installation\n\n1. **Clone the repository**:\n\n   ```bash\n   git clone https://github.com/bukhavtsov/smart-dictionary.git\n   ```\n\n2. **Navigate into the project directory**:\n\n   ```bash\n   cd smart-dictionary\n   ```\n\n3. **Set up the environment**:\n\n   Configure your environment variables by creating a `.env` file or using the provided `.env.tmp` as a template.\n\n### Running the Application\n\nYou can run the application either directly or using Docker.\n\n#### 1. Run Locally with Go\n\nMake sure to have the necessary Go modules installed:\n\n```bash\ngo mod tidy\n```\n\nThen, run the application:\n\n```bash\ngo run cmd/main.go\n```\n\nThe app will be available at `http://localhost:8080`.\n\n#### 2. Run via Docker\n\nBuild the Docker image:\n\n```bash\ndocker build -t smart-dict .\n```\n\nRun the application using Docker:\n\n```bash\ndocker run --env-file .env.tmp -p 8080:8080 smart-dict\n```\n\nAlternatively, use `docker-compose` to spin up the application and any dependencies (e.g., database):\n\n```bash\ndocker-compose --env-file .env.tmp up -d\n```\n\n### Database Initialization\n\nThe application uses PostgreSQL as its database. You can initialize the database schema with the SQL file provided in the `db/` folder. If you're using Docker, this is handled automatically by the `docker-compose.yaml` file.\n\nFor manual setup:\n\n1. Create a PostgreSQL database.\n2. Run the `db/init.sql` script to create necessary tables.\n\n## API Endpoints\n\nThe application exposes various endpoints for translations and user management. Below are key endpoints:\n\n- **POST** `/translate` - Translate a word or phrase.\n- **POST** `/login` - User authentication.\n- **POST** `/register` - User registration.\n- **GET** `/languages` - Fetch supported languages for translation.\n\n## Testing\n\nTo run the tests:\n\n```bash\ngo test ./...\n```\n\nMake sure that your testing environment is properly set up with mock services or a test database.\n\n## Docker\n\n### Build and Run the Docker Image\n\nTo build the Docker image:\n\n```bash\ndocker build -t smart-dict .\n```\n\nRun the application using the built image:\n\n```bash\ndocker run --env-file .env.tmp -p 8080:8080 smart-dict\n```\n\n### Using Docker Compose\n\nYou can also run the application with `docker-compose`, which will handle the database and any additional services:\n\n```bash\ndocker-compose up --build\n```\n\n### Environment Variables\n\nMake sure to configure the `.env` file with the necessary environment variables, such as:\n\n- `DB_HOST`: Database host\n- `DB_USER`: Database user\n- `DB_PASSWORD`: Database password\n- `JWT_SECRET`: Secret for JWT token signing\n\n## Contributing\n\nWe welcome contributions! To contribute to the Smart Dictionary project:\n\n1. Fork the repository.\n2. Create a feature branch (`git checkout -b feature/new-feature`).\n3. Make your changes and commit them (`git commit -m 'Add new feature'`).\n4. Push your branch (`git push origin feature/new-feature`).\n5. Open a pull request.\n\nPlease ensure that your code adheres to the project guidelines and includes relevant tests.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Contact\n\nFor any issues or suggestions, feel free to create an issue in the repository or reach out to the maintainers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbukhavtsov%2Fsmart-dictionary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbukhavtsov%2Fsmart-dictionary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbukhavtsov%2Fsmart-dictionary/lists"}