This project is a full-stack authentication and task management system built with:
FastAPIfor the backend REST APIMongoDBwithmotorfor async database accessReact + TypeScript + Vitefor the frontendJWTfor authentication- Role-based authorization for user and admin actions
Dockeranddocker-composefor containerized startupGitHub Actionsfor CI
The codebase is organized as two main applications:
backend/: API, auth, database access, schemas, and route handlersfrontend/: login/register UI, dashboard, admin panel, shared state, and API client logic
- User registration with email, password, and optional name
- Password hashing using
bcrypt - User login using OAuth2 password form flow
- JWT access token generation
- Token-based session persistence in frontend
localStorage - Automatic token decoding on frontend app startup
- Auto logout when token is expired or invalid
- Role-based access control with
USERandADMIN - Protected frontend routes using a private route wrapper
- Backend dependency-based authorization guards
- Admin-only access for user management and viewing all tasks
- Ownership-based control for task updates and deletes
- Create tasks
- List current user's tasks
- Update owned tasks
- Delete owned tasks
- Admin ability to delete any task
- Admin endpoint to fetch all tasks
- Public self-registration flow
- Admin-created user accounts
- Admin list of all users
- Admin update of user role, name, and permissions
- Admin delete user accounts
- User or admin can fetch a specific user record
- Login page
- Registration page
- Protected dashboard
- Admin panel for user management
- Toast notification system for success/error/info messages
- Global Axios response interceptor for centralized API error handling
- API health/status indicator on dashboard and admin panel
- Dockerfiles for backend and frontend
docker-compose.ymlto run both services together- CI workflow for backend verification and frontend build
- Backend startup/shutdown database lifecycle hooks
- Custom colored logger for console output
authdb/
├── .github/
│ └── workflows/
│ └── ci.yml
├── backend/
│ ├── app/
│ │ ├── core/
│ │ │ ├── config.py
│ │ │ ├── dependencies.py
│ │ │ └── security.py
│ │ ├── db/
│ │ │ └── mongodb.py
│ │ ├── models/
│ │ │ ├── task.py
│ │ │ └── user.py
│ │ ├── routes/
│ │ │ └── api/
│ │ │ ├── v1/
│ │ │ │ ├── auth.py
│ │ │ │ ├── health.py
│ │ │ │ ├── tasks.py
│ │ │ │ └── users.py
│ │ │ └── v2/
│ │ │ └── verify_db.py
│ │ ├── schemas/
│ │ │ ├── task.py
│ │ │ └── user.py
│ │ ├── utils/
│ │ │ └── logger.py
│ │ └── main.py
│ ├── Dockerfile
│ └── requirements.txt
├── docs/
│ ├── Back-End.md
│ ├── DB_Schema.md
│ ├── Front-End.md
│ ├── Scalability_Guide.md
│ └── Screenshot of working/
├── frontend/
│ ├── public/
│ │ └── vite.svg
│ ├── src/
│ │ ├── api/
│ │ │ └── axios.ts
│ │ ├── assets/
│ │ │ └── react.svg
│ │ ├── components/
│ │ │ └── GlobalAxiosInterceptor.tsx
│ │ ├── context/
│ │ │ ├── AuthContext.tsx
│ │ │ └── ToastContext.tsx
│ │ ├── pages/
│ │ │ ├── AdminPanel.tsx
│ │ │ ├── Dashboard.tsx
│ │ │ ├── Login.tsx
│ │ │ └── Register.tsx
│ │ ├── App.css
│ │ ├── App.tsx
│ │ ├── index.css
│ │ └── main.tsx
│ ├── Dockerfile
│ ├── eslint.config.js
│ ├── index.html
│ ├── package-lock.json
│ ├── package.json
│ ├── tsconfig.app.json
│ ├── tsconfig.json
│ ├── tsconfig.node.json
│ └── vite.config.ts
├── docker-compose.yml
├── README.md
└── Project.md
- FastAPI application entry point
- Registers CORS middleware
- Connects/disconnects MongoDB on app lifecycle events
- Includes API routers for health, auth, tasks, and users
- Loads environment settings via
pydantic-settings - Defines project name, MongoDB URL, DB name, JWT secret, algorithm, and token expiry
- Password hash generation
- Password verification
- JWT access token creation with optional extra claims
- OAuth2 bearer token extraction
- Current user lookup from JWT
sub - Admin access enforcement dependency
- MongoDB client manager
- Async connect/close helpers
- Health check with
ping - Shared database dependency provider
POST /registerPOST /login- Handles account creation, duplicate email checks, password hashing, and JWT issuance
POST /GET /PUT /{task_id}DELETE /{task_id}GET /all- Handles CRUD operations for tasks with owner/admin authorization rules
GET /POST /GET /{user_id}PUT /{user_id}DELETE /{user_id}- Handles admin user management and controlled self/admin profile retrieval
GET /health- Reports API database connectivity state
- Standalone script to verify MongoDB connectivity
- Used in CI validation flow
- Pydantic request/response models for user creation, update, storage, and API responses
- Defines
UserRoleenum withUSERandADMIN
- Pydantic request/response models for tasks
- Defines create, update, stored, and response payload shapes
- User model representation for stored database documents
- Task model representation for stored database documents
- Colored console logger configuration
- Reduces duplicate handlers on app startup
- Application bootstrap
- Wraps the app with router, auth provider, toast provider, and global interceptor
- Defines frontend routes
- Protects dashboard and admin pages behind authentication
- Redirects
/to/dashboard
- Shared Axios client
- Configures API base URL
- Attaches bearer token automatically from
localStorage
- Centralized response error handling
- Shows toast notifications for network, auth, authorization, and server errors
- Clears token and redirects to login on token expiry cases
- Stores authenticated user and token state
- Decodes JWT payload on startup
- Exposes
login,logout,isAuthenticated, and loading state
- Global toast state manager
- Renders portal-based notification UI
- Supports success, error, and info messages
- User login form
- Sends OAuth2-form login request
- Stores JWT after successful login
- User registration form
- Validates password confirmation on client side
- Redirects to login after successful signup
- Protected task dashboard
- Fetches user tasks
- Creates tasks
- Deletes tasks
- Shows system health and latency indicator
- Provides admin shortcut when logged in as admin
- Protected admin-only interface
- Lists users
- Creates, edits, and deletes users
- Assigns roles and permissions
- Displays summary cards and system status
- Starts backend and frontend containers together
- Builds backend service with Python 3.11
- Runs FastAPI via
uvicorn
- Builds frontend with Node 24
- Runs Vite development server
- Runs backend dependency installation and DB verification
- Starts backend in CI
- Builds frontend in CI
- Contains backend, frontend, schema, and scalability documentation
- Includes screenshots of working UI
GET /api/v1/health- database-aware health check
POST /api/v1/auth/register- register a new userPOST /api/v1/auth/login- login and receive JWT token
POST /api/v1/tasks/- create taskGET /api/v1/tasks/- list current user's tasksPUT /api/v1/tasks/{task_id}- update owned taskDELETE /api/v1/tasks/{task_id}- delete owned task or any task if adminGET /api/v1/tasks/all- admin-only list of all tasks
GET /api/v1/users/- admin-only list usersPOST /api/v1/users/- admin-only create userGET /api/v1/users/{user_id}- fetch own profile or any profile if adminPUT /api/v1/users/{user_id}- admin-only update userDELETE /api/v1/users/{user_id}- admin-only delete user
nameemailhashed_passwordrolepermissionscreated_at
titledescriptionowner_idcreated_at
- The backend is modular and follows a clear FastAPI separation between config, dependencies, schemas, routes, and DB access.
- The frontend is organized by responsibility with separate folders for pages, shared context, components, and API utilities.
- The project supports both standard users and admins, with most advanced capabilities centered around admin user management.
- Some frontend comments mention an older health route assumption, but the actual backend currently exposes health at
/api/v1/healththrough thehealthrouter. - The frontend Axios base URL is currently hardcoded to the deployed Render backend, which is convenient for demos but less flexible for local development unless changed or made environment-based.
- Authentication
- Authorization
- User management
- Task management
- API routing
- Security and token handling
- Database connection management
- Validation schemas
- Logging
- Frontend state management
- API client and interceptor handling
- DevOps and containerization
- CI/CD workflows
- Documentation and project analysis
- Testing (if implemented)
- Scalability and performance optimizations (if implemented)
- Monitoring and observability (if implemented)
- Error handling and resilience (if implemented)
- Deployment and hosting configurations (if implemented)
- API documentation and client generation (if implemented)
- Code quality and linting configurations (if implemented)
- Performance profiling and optimization tools (if implemented)
- Security hardening and vulnerability scanning (if implemented)
- Internationalization and localization (if implemented)
- Accessibility improvements (if implemented)
- User experience enhancements (if implemented)
- Feature flagging and A/B testing (if implemented)