How gowthamchandu307/userauth-api works
Main Components
a) Client Layer:
• External clients/applications that consume the API
• Swagger UI interface (running on /docs)
b) API Layer (FastAPI Application):
• Authentication endpoints (from routers/token.py)
• User management endpoints (from routers/user.py)
• Middleware for JWT validation
c) Service Layer:
• CRUD operations (from crud.py)
• Token generation and validation services
d) Data Layer:
• MySQL Database
• SQLAlchemy ORM (models.py)
[Client Layer]
• ↓↑
[API Gateway/FastAPI]
• ↓↑
[Service Layer]
• ↓↑
[Data Layer]
Component Details
For each component, include these specific elements:
Client Layer:
• HTTP/REST clients
• Swagger UI documentation interface
• Supported HTTP methods (POST, GET)
API Layer:
• FastAPI application container
• Route handlers:
• /auth/token (JWT authentication)
• /users (user management)
• Authentication middleware
Service Layer:
• User service (CRUD operations)
• Token service (JWT generation/validation)
• Password hashing service (bcrypt)
Data Layer:
• MySQL container
• User table schema
• SQLAlchemy ORM
Interactions and Flows
• Client → API: HTTP requests with JWT tokens
• API → Service: Internal method calls
• Service → Database: SQL queries via SQLAlchemy
• Database → Service: Query results
• Service → API: Processed data
• API → Client: HTTP responses
Container Architecture
A separate section showing Docker container architecture:
• FastAPI container
• MySQL container
• Docker network
• Exposed ports (8000 for API)
Security Layers
Security implementations:
• JWT token flow
• Password hashing
• Authentication middleware
• Database security
Additional Notes
Annotations for:
• Environment variables configuration
• Database connection details
• API documentation endpoints
• Security measures