diff --git a/README.md b/README.md index 6544da2..e1874a0 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,115 @@ -
-GHBanner -
+# AI India Innovations — Web Platform -# Run and deploy your AI Studio app +Full-stack TypeScript web application for **AI India Innovations (AIII)** featuring a React SPA frontend, interactive UI animations, and an Express backend with multi-turn Gemini API chat integration. -This contains everything you need to run your app locally. +## Tech Stack -View your app in AI Studio: https://ai.studio/apps/ed55e1b8-84fd-4d0a-873e-aec620197b6c +### Frontend +- **React 19** (`react`, `react-dom`) — Component-based UI +- **TypeScript 5.8** — Static typing (`ES2022`, `react-jsx`) +- **Vite 6** (`vite`, `@vitejs/plugin-react`) — Dev server, HMR, and production bundling +- **Tailwind CSS v4** (`@tailwindcss/vite`, `tailwindcss`, `autoprefixer`) — Utility-first styling +- **Motion** (`motion`) — UI animations and transitions +- **Lucide React** (`lucide-react`) — Iconography -## Run Locally +### Backend & AI +- **Node.js & Express 4** (`express`) — HTTP server, API routes, and static/SPA serving +- **Google GenAI SDK** (`@google/genai`) — Multi-turn chat completions (`/api/chat`) with model fallback handling +- **dotenv** (`dotenv`) — Environment variable loading -**Prerequisites:** Node.js +### Build & Tooling +- **tsx** — TypeScript execution for development (`server.ts`) +- **esbuild** — Server bundling to CommonJS (`dist/server.cjs`) +- **TypeScript Compiler** (`tsc --noEmit`) — Type checking +--- -1. Install dependencies: - `npm install` -2. Set the `GEMINI_API_KEY` in [.env.local](.env.local) to your Gemini API key -3. Run the app: - `npm run dev` +## Project Structure + +```text +├── public/ # Static assets served at / +├── src/ +│ ├── components/ # UI views, modals, navbar, chatbot, and section components +│ ├── context/ # React context providers (ThemeContext) +│ ├── data/ # Static domain data (solutions, industries, GCC, blogs, site data) +│ ├── imports/ # Bundled image assets +│ ├── App.tsx # Root application component and view routing +│ ├── index.css # Global styles and Tailwind CSS entry +│ ├── main.tsx # React DOM entry point +│ └── types.ts # Shared TypeScript interfaces and types +├── index.html # HTML entry point +├── server.ts # Express server, API endpoints, and Vite middleware/static serving +├── vite.config.ts # Vite configuration and path alias (@ -> project root) +├── tsconfig.json # TypeScript compiler configuration +└── package.json # Dependencies and npm scripts +``` + +--- + +## Prerequisites + +- **Node.js** (v20+ recommended) +- **npm** + +--- + +## Environment Variables + +Create a `.env` file in the project root (see `.env.example`): + +| Variable | Required | Description | +| --- | --- | --- | +| `GEMINI_API_KEY` | Optional (required for live `/api/chat` responses) | API key used by `@google/genai` on the backend. Without it, `/api/chat` returns a fallback message. | +| `NODE_ENV` | Optional | Set to `production` to serve built static assets from `dist/` instead of Vite dev middleware. | +| `DISABLE_HMR` | Optional | Set to `true` to disable Vite HMR and file watching. | + +--- + +## Getting Started + +1. **Install dependencies:** + ```bash + npm install + ``` + +2. **Run in development mode** (starts Express + Vite middleware on port `3000`): + ```bash + npm run dev + ``` + +3. **Type-check:** + ```bash + npm run lint + ``` + +4. **Build for production** (builds client to `dist/` and bundles `server.ts` to `dist/server.cjs`): + ```bash + npm run build + ``` + +5. **Run production server:** + ```bash + NODE_ENV=production npm start + ``` + +--- + +## Available Scripts + +| Script | Command | Description | +| --- | --- | --- | +| `dev` | `tsx server.ts` | Starts the Express + Vite development server on `http://0.0.0.0:3000` | +| `build` | `vite build && esbuild server.ts --bundle --platform=node --format=cjs --packages=external --sourcemap --outfile=dist/server.cjs` | Builds frontend assets and bundles the Node server | +| `start` | `node dist/server.cjs` | Runs the compiled production server | +| `preview` | `vite preview` | Previews the built Vite frontend | +| `lint` | `tsc --noEmit` | Runs TypeScript type checking | +| `clean` | `rm -rf dist server.js` | Removes build artifacts | + +--- + +## API Endpoints + +- **`GET /api/health`** + Returns server status, whether `GEMINI_API_KEY` is configured, and an ISO timestamp. +- **`POST /api/chat`** + Accepts `{ message, history?, model?, rolePreset? }` and returns `{ text, model }` using `@google/genai` with a model fallback chain.