{"id":22447280,"url":"https://github.com/yahrdev/engram_async","last_synced_at":"2025-03-27T11:26:28.664Z","repository":{"id":258547315,"uuid":"874144475","full_name":"yahrdev/EnGram_async","owner":"yahrdev","description":"The API generates tests for English grammar learning and can be used as a backend for English learning-related projects. The app was built using Quart with asynchronous programming and has two endpoints: gettests and updatestatus. ","archived":false,"fork":false,"pushed_at":"2024-10-18T11:09:57.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-19T14:07:14.213Z","etag":null,"topics":["aioredis","alembic","async","asyncio","pydantic","pytest-asyncio","quart","sqlalchemy"],"latest_commit_sha":null,"homepage":"","language":"Python","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/yahrdev.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-10-17T10:26:48.000Z","updated_at":"2024-10-18T11:10:01.000Z","dependencies_parsed_at":"2024-10-20T13:40:31.508Z","dependency_job_id":null,"html_url":"https://github.com/yahrdev/EnGram_async","commit_stats":null,"previous_names":["yahrdev/engram_async"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahrdev%2FEnGram_async","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahrdev%2FEnGram_async/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahrdev%2FEnGram_async/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahrdev%2FEnGram_async/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yahrdev","download_url":"https://codeload.github.com/yahrdev/EnGram_async/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245834751,"owners_count":20680071,"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":["aioredis","alembic","async","asyncio","pydantic","pytest-asyncio","quart","sqlalchemy"],"created_at":"2024-12-06T04:15:35.859Z","updated_at":"2025-03-27T11:26:28.641Z","avatar_url":"https://github.com/yahrdev.png","language":"Python","readme":"# EnGram Async API\n\nThe **API** generates tests for English grammar learning and can be used as a backend for English learning-related projects.\n\nThe app was built using **Quart** with asynchronous programming and has two endpoints: `gettests` and `updatestatus`.\n\n- The first endpoint generates one test each time it's called.\n- The second endpoint updates the date and time when the test was displayed on the frontend.\n\nWhen the `gettests` endpoint is called, the app retrieves a fixed number of tests from the database and stores them in the cache. Users receive one test from the cache per call, which helps reduce database requests for every endpoint call. The tests are sorted by the datetime_shown field, so the test that was shown the longest time ago is displayed first. The `updatestatus` endpoint simply records the datetime when a test is shown, keeping the database up to date.\n\n## Technologies Used\n\n- **Quart**: For building the web API with asynchronous capabilities.\n- **SQLAlchemy**: For ORM functionality with MySQL.\n- **Alembic**: To handle database migrations.\n- **aiomysql**: MySQL client for asynchronous programming.\n- **Aioredis**: Used for managing the cache layer asynchronously.\n- **Pydantic**: For data validation.\n- **quart_schema**: For request and response validation.\n- **pytest-asyncio**: For writing and running asynchronous unit tests.\n\n## Installation\n\n### 1. Clone the repository\n\n```bash\ngit clone https://github.com/yourusername/EnGram_async.git\n```\n\n### 2. Navigate into the project directory\n\n```bash\ncd EnGram_async\n```\n\n### 3. Install the dependencies\n\n```bash\npip install -r requirements.txt\n```\n\n### 4. Set up the environment\n\nCreate .env and .test.env files based on the provided examples. \n\n### 5. Set up the database\n\nCreate the database in MySQL and initialize and apply migrations:\n\n```bash\nalembic init migrations\nalembic revision --autogenerate -m \"Database creation\"\nalembic upgrade c14ac4dc5999  # Use your own revision ID from the generated migration file\n```\n\nYou can use that [Initial Migration Script](https://github.com/yahrdev/EnGram_async/blob/main/migrations/versions/2b12ec7d4cd1_database_creation.py) which is provided in this repository.\nAlso populate the database with data. \n\n### 6. Set up Redis\n\nDownload Redis and place the folder on disk C (for example). Open a command prompt and navigate to the Redis folder:\n\n```bash\ncd C:\\Redis\n```\n\nSet up configuration files. You can either modify the redis.windows.conf or create two copies: redis-prod.conf and redis-test.conf, and specify different ports in each file.\nStart Redis servers:\n\n```bash\nredis-server.exe redis-test.conf\n```\n\n```bash\nredis-server.exe redis-prod.conf\n```\n\n### 7. Run the application\n\n```bash\npython api/app.py\n```\n\n### 8. Testing\n\n```bash\npytest -v tests/test_api.py  \n```\n\nAnd check Swagger: http://127.0.0.1:8000/docs\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyahrdev%2Fengram_async","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyahrdev%2Fengram_async","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyahrdev%2Fengram_async/lists"}