{"id":29311475,"url":"https://github.com/ashaffah/actix-sea-orm","last_synced_at":"2026-05-17T06:38:12.872Z","repository":{"id":301885347,"uuid":"1010522329","full_name":"ashaffah/actix-sea-orm","owner":"ashaffah","description":"Rust Actix SeaORM example","archived":false,"fork":false,"pushed_at":"2025-07-06T05:57:15.000Z","size":97,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-07T08:14:56.989Z","etag":null,"topics":["actix-web","mysql","rust","sea-orm","sea-orm-migrations","seeder"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ashaffah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2025-06-29T08:51:47.000Z","updated_at":"2025-07-06T05:57:18.000Z","dependencies_parsed_at":"2025-06-29T12:29:12.245Z","dependency_job_id":"e1937a00-7740-4e47-8ae5-8dc1c43e8454","html_url":"https://github.com/ashaffah/actix-sea-orm","commit_stats":null,"previous_names":["ashaffah/actix-sea-orm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ashaffah/actix-sea-orm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashaffah%2Factix-sea-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashaffah%2Factix-sea-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashaffah%2Factix-sea-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashaffah%2Factix-sea-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashaffah","download_url":"https://codeload.github.com/ashaffah/actix-sea-orm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashaffah%2Factix-sea-orm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279032418,"owners_count":26089383,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["actix-web","mysql","rust","sea-orm","sea-orm-migrations","seeder"],"created_at":"2025-07-07T08:14:54.166Z","updated_at":"2025-10-15T00:36:31.187Z","avatar_url":"https://github.com/ashaffah.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# actix-sea-orm\n\nA Rust web application example demonstrating the integration of **Actix Web** with **SeaORM** for database operations and **Tera** for templating. This project also includes QR code generation functionality using the `qirust` library.\n\n## Features\n\n- **CRUD Operations**: Create, read, update, and delete posts using SeaORM with a MySQL database.\n- **Pagination and Search**: List posts with pagination and search functionality.\n- **Template Rendering**: Uses Tera templates for rendering HTML pages (`index.html.tera`, `new.html.tera`, `edit.html.tera`, `404.html.tera`, `500.html.tera`).\n- **QR Code Generation**: Generate QR codes as SVG or PNG images with customizable options (size, color, border, frame style, etc.).\n- **RESTful API**: Public routes for QR code generation under `/public/v1`.\n\n## Dependencies\n\nKey dependencies used in the project:\n\n- `actix-web`: Web framework for building the API and handling HTTP requests.\n- `sea-orm`: Asynchronous ORM for MySQL database interactions.\n- `tera`: Template engine for rendering HTML pages.\n- `qirust`: Library for generating QR codes.\n- `image`: Image processing for QR code generation.\n- `serde`: Serialization and deserialization for handling JSON data.\n- `dotenvy`: Loads environment variables from a `.env` file.\n- `env_logger`: Logging configuration.\n\nSee `Cargo.toml` for the full list of dependencies.\n\n## Setup\n\n1. **Clone the Repository**:\n\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd actix-sea-orm\n   ```\n\n2. **Set Up Environment Variables**:\n   Create a `.env` file in the root directory with the following:\n\n   ```\n   DATABASE_URL=mysql://\u003cusername\u003e:\u003cpassword\u003e@\u003chost\u003e:\u003cport\u003e/\u003cdatabase\u003e\n   ```\n\n   Replace `\u003cusername\u003e`, `\u003cpassword\u003e`, `\u003chost\u003e`, `\u003cport\u003e`, and `\u003cdatabase\u003e` with your MySQL credentials.\n\n3. **Install Dependencies**:\n\n   ```bash\n   cargo build\n   ```\n\n4. **Run Migrations**:\n   Ensure your MySQL database is running, then apply migrations:\n\n   ```bash\n   cargo run -p migration -- up\n   ```\n\n5. **Seed the Database** (Optional):\n   Populate the database with initial data:\n\n   ```bash\n   cargo run -p seeder -- up\n   ```\n\n6. **Run the Application**:\n   Start the Actix Web server:\n\n   ```bash\n   cargo run\n   ```\n\n   The application will be available at `http://localhost:8080`.\n\n## Usage\n\n### Post Management\n\n- **List Posts**: `GET /`\n\n  - Query parameters: `page`, `per_page`, `search`\n  - Example: `http://localhost:8080/?page=1\u0026per_page=10\u0026search=example`\n  - Returns a paginated list of posts with optional search filtering.\n\n- **Create Post**: `GET /new` and `POST /`\n\n  - `GET /new`: Renders a form to create a new post.\n  - `POST /`: Submits the form to create a post and redirects to `/`.\n\n- **Edit Post**: `GET /{id}` and `POST /{id}`\n\n  - `GET /{id}`: Renders a form to edit the post with the specified `id`.\n  - `POST /{id}`: Updates the post and redirects to `/`.\n\n- **Delete Post**: `POST /delete/{id}`\n  - Deletes the post with the specified `id` and redirects to `/`.\n\n### QR Code Generation\n\n- Query parameters: `data`, `size`, `color`, `border`, `inner_px`, `frame_style`, `scale`, `ecc`, `bg_color`\n\n- **Generate SVG QR Code**: `POST /public/v1/qr`\n\n  - Payload: `{ \"data\": \"\u003cstring\u003e\" }`\n  - Returns a JSON response with the SVG string.\n\n- **Generate PNG QR Code**: `GET /public/v1/qr`\n\n  - Example: `http://localhost:8080/public/v1/qr?data=https://example.com\u0026size=500x500\u0026color=000000`\n  - Returns a PNG image of the QR code.\n\n- **Generate Framed QR Code**: `GET /public/v1/frameqr`\n  - Similar query parameters to `/qr`, with additional support for framing (uses `gh.png` from static assets).\n  - Returns a PNG image with a framed QR code.\n  - Example: `http://localhost:8000/api/public/v1/frameqr?data=https://example.com\u0026color=000000\u0026size=325x325\u0026border=1\u0026inner_px=10\u0026frame_style=\u0026scale=16\u0026ecc=H`\n\n## Templates\n\nThe application uses Tera templates located in the templates directory:\n\n- `index.html.tera`: Displays the list of posts.\n- `new.html.tera`: Form for creating a new post.\n- `edit.html.tera`: Form for editing an existing post.\n- `404.html.tera`: Custom 404 error page.\n- `500.html.tera`: Custom 500 error page.\n\nEnsure these templates are configured in your `AppsConfig` for proper rendering.\n\n## Error Handling\n\n- **Database Errors**: Returns HTTP 500 with a JSON error message or renders `500.html.tera`.\n- **Not Found**: Returns HTTP 404 with `404.html.tera` for invalid post IDs.\n- **Template Errors**: Returns HTTP 500 with a generic error message if Tera fails to render.\n\n## Notes\n\n- The QR code generation uses the `qirust` library, which supports customizable QR codes with options like error correction level (`ecc`), frame styles, and colors.\n- The application assumes a MySQL database is configured via the `DATABASE_URL` environment variable.\n- Static assets (e.g., `gh.png` for framed QR codes) should be placed in `src/static/images/`.\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashaffah%2Factix-sea-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashaffah%2Factix-sea-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashaffah%2Factix-sea-orm/lists"}