Accounts

Frontend of Backend project (which was built using FastAPI) using Next.js

This project handles all the frontend logic by defining API endpoints, which communicate with the my backend project to perform operations like user registration, login, reset-password and account management. It is built using Next.js. These act as middleware, validating and forwarding requests to the FastAPI backend.

๐Ÿงพ Auth Features

๐Ÿ” User Registration ( And Otp Verification)

Signup page
Signup page

Using Email

POST /api/auth/start-registration This feature allows users to register by providing their email address. An OTP (One-Time Password) is sent to the user's email for verification.

OTP Verification
OTP Verification

POST /api/auth/verify-email After OTP verification, POST /api/auth/set-session this automatically signs the user in. This feature I like very much and remember building for days to make it work perfectly.

Using Google and Github

Just Simple implementation of Google POST /api/auth/google and Github POST /api/auth/github OAuth login. backend handles the OAuth flow and returns user data to the frontend.

Google Login
Google Login

๐Ÿ”“ Login

Using Email/Username and Password

Log in using their email/username and password. After successful authentication, user is redirected to dashboard page.

Using Google and Github

The backend handles the OAuth flow in this case as well.

๐Ÿ” Reset Password ( Request + Confirm )

POST /api/auth/request-password-reset and POST /api/auth/verify-password-reset Reset password by requesting a password reset OTP via email/username.

Request Password Reset
Request Password Reset
Reset Password
Reset Password

POST /api/auth/reset-password After OTP verification, users can set a new password.

Reset Password
Reset Password

๐Ÿ”‘ Session and Account Management

GET /api/user/me - Retrieve the current user's profile information. POST /api/user/me - Update the current user's profile information.

Dashboard Page
Dashboard Page

POST /api/auth/refresh The session is automatically refreshed when the user interacts with the application.

๐Ÿšช Logout

POST /api/auth/logout - Logs the user out and clears the session.

๐Ÿ“‚ Folder Structure

src/
โ”œโ”€โ”€ app/                     # Next.js App Router
โ”‚   โ”œโ”€โ”€ api/                 # API routes
โ”‚   โ”‚   โ”œโ”€โ”€ auth/            # Auth API endpoints
โ”‚   โ”‚   โ””โ”€โ”€ user/            # User API endpoints
โ”‚   โ”‚       โ””โ”€โ”€ me/          # User profile operations
โ”‚   โ”œโ”€โ”€ auth/                # Auth pages
โ”‚   โ”‚   โ”œโ”€โ”€ user/            # User auth flows
โ”‚   โ”‚   โ””โ”€โ”€ admin/           # Admin auth flows
โ”‚   โ””โ”€โ”€ user/                # User dashboard pages
โ”‚       โ”œโ”€โ”€ dashboard/       # Main user dashboard
โ”‚       โ””โ”€โ”€ me/              # Profile management
โ”œโ”€โ”€ components/              # Shared components
โ”‚   โ””โ”€โ”€ ui/                  # UI component library
โ”œโ”€โ”€ lib/                     # Utility libraries
โ”œโ”€โ”€ middleware               # Next.js request middleware
โ””โ”€โ”€ utils/                   # Additional utilities