{"id":15031701,"url":"https://github.com/aarambhdevhub/rust-backend-axum","last_synced_at":"2025-03-17T16:11:36.768Z","repository":{"id":255841881,"uuid":"852722346","full_name":"AarambhDevHub/rust-backend-axum","owner":"AarambhDevHub","description":"Master Rust backend development with Axum in this comprehensive tutorial. Learn user authentication, PostgreSQL integration, email verification, and secure APIs. Build scalable, production-ready apps using Rust. Source code and Postman collection available for easy testing.","archived":false,"fork":false,"pushed_at":"2024-09-08T02:59:31.000Z","size":56,"stargazers_count":57,"open_issues_count":1,"forks_count":11,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-02T13:11:33.742Z","etag":null,"topics":["authentication","authentication-backend","axum","axum-authentication","axum-extractor","axum-framework","axum-middleware","axum-router","axum-rs","axum-server","letter","mail","rust","rust-language","server","sqlx","sqlx-cli","sqlx-postgres","uuid","validation"],"latest_commit_sha":null,"homepage":"https://youtu.be/M0wi7V1rP4Y","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/AarambhDevHub.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}},"created_at":"2024-09-05T09:59:21.000Z","updated_at":"2025-03-02T09:12:45.000Z","dependencies_parsed_at":"2024-09-07T12:26:34.668Z","dependency_job_id":"3d1ed20d-7639-486f-b209-94df402cc02c","html_url":"https://github.com/AarambhDevHub/rust-backend-axum","commit_stats":null,"previous_names":["aarambhdevhub/rust-backend-axum"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AarambhDevHub%2Frust-backend-axum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AarambhDevHub%2Frust-backend-axum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AarambhDevHub%2Frust-backend-axum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AarambhDevHub%2Frust-backend-axum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AarambhDevHub","download_url":"https://codeload.github.com/AarambhDevHub/rust-backend-axum/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244066181,"owners_count":20392406,"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":["authentication","authentication-backend","axum","axum-authentication","axum-extractor","axum-framework","axum-middleware","axum-router","axum-rs","axum-server","letter","mail","rust","rust-language","server","sqlx","sqlx-cli","sqlx-postgres","uuid","validation"],"created_at":"2024-09-24T20:16:21.710Z","updated_at":"2025-03-17T16:11:36.745Z","avatar_url":"https://github.com/AarambhDevHub.png","language":"Rust","funding_links":["https://buymeacoffee.com/aarambhdevhub"],"categories":[],"sub_categories":[],"readme":"# Rust Backend with Axum, PostgreSQL, \u0026 Email Verification\n\n[![Watch the video](https://img.youtube.com/vi/M0wi7V1rP4Y/maxresdefault.jpg)](https://youtu.be/M0wi7V1rP4Y)\n\nThis repository contains the source code for a fully functional backend application built with Rust, using the [Axum](https://github.com/tokio-rs/axum) framework. It includes user authentication, email verification, and a connection to a PostgreSQL database.\n\n## 🛠️ Features\n\n- **User Authentication**: Register, login, password reset functionality.\n- **Email Verification**: Users receive an email to verify their accounts.\n- **PostgreSQL Integration**: Store and manage user data securely.\n- **JWT Authentication**: Secure API endpoints with JSON Web Tokens (JWT).\n- **Middleware**: Implement custom middleware for authentication.\n- **Testing with Postman**: A full Postman collection is provided to test all API endpoints.\n\n## 🚀 Getting Started\n\n### Prerequisites\n\nTo run this project, you will need:\n\n- [Rust](https://www.rust-lang.org/) installed on your machine.\n- [PostgreSQL](https://www.postgresql.org/) installed and running locally or remotely.\n- [SQLx-CLI](https://crates.io/crates/sqlx-cli) for database migrations.\n- [Postman](https://www.postman.com/) for testing API endpoints.\n\n### Installation\n\n1. **Clone the repository:**\n\n    ```bash\n    git clone https://github.com/AarambhDevHub/rust-backend-axum.git\n    cd rust-backend-axum\n    ```\n\n2. **Install dependencies:**\n\n    ```bash\n    cargo install --path .\n    ```\n\n3. **Set up PostgreSQL:**\n\n   Create a new database in PostgreSQL and update the `.env` file with your database URL.\n\n   Example:\n\n    ```\n    DATABASE_URL=postgres://user:password@localhost/dbname\n    ```\n\n4. **Run migrations:**\n\n    ```bash\n    sqlx migrate run\n    ```\n\n5. **Start the server:**\n\n    ```bash\n    cargo run\n    ```\n\n   The server will be running on `http://127.0.0.1:8000`.\n\n## 📬 Email Verification Setup\n\nTo enable email verification, you will need to configure an email service provider. Update the following environment variables in your `.env` file:\n\n```env\nSMTP_SERVER=smtp.your-email-provider.com\nSMTP_PORT=587\nSMTP_USER=your-email@example.com\nSMTP_PASSWORD=your-email-password\n```\n\nThe application will send verification emails to users after registration.\n\n## 🧪 API Testing with Postman\n\nYou can test all the API endpoints using the provided Postman collection. [Download the Postman collection here](https://github.com/AarambhDevHub/rust-backend-axum/blob/main/postman_collection.json) and import it into Postman.\n\nAPI Endpoints:\n\nPOST `/api/auth/register`: Register a new user\n\nPOST `/api/auth/login`: Login with an existing user\n\nGET `/api/auth/forgot-password`: Request password reset\n\nPOST `/api/auth/reset-password`: Reset user password\n\nGET `/api/auth/verify`: Verify email with token\n\nGET `/api/users/me`: Get current user profile (JWT required)\n\n## ⚙️ Configuration\n\nThe application requires a .env file for configuration. Below are the required environment variables:\n\n```\n# -----------------------------------------------------------------------------\n# Database (PostgreSQL)\n# -----------------------------------------------------------------------------\nDATABASE_URL=postgresql://postgres:password@localhost:5432/axum_auth\n\n# -----------------------------------------------------------------------------\n# JSON Web Token Credentials\n# -----------------------------------------------------------------------------\nJWT_SECRET_KEY=my_ultra_secure_jwt_secret_key\nJWT_MAXAGE=60\n\n# -----------------------------------------------------------------------------\n# SMTP Server Settings\n# -----------------------------------------------------------------------------\nSMTP_SERVER=smtp.your-email-provider.com\nSMTP_PORT=587                     # Common ports: 587 (TLS), 465 (SSL), 25 (non-secure)\nSMTP_USERNAME=your_email@example.com\nSMTP_PASSWORD=your_email_password\nSMTP_FROM_ADDRESS=no-reply@yourdomain.com\n```\n\n## 🎯 Future Enhancements\n\nAdd role-based access control (RBAC) for different user roles (admin, user).\nImprove security with additional layers like rate limiting and input validation.\nExpand API to include more features like user profiles, etc.\n\n## 📄 License\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n\n## ✨ Acknowledgements\n\n[Axum](https://github.com/tokio-rs/axum) for building powerful, fast APIs in Rust.\n\n[PostgreSQL](https://www.postgresql.org/) for reliable database management.\n\n[SQLx](https://github.com/launchbadge/sqlx) for async SQL in Rust.\n\n## Donations\n\nIf you find this project useful and would like to support its continued development, you can make a donation via [Buy Me a Coffee](https://buymeacoffee.com/aarambhdevhub).\n\nThank you for your support!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faarambhdevhub%2Frust-backend-axum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faarambhdevhub%2Frust-backend-axum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faarambhdevhub%2Frust-backend-axum/lists"}