Development Setup and Configuration
Prerequisites
- Node.js 18+ (or Bun)
- npm, yarn, pnpm, or bun package manager
- Git
Installation
# Clone the repository
git clone <repository-url>
cd ibw-admin
# Install dependencies
npm install
# or
bun installEnvironment Configuration
Create a .env file in the root directory:
VITE_BASE_URL=http://localhost:8080Environment Variables
VITE_BASE_URL: Base URL for the backend API- Development:
http://localhost:8080 - Production:
https://ibw-app-service.lemonpebble-d3abe181.southeastasia.azurecontainerapps.io
- Development:
Development Server
# Start development server
npm run dev
# or
bun run devThe application will be available at http://localhost:5173 (default Vite port).
Build
# Build for production
npm run build
# or
bun run buildThe production build will be output to the dist/ directory.
Preview Production Build
# Preview production build locally
npm run preview
# or
bun run previewLinting
# Run ESLint
npm run lint
# or
bun run lintProject Configuration
Vite Configuration (vite.config.ts)
import path from "path";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react(), tailwindcss()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
});Key Features:
- React plugin for JSX/TSX support
- Tailwind CSS plugin for styling
- Path alias
@pointing tosrc/directory
TypeScript Configuration
tsconfig.json
Main TypeScript configuration.
tsconfig.app.json
Application-specific TypeScript configuration.
tsconfig.node.json
Node.js-specific TypeScript configuration (for Vite config).
ESLint Configuration (eslint.config.js)
ESLint configuration for code quality and consistency.
Directory Structure
ibw-admin/
├── public/ # Public static files
│ ├── favicon.ico
│ └── vite.svg
├── src/
│ ├── app/ # Application data
│ │ └── dashboard/
│ │ └── data.json
│ ├── assets/ # Static assets
│ │ ├── react.svg
│ │ └── telegram_bg.png
│ ├── components/ # React components
│ │ ├── ui/ # UI primitives
│ │ ├── quest/ # Quest components
│ │ └── users/ # User components
│ ├── contexts/ # React contexts
│ ├── hooks/ # Custom hooks
│ ├── lib/ # Utilities and API client
│ ├── pages/ # Page components
│ ├── App.tsx # Main app component
│ ├── App.css # App styles
│ ├── index.css # Global styles
│ └── main.tsx # Entry point
├── dist/ # Build output
├── node_modules/ # Dependencies
├── .env # Environment variables (not in git)
├── .gitignore
├── components.json # shadcn/ui configuration
├── eslint.config.js # ESLint config
├── index.html # HTML template
├── package.json # Dependencies and scripts
├── README.md # Project documentation
├── tsconfig.json # TypeScript config
├── tsconfig.app.json # TypeScript app config
├── tsconfig.node.json # TypeScript node config
└── vite.config.ts # Vite configurationPath Aliases
The project uses path aliases for cleaner imports:
@/→src/
Example:
import { apiClient } from "@/lib/api";
import { Button } from "@/components/ui/button";Code Style
TypeScript
- Use TypeScript for all new code
- Define interfaces for all data structures
- Use type inference where appropriate
- Avoid
anytype (useunknownif needed)
React
- Use functional components with hooks
- Use TypeScript for component props
- Follow React best practices
- Use proper key props for lists
Styling
- Use Tailwind CSS utility classes
- Follow mobile-first responsive design
- Use consistent spacing and sizing
- Maintain accessibility standards
Development Workflow
-
Create a feature branch
git checkout -b feature/your-feature-name -
Make changes
- Write code following project conventions
- Add/update tests if applicable
- Update documentation if needed
-
Test locally
npm run dev npm run lint -
Commit changes
git add . git commit -m "feat: your feature description" -
Push and create PR
git push origin feature/your-feature-name
Common Issues and Solutions
Port Already in Use
If port 5173 is already in use:
# Kill process on port 5173
lsof -ti:5173 | xargs kill -9Or specify a different port:
npm run dev -- --port 3000Module Resolution Issues
If you encounter module resolution errors:
- Delete
node_modulesandpackage-lock.json - Run
npm installagain - Restart your IDE/editor
TypeScript Errors
If TypeScript shows errors:
- Restart TypeScript server in your IDE
- Check
tsconfig.jsonconfiguration - Ensure all dependencies are installed
Browser Support
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
Performance Optimization
- Code splitting via React.lazy()
- Image optimization
- Bundle size monitoring
- Lazy loading for routes
- Memoization for expensive computations
Security Considerations
- Never commit
.envfiles - Validate all user inputs
- Sanitize data before rendering
- Use HTTPS in production
- Implement proper authentication checks
- Validate API responses