How gururock007/otpfiy works
Project type and purpose
• This is a full-stack web application offering an OTP (One-Time Password) service via Gmail.
• Frontend: React JS + TailWind CSS + Framer Motion, served as a SPA via Vite.
• Backend: Flask REST API with JWT-based authentication, exposing endpoints to register users, issue API keys, generate and verify OTPs, and send emails through Gmail’s SMTP using app passwords.
File structure
• Top-level:
• README.md – overview and tech stack
• backend/ – Python Flask application
• forntend/ – React SPA (note typo “forntend”)
• backend/:
• class_user.py, class_otp.py, class_conn.py, class_info.py – core business logic for user management, OTP generation and storage, Gmail connection, and metadata
• otpify_frontend.py – likely the Flask app’s main entrypoint serving APIs
• requirements.txt – Python dependencies
• forntend/:
• package.json, vite.config.js, tailwind.config.js – build & styling config
• public/ – static assets (fonts, images)
• src/:
– api/axios.js – HTTP client configured for JWT
– components/, routes/ – React components & pages (Login, Signup, Dashboard, etc.)
– context/ – React Context for Auth, User, Error state
– hooks/ – custom React hooks for auth, token refresh
– main.jsx – app bootstrap
README for additional insights
• Features: secure OTP generation, Gmail integration, API access, user accounts
• Technology call-outs: Flask, JWT, React, TailWind, Framer Motion
• Usage flow: user signs up → obtains API key → calls /generateOTP → email sent via Gmail → calls /verifyOTP
Diagramming guidance
a. Main components
• Frontend (React SPA)
• Backend (Flask REST API)
• Database (e.g., SQL or key-value store for users, API keys, OTP records)
• External Email Service (Gmail SMTP)
• JWT Authentication Service (part of Flask)
b. Relationships & interactions
1. User’s browser loads React SPA from the Web Server (or CDN).
2. SPA invokes Auth endpoints: /signup, /login → Flask → Database → returns JWT & API key.
3. SPA uses axios instances (public & private) to call protected endpoints with JWT header.
4. On OTP request, Flask generates OTP, stores hash/expiry in DB, then calls Gmail SMTP with app password to send email.
5. For OTP verification, the SPA or external client calls /verifyOTP → Flask validates stored OTP → returns success/failure.
c. Architectural patterns & design principles
• RESTful API pattern in Flask
• JWT-based stateless authentication
• Single-page application (SPA) architecture
• Separation of concerns: business logic classes (class_user, class_otp, etc.) decoupled from routing layer
• Environment-based configuration for Gmail credentials
d. Key technologies & libraries
• Flask + flask_jwt_extended
• SMTP lib or flask-mail for Gmail
• React with Context API and custom hooks
• Axios for HTTP calls
• TailWind CSS & Framer Motion for styling & animation
• Vite for frontend build
Elements
• Clear component labels (e.g., “React SPA”, “Flask API Server”, “MySQL/PostgreSQL”, “Gmail SMTP”)
• Browser → React SPA → API server → DB
• API server → Gmail SMTP
• Gmail SMTP → User’s email inbox
• Ports or protocols (e.g., HTTPS 443, SMTP 587) if relevant.
• JWT generation & validation steps.