Skip to content

dengcong80/MiniAiApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MiniAIAPP

AI-assisted requirements extractor → store to MongoDB → simple dynamic UI generator.

Monorepo Structure

  • server/: Node + Express + TypeScript. Endpoints, Mongo, AI integration, cache, rate limiting
  • client/: Vite + React + TypeScript. Two pages: / and /app/:id

Environment

Create server/.env from example:

NODE_ENV=development
PORT=8080
MONGODB_URI=<your Mongo Atlas URI>
OPENAI_API_KEY=<your key>
AI_MODEL=gpt-4o-mini
REDIS_URL=
CORS_ORIGIN=http://localhost:5173

Client uses VITE_API_URL (default http://localhost:8080). Optionally add client/.env:

VITE_API_URL=http://localhost:8080

Install & Run (Local)

Terminal 1 (server):

cd server
npm i
npm run dev

Terminal 2 (client):

cd client
npm i
npm run dev

Server: http://localhost:8080 Client: http://localhost:5173

API

  • GET /api/health{ ok: true }
  • POST /api/requirements body: { prompt } → structured requirements (Zod validated, cached 24h)
  • POST /api/projects body: { prompt } (supports Idempotency-Key) → { projectId, requirements }
  • GET /api/projects/:id → full document (cached 60s)

Data Model (Mongo projects)

appName: string
prompt: string
promptHash: string (sha256, unique)
entities: { name: string; fields: string[] }[]
roles: string[]
features: string[]
createdAt: Date

Indexes:

  • { promptHash: 1 } unique
  • { createdAt: -1 }

Security & Reliability

  • Helmet, CORS whitelist, pino logs
  • Zod for env and request validation
  • AI timeout (8s) and retry (2 attempts)
  • Rate limits: strict for /requirements, normal for others
  • Cache: Redis with in-memory fallback
  • Idempotency: promptHash unique + Idempotency-Key

Deploy

Server (Render):

  • Build Command: npm run build
  • Start Command: npm start
  • Env: MONGODB_URI, OPENAI_API_KEY, AI_MODEL, REDIS_URL, CORS_ORIGIN

Client (Render Static or Vercel):

  • Set VITE_API_URL to backend public URL
  • Enable CDN cache for static assets

Screenshots / Examples

  • Input prompt, AI output JSON, generated UI (entities/roles/features)

About

Intern Evaluation Task: Mini AI App Builder Portal + User App UI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors