{"id":14989795,"url":"https://github.com/ramo4040/fullstack-user-authentication-system-ts-react-express-mongodb","last_synced_at":"2026-01-25T07:37:20.049Z","repository":{"id":255502962,"uuid":"837161745","full_name":"ramo4040/FullStack-User-Authentication-System-TS-React-Express-MongoDB","owner":"ramo4040","description":"This project is a robust user authentication system offering registration, login, logout, email verification, password reset, and Google authentication, built with modern technologies and security best practices.","archived":false,"fork":false,"pushed_at":"2024-09-04T15:10:34.000Z","size":9598,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-14T01:41:41.561Z","etag":null,"topics":["auth0","authentication","expressjs","mongodb","nodejs","reactjs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/ramo4040.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-08-02T10:47:33.000Z","updated_at":"2024-09-04T18:41:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"cc9a1c4a-a5ca-42c3-bebe-51f3a0b3acbf","html_url":"https://github.com/ramo4040/FullStack-User-Authentication-System-TS-React-Express-MongoDB","commit_stats":{"total_commits":54,"total_committers":2,"mean_commits":27.0,"dds":0.07407407407407407,"last_synced_commit":"d02446e9ddfba8a71cd5b4f00b86f512267fa383"},"previous_names":["ramo4040/fullstack-user-authentication-system-ts-react-express-mongodb"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramo4040%2FFullStack-User-Authentication-System-TS-React-Express-MongoDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramo4040%2FFullStack-User-Authentication-System-TS-React-Express-MongoDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramo4040%2FFullStack-User-Authentication-System-TS-React-Express-MongoDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramo4040%2FFullStack-User-Authentication-System-TS-React-Express-MongoDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ramo4040","download_url":"https://codeload.github.com/ramo4040/FullStack-User-Authentication-System-TS-React-Express-MongoDB/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219849797,"owners_count":16556324,"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":["auth0","authentication","expressjs","mongodb","nodejs","reactjs","typescript"],"created_at":"2024-09-24T14:18:55.479Z","updated_at":"2026-01-25T07:37:20.015Z","avatar_url":"https://github.com/ramo4040.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Full Stack User Authentication System 🔐\n\nThis project is a comprehensive user authentication system designed to handle various aspects of user authentication, including registration, login, logout, email verification, password reset, and Google authentication. The system is built using modern technologies and follows best practices for security and scalability.\n\n### Features ✨\n\n* **Email/Password Authentication:**\n    * User registration with email verification.\n    * Secure login and logout functionality.\n    * Password reset and recovery mechanisms.\n* **Google OAuth Integration:**\n    * Seamless login using Google accounts.\n* **User Management:**\n    * Account verification via email.\n    * Token-based authentication for secure API access.\n    * Refresh token mechanism for extended session duration.\n\n### Technology Stack 🚀\n\n* **Backend:**\n    * **Node.js**  [https://nodejs.org/](https://nodejs.org/) \n    * **Express.js** [https://expressjs.com/](https://expressjs.com/) \n    * **MongoDB**  [https://www.mongodb.com/](https://www.mongodb.com/) \n    * **JWT (JSON Web Tokens)** [https://jwt.io/](https://jwt.io/)\n* **Frontend:**\n    * **React**  [https://reactjs.org/](https://reactjs.org/) \n* **Other:**\n    * **Docker** for containerization [https://www.docker.com/](https://www.docker.com/)\n    * **Docker Compose** for multi-container orchestration [https://docs.docker.com/compose/](https://docs.docker.com/compose/)\n    * **Husky** for Git hooks (pre-commit) [https://typicode.github.io/husky/](https://typicode.github.io/husky/)\n\n### Object-Oriented Design \u0026 Dependency Injection\n* **Object-Oriented Programming (OOP):**\n   * The backend leverages OOP principles to create modular, reusable, and maintainable code.\n\n* **Inversify Library:**\n   *  Used for Dependency Injection (DI) to manage the dependencies between classes, promoting loose coupling and making the application easier to test and extend.\n  \n## Screenshots\n\n|  |  |\n|---|---|\n|Sign Up page|Sign In page|\n| ![signup](./client/public/signup.png) | ![signin](./client/public/signin.png) |\n|Forgot password page|Reset password page|\n| ![forgotpassword](./client/public/forgotpassword.png) | ![resetpassword](./client/public/resetpassword.png) |\n|Email verification page|Dashboard page|\n| ![verfieremail](./client/public/verfieremail.png) | ![dashboard](./client/public/dashboard.png) |\n\n### Project Structure 📁\n\n```\n├── server\n│   ├── src\n│   │   ├── controllers\n│   │   │   └── auth\n│   │   ├── core\n│   │   │   ├── config\n│   │   │   └── interfaces\n│   │   ├── middlewares\n│   │   ├── models\n│   │   ├── repositories\n│   │   ├── routes\n│   │   │   └── auth\n│   │   ├── services\n│   │   │   └── auth\n│   │   ├── utils\n│   │   └── validator\n│   │   ├── .env.template\n│   └── ...\n│\n├── client\n│   ├── src\n│   └── ...\n│\n├── docker-compose.yml\n└── README.md\n```\n\n### Running and Configuring the Application 🏃‍♂️\n\n#### 1. Environment Variables 🔐\n\nCreate a `.env` file by copying the `.env.template` file and filling in the following environment variables:\n\n```\nPORT=\nAPI_PREFIX=\nMONGODB_URI=\n\nSERVER_URL=\nCLIENT_URL=\n\nAUTH_ACCESS_TOKEN_SECRET=\nAUTH_ACCESS_TOKEN_EXPIRY=\n\nAUTH_REFRESH_TOKEN_SECRET=\nAUTH_REFRESH_TOKEN_EXPIRY=\n\nEMAIL_TOKEN_SECRET=\nEMAIL_TOKEN_EXPIRY=\n\nAUTH_EMAIL_USER=\nAUTH_EMAIL_PASS=\n\nGOOGLE_CLIENT_ID=\nGOOGLE_CLIENT_SECRET=\nGOOGLE_REDIRECT_URI=\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eExplanation\u003c/summary\u003e\n  \u003cp\u003e\n\n* **PORT:** Port on which the server will listen.\n* **API_PREFIX:** Prefix for all API endpoints.\n* **MONGODB_URI:** MongoDB connection URI.\n* **AUTH_ACCESS_TOKEN_SECRET:** Secret key for generating access tokens.\n* **AUTH_ACCESS_TOKEN_EXPIRY:** Expiry time for access tokens.\n* **AUTH_REFRESH_TOKEN_SECRET:** Secret key for generating refresh tokens.\n* **AUTH_REFRESH_TOKEN_EXPIRY:** Expiry time for refresh tokens.\n* **EMAIL_TOKEN_SECRET:** Secret key for generating email verification tokens.\n* **EMAIL_TOKEN_EXPIRY:** Expiry time for email verification tokens.\n* **AUTH_EMAIL_USER:** Email address for sending verification emails.\n* **AUTH_EMAIL_PASS:** Password for the email account.\n* **GOOGLE_CLIENT_ID:** Google OAuth Client ID.\n* **GOOGLE_CLIENT_SECRET:** Google OAuth Client Secret.\n* **GOOGLE_REDIRECT_URI:** Google OAuth Redirect URI.\n\n  \u003c/p\u003e\n\u003c/details\u003e\n\n#### 2. Setting up Google OAuth \n\n* **Create a Google Cloud Project:**  \n    * Go to the Google Cloud Console [https://console.cloud.google.com/](https://console.cloud.google.com/).\n    * Create a new project.\n* **Enable the Google Sign-In API:**\n    * Go to the \"APIs \u0026 Services\" section of your project.\n    * Search for \"Google Sign-In\" and enable it.\n* **Create OAuth 2.0 credentials:**\n    * Go to the \"APIs \u0026 Services\" -\u003e \"Credentials\" section.\n    * Click \"Create credentials\" -\u003e \"OAuth client ID\".\n    * Choose \"Web application\" as the application type.\n    * In the \"Authorized redirect URIs\" field, add `http://localhost:3000/auth/google/callback` (or your appropriate redirect URI).\n    * Click \"Create\" to generate your client ID and client secret.\n* **Update your `.env` file:**\n    * Fill in the `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET`, and `GOOGLE_REDIRECT_URI` environment variables with the values you obtained from Google Cloud Console.\n\n\n#### 3. Installation and Running \n\n1. **Prerequisites:**\n   * **Node** (look at .nvmrc file for version)\n   * **Docker and Docker Compose** installed.\n   * **Node.js and npm** installed.\n\n3. **Clone the repository:**\n   ```bash\n   git clone https://github.com/ramo4040/FullStack-User-Authentication-System-TS-React-Express-MongoDB.git\n   ```\n4. **Navigate to the project directory:**\n   ```bash\n   cd FullStack-User-Authentication-System-TS-React-Express-MongoDB\n   ```\n5. **Install dependencies:**\n   ```bash\n   npm install \n   ```\n6. **Start the containers:**\n   ```bash\n   docker-compose up --build -d\n   ```\n   This will build the Docker images if they don't exist and then run them in detached mode.\n7. **Access the application:**\n   Open your browser and navigate to `http://localhost:3000` (or the port specified in your `.env` file).\n\n\n\n**Remember to:**\n\n*  **Keep your secrets secure!**  Do not commit your `.env` file to version control. \n*  **Configure your email provider** and set up your email credentials correctly.\n*  **Test thoroughly** to ensure all features, including email verification and Google authentication, are working correctly.\n\nLet me know if you have any questions or if there's anything else I can help you with! \n\n\n## API Reference\n\n#### Register User\n\n```http\n  POST /api/v1/auth/register\n```\n\n| Parameter | Type     | Description                |\n| :-------- | :------- | :------------------------- |\n| `Username` | `string` | **Required**. User username |\n| `Email` | `string` | **Required**. User email |\n| `Password` | `string` | **Required**. User password |\n| `Confirm password` | `string` | **Required**. User password |\n\n#### Login User\n\n```http\n  POST /api/v1/auth/login\n```\n\n| Parameter | Type     | Description                       |\n| :-------- | :------- | :-------------------------------- |\n| `email`      | `string` | **Required**. User email |\n| `password`      | `string` | **Required**. User password |\n\n#### Logout User\n\n```http\n  GET /api/v1/auth/logout\n```\n\n#### Google OAuth Authentication\n\n```http\n  GET /api/v1/auth//google/authenticate\n```\n\n#### Google OAuth Callback\n\n```http\n  GET /api/v1/auth/google/callback\n```\n| Parameter | Type     | Description                       |\n| :-------- | :------- | :-------------------------------- |\n| `code`      | `query(url)` | callback code |\n\n#### Verify Email\n\n```http\n  GET /api/v1/auth//verify-email\n```\n| Parameter | Type     | Description                       |\n| :-------- | :------- | :-------------------------------- |\n| `token`      | `query(url)` | token generated for email validation|\n| `oldAccessToken`      | `cookies` | old access token |\n\n#### Refresh Token\n\n```http\n  POST /api/v1/auth/token/refresh\n```\n| Parameter | Type     | Description                       |\n| :-------- | :------- | :-------------------------------- |\n| `refreshToken`      | `cookie(string)` | Required. Refresh token |\n\n#### Forgot password \n\n```http\n  POST /api/v1/auth/forgot-password\n```\n| Parameter | Type     | Description                       |\n| :-------- | :------- | :-------------------------------- |\n| `email`      | `string` | Required. User email |\n\n#### Validate Reset Token \n\n```http\n  GET /api/v1/auth/validate-reset-token\n```\n| Parameter | Type     | Description                       |\n| :-------- | :------- | :-------------------------------- |\n| `token`      | `query(url)` | Required. Reset token |\n\n#### Reset Password \n\n```http\n  PUT /api/v1/auth/reset-password\n```\n| Parameter | Type     | Description                       |\n| :-------- | :------- | :-------------------------------- |\n| `token`      | `query(url)` | Required. Reset token |\n| `email`      | `string` | Required. New password |\n\n#### Get current user \n\n```http\n  GET /api/v1/auth/me\n```\n\n\n**Notes:**\n\n* All endpoints require authentication except for `/api/auth/register`, `/api/auth/login`, `/api/auth/forgot-password`, `/api/auth/validate-reset-token`, and `/api/auth/google/authenticate`.\n* All endpoints return JSON data.\n* The `token` in the request body or query parameter should be a valid authentication or verification token.\n* The response body may contain additional information depending on the specific endpoint.\n\n\n\n### Contributing 🙌\n\nContributions are welcome! Please fork the repository, make your changes, and submit a pull request.\n\n### License 📝\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framo4040%2Ffullstack-user-authentication-system-ts-react-express-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Framo4040%2Ffullstack-user-authentication-system-ts-react-express-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framo4040%2Ffullstack-user-authentication-system-ts-react-express-mongodb/lists"}