meti-frontend/README.md

99 lines
2.5 KiB
Markdown
Raw Permalink Normal View History

2025-08-15 23:03:15 +07:00
# E-Voting Platform
A modern e-voting platform built with Next.js and integrated with an external authentication API.
## Features
- External API authentication
- Role-based access control (Admin/Voter)
- Modern UI with Tailwind CSS
- Responsive design
- Secure session management
## Setup
### Environment Variables
Create a `.env.local` file in the root directory with the following variables:
```bash
# External API Configuration
2025-08-15 23:16:19 +07:00
NEXT_PUBLIC_API_BASE_URL=https://evoting-be.apskel.org
2025-08-15 23:03:15 +07:00
NEXT_PUBLIC_API_AUTH_HEADER=••••••
# JWT Secret (for local token generation)
JWT_SECRET=your-secret-key-change-this
# Environment
NODE_ENV=development
# Base URL for the application
NEXT_PUBLIC_BASE_URL=http://localhost:3000
```
### API Endpoints
The application expects the following external API endpoints:
- `POST /api/v1/auth/login` - User authentication
- `POST /api/v1/auth/logout` - User logout
- `GET /api/v1/auth/verify` - Token verification
### Login Credentials
Use the following credentials for testing:
```bash
curl --location 'localhost:4000/api/v1/auth/login' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data-raw '{
"email": "superadmin@example.com",
"password": "ChangeMe!Super#123"
}'
```
## Development
```bash
# Install dependencies
npm install
# Run development server
npm run dev
# Build for production
npm run build
# Start production server
npm start
```
## Architecture
- **Frontend**: Next.js 15 with React 19
- **Styling**: Tailwind CSS with shadcn/ui components
- **Authentication**: External API integration with local token storage
- **State Management**: React hooks with localStorage persistence
## File Structure
```
├── app/ # Next.js app directory
│ ├── admin/ # Admin dashboard
│ ├── login/ # Login page
│ ├── vote/ # Voting interface
│ └── api/ # API routes (removed - using external API)
├── components/ # Reusable UI components
├── hooks/ # Custom React hooks
├── lib/ # Utility libraries and configuration
└── public/ # Static assets
```
## Security Notes
- The application now uses an external authentication API
- Local JWT tokens are used for session management
- All sensitive operations are delegated to the external API
- Environment variables should be properly secured in production