This document provides a comprehensive analysis of the Project Data Platform codebase, mapping all front-end and back-end functions, identifying issues, and outlining the path to containerization for Azure serverless deployment.
Front-End:
- Framework: Nuxt 3 (Vue 3)
- Styling: Tailwind CSS
- Build Tool: Nuxt (Vite-based)
- Port: 3000 (development)
Back-End:
- Runtime: Azure Functions v4 (Node.js)
- Language: TypeScript
- Port: 7071 (local development)
- Database: PostgreSQL (via
pglibrary) - Storage: Azure Blob Storage
External Services:
- Azure Blob Storage (OKH/OKW libraries)
- PostgreSQL Database (incidents, project data)
- Supply Graph AI Service (port 8081/8001 - external dependency)
| Function Name | Route Pattern | Methods | Purpose | Status |
|---|---|---|---|---|
test |
/test |
GET, POST | Health check endpoint | ✅ Active |
listRoutes |
/listRoutes |
GET, POST | Lists all available API routes | ✅ Active |
getFile |
/getFile/{containerName}/{fileName}/{fileType} |
GET, POST | Downloads blob file (JSON/YAML) from Azure Storage | ✅ Active |
listFilesByContainerName |
/listFiles/{containerName} |
GET, POST | Lists all files in specified container (okh/okw) | ✅ Active |
listOKHsummaries |
/listOKHsummaries |
GET, POST | Returns summary thumbnails for OKH products | ✅ Active |
listOKWsummaries |
/listOKWsummaries |
GET, POST | Returns summary thumbnails for OKW products | ✅ Active |
getRelatedOKH |
/getRelatedOKH |
GET, POST | Returns OKH products matching keywords | ✅ Active |
getIncidents |
/incidents |
GET, POST | Returns all incidents from PostgreSQL database | ✅ Active |
getOKHByFileName()- Fetches OKH/OKW file from Azure Blob Storage with cachingconvertToProduct()- Transforms OKH/OKW data to product summary formathasOverlapKeywords()- Keyword matching logicnormalizeKeywords()- Keyword normalization utilitylistSummaries()- Shared logic for OKH/OKW summary generation
Core:
@azure/functions- Azure Functions runtime@azure/storage-blob- Azure Blob Storage client@azure/identity- Azure authenticationpg- PostgreSQL clientyaml- YAML parsinglodash- Utility functionsdotenv- Environment variable management
Configuration Files:
host.json- Azure Functions host configurationlocal.settings.json- Local development settings (not in git)local.settings.json.template- Template for local settings
| Page | Route | Purpose | API Calls |
|---|---|---|---|
index.vue |
/ |
Homepage - displays OKH product summaries | GET /listOKHsummaries |
homepage.vue |
/homepage |
Incident display page (hardcoded data) | None (static) |
products/[id]/index.vue |
/products/:id |
Product detail page | GET /getFile/okh/{name}/{ext} |
products/[id]/supplyTree.vue |
/products/:id/supplyTree |
Supply tree visualization | External: Supply Graph AI API |
detailedcrisis.vue |
/detailedcrisis |
Detailed crisis/incident view | GET /incidents |
about.vue |
/about |
About page | None |
contact.vue |
/contact |
Contact page | None |
login.vue |
/login |
Login page (UI only) | None |
register.vue |
/register |
Registration page (UI only) | None |
supply-graph-api.vue |
/supply-graph-api |
Supply graph API testing page | GET /listOKHsummaries, External: Supply Graph AI |
| Component | Purpose | API Calls |
|---|---|---|
AppHeader.vue |
Navigation header | None |
ProductCard.vue |
Product card display | None |
ProductGroup.vue |
Product group container | None |
RelatedItems.vue |
Related products display | GET /getRelatedOKH?keywords=... |
IncidentsCard.vue |
Incident card display | None |
Slider.vue |
Image slider | None |
D3Tree.vue |
D3.js tree visualization | None |
Reviews.vue |
Reviews display | None |
SkeletonCard.vue |
Loading skeleton | None |
SkeletonRelatedItems.vue |
Loading skeleton | None |
Key Files:
nuxt.config.ts- Nuxt configuration with hardcoded backend URLpackage.json- Dependencies and scriptstailwind.config.js- Tailwind CSS configuration
Runtime Configuration:
baseUrl:http://127.0.0.1:7071/api(hardcoded, can be overridden withBACKEND_URLenv var)supplyGraphAiUrl:http://localhost:8081(can be overridden withSUPPLY_GRAPH_AI_URLenv var)
┌─────────────────┐
│ User Browser │
└────────┬────────┘
│
│ HTTP Requests
▼
┌─────────────────────────────────┐
│ Nuxt Front-End (Port 3000) │
│ - SSR/SSG │
│ - Vue Components │
│ - Tailwind CSS │
└────────┬────────────────────────┘
│
│ API Calls (useFetch)
▼
┌─────────────────────────────────┐
│ Azure Functions (Port 7071) │
│ - HTTP Triggers │
│ - TypeScript │
└────────┬────────────────────────┘
│
├─────────────────┬──────────────────┐
│ │ │
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Azure Blob │ │ PostgreSQL │ │ Supply Graph │
│ Storage │ │ Database │ │ AI Service │
│ (OKH/OKW) │ │ (Incidents) │ │ (External) │
└──────────────┘ └──────────────┘ └──────────────┘
-
Hardcoded URLs
nuxt.config.tshas hardcodedhttp://127.0.0.1:7071/api- Backend URL should be environment-based for production
- CORS configuration is permissive (
*) in development
-
Environment Variable Management
- Backend uses
dotenvwith path../.env(parent directory) - No clear
.envfile structure - Database credentials in environment variables (not in
local.settings.json) - Azure Storage credentials in
local.settings.jsonbut should use Azure Key Vault in production
- Backend uses
-
Database Connection
- PostgreSQL connection uses environment variables (
PGHOST,PGUSER, etc.) - SSL configuration with
rejectUnauthorized: false(security risk) - No connection pooling configuration visible
- No error handling for database connection failures
- PostgreSQL connection uses environment variables (
-
Caching Implementation
- In-memory cache in
getOKHByFileName()(line 282-323) - Comment says "temporary implementation" - needs proper cache strategy
- Cache never expires, could cause memory issues
- In-memory cache in
-
Error Handling
- Inconsistent error responses across endpoints
- Some endpoints return error objects, others return error messages
- No structured error logging
-
Code Quality Issues
- Duplicate code in
listFilesByContainerName()(lines 105-110, 113-116) - Commented-out code in
httpFunctions.ts(lines 44-46) - Inconsistent CORS headers across endpoints
- Console.log statements in production code
- Duplicate code in
-
Type Safety
- Heavy use of
anytypes - Missing type definitions for OKH/OKW structures
- No shared types between front-end and back-end
- Heavy use of
-
Security Concerns
- CORS allows all origins (
*) - No authentication/authorization implemented
- Database credentials in environment variables (should use managed identity)
- CORS allows all origins (
-
Build Configuration
- No production build optimization visible
- No Dockerfile or containerization setup
- No CI/CD pipeline configuration
-
Dependencies
- Some dependencies may be outdated
- No lock files visible (package-lock.json in .gitignore)
- Potential security vulnerabilities
-
Documentation
- Missing API documentation
- No OpenAPI/Swagger specification
- README has outdated information
-
Code Organization
- Utility functions duplicated between front-end and back-end
- No clear separation of concerns in some components
- Mixed concerns in some files
Requirements:
-
Dockerfile for Azure Functions
- Base image:
mcr.microsoft.com/azure-functions/node:4-node20or similar - Install dependencies
- Copy source files
- Build TypeScript
- Set entry point
- Base image:
-
Environment Configuration
- Move all secrets to Azure Key Vault or App Settings
- Remove hardcoded values
- Use managed identity for Azure Storage
- Use connection strings for PostgreSQL
-
Build Process
- TypeScript compilation
- Dependency installation
- Output to
dist/directory
-
Azure Functions Configuration
- Update
host.jsonfor production - Configure CORS properly
- Set up Application Insights
- Configure scaling options
- Update
Options for Deployment:
Option A: Static Site Generation (SSG)
- Build static site with
nuxt generate - Deploy to Azure Static Web Apps or Blob Storage + CDN
- Requires API calls to be client-side only
Option B: Server-Side Rendering (SSR)
- Containerize Nuxt with Node.js
- Deploy to Azure Container Apps or App Service
- Requires server runtime
Option C: Hybrid (Recommended)
- Static generation for most pages
- API routes for dynamic content
- Deploy static assets to CDN
- API to Azure Functions
Requirements:
-
Dockerfile for Nuxt
- Base image:
node:20-alpine - Multi-stage build (build + production)
- Install dependencies
- Build Nuxt app
- Serve with Node.js or static files
- Base image:
-
Environment Configuration
- Runtime config for backend URL
- Environment-based API endpoints
- Remove hardcoded URLs
-
Build Configuration
- Production build optimizations
- Environment variable injection
- Asset optimization
-
✅ Remove hardcoded URLs
- Update
nuxt.config.tsto use environment variables - Ensure all API calls use runtime config
- Update
-
✅ Fix environment variable management
- Standardize
.envfile structure - Document required environment variables
- Create
.env.examplefiles
- Standardize
-
✅ Improve error handling
- Standardize error responses
- Add proper logging
- Remove console.log statements
-
✅ Fix code quality issues
- Remove duplicate code
- Remove commented-out code
- Fix CORS configuration
-
✅ Update database configuration
- Proper SSL configuration
- Connection pooling
- Error handling
-
Back-End Dockerfile
- Create Dockerfile for Azure Functions
- Multi-stage build
- Optimize image size
-
Front-End Dockerfile
- Create Dockerfile for Nuxt
- Choose SSG or SSR approach
- Optimize build
-
Docker Compose (Optional)
- Local development setup
- Include PostgreSQL if needed locally
-
Azure Functions Setup
- Create Function App
- Configure Application Settings
- Set up Key Vault integration
- Configure CORS
-
Front-End Deployment
- Choose deployment target (Static Web Apps / Container Apps / App Service)
- Configure custom domain
- Set up CDN if needed
-
Database Setup
- Azure Database for PostgreSQL
- Configure firewall rules
- Set up connection string
-
Storage Setup
- Verify Azure Blob Storage access
- Configure managed identity
- Test blob access
-
Integration Testing
- Test all API endpoints
- Verify front-end to back-end communication
- Test with production-like environment
-
Performance Optimization
- Implement proper caching strategy
- Optimize database queries
- Optimize bundle sizes
-
Security Hardening
- Implement proper CORS
- Add authentication if needed
- Security scanning
# Azure Storage
Azure_Storage_ServiceName=https://projectdatablobstorage.blob.core.windows.net
Azure_Storage_OKH_ContainerName=okh
Azure_Storage_OKW_ContainerName=okw
# PostgreSQL Database
PGHOST=<database-host>
PGUSER=<database-user>
PGPASSWORD=<database-password>
PGDATABASE=<database-name>
PGPORT=5432
# Azure Functions
AzureWebJobsStorage=<storage-connection-string>
FUNCTIONS_WORKER_RUNTIME=node# Backend API URL
BACKEND_URL=http://localhost:7071/api # Development
# BACKEND_URL=https://<function-app>.azurewebsites.net/api # Production
# Supply Graph AI (Optional)
SUPPLY_GRAPH_AI_URL=http://localhost:8081- Review this document and prioritize issues
- Start with Phase 1 - Code cleanup
- Create Dockerfiles for both front-end and back-end
- Test locally with Docker
- Deploy to Azure and test
- Iterate based on findings
- Deployment Target: Static Web Apps, Container Apps, or App Service for front-end?
- Authentication: Do we need user authentication? If so, which provider?
- Database: Is PostgreSQL already set up in Azure, or do we need to create it?
- Supply Graph AI: Is this a separate service that needs to be containerized too?
- Domain: Do we have a custom domain for production?
- CI/CD: Do we need to set up GitHub Actions or Azure DevOps pipelines?
Document created: 2024 Last updated: 2024