A modern web application built with Next.js, TypeScript, and Web3Auth for decentralized authentication.
- Web3Auth Integration: Decentralized authentication with multiple wallet providers
- Client-side Persistence: Secure session management using Zustand with localStorage
- Modern UI: Built with Tailwind CSS and Shadcn UI components
- TypeScript: Full type safety throughout the application
This application uses Web3Auth for decentralized authentication with Zustand for client-side state management. The authentication flow works as follows:
- Web3Auth Integration: Users can connect their wallets through Web3Auth
- Client-Side Storage: User sessions are persisted in localStorage with Zustand
- Cross-Tab Synchronization: Authentication state syncs across browser tabs
- Client-Side Hooks: React hooks provide easy access to authentication state
useAuthStore(): Main authentication store for client componentsuseWeb3AuthConnect(): Web3Auth connection managementuseWeb3AuthUser(): Web3Auth user informationuseWeb3AuthDisconnect(): Web3Auth disconnect functionality
| Route | Method | Description |
|---|---|---|
/api/auth |
POST | Sign in a user (Web3Auth) |
/api/auth |
DELETE | Sign out the current user |
/api/auth |
GET | Get the current session |
/api/projects |
GET | (Stub/Planned) Fetch projects (currently commented out) |
/api/users/[walletAddress] |
GET | Fetch proposals reviewed by a user (by wallet address) |
/api/proposals |
GET | List proposals (supports pagination) |
/api/proposals/create |
POST | Create a new proposal |
/api/proposals/[id] |
GET | Get a proposal by ID |
/api/proposals/[id] |
DELETE | Delete a proposal by ID |
/api/proposals/[id]/publish |
POST | Publish a proposal |
/api/proposals/[id]/rubric-answer |
POST | Submit a rubric answer for a proposal |
/api/proposals/[id]/rubric-results |
GET | Get rubric results for a proposal |
/api/proposals/[id]/scientific-review |
POST | Submit a scientific review for a proposal |
/api/proposal-templates |
GET | Get available proposal templates |
/api/proposals/upload |
POST | Upload files related to proposals |
Create a .env.local file with the following variables:
# NextJS
SITE_NAME=
SITE_URL=
NEXT_PUBLIC_APP_URL=
API_BASE_URL=
# Web3Auth handles authentication - no additional auth env vars needed
# Web3Auth (Client-side variables)
NEXT_PUBLIC_WEB3AUTH_CLIENT_ID=-
Install dependencies:
npm install
-
Run the development server:
npm run dev
-
Open your browser and navigate to
http://localhost:3000
src/
├── app/ # Next.js App Router
│ ├── api/ # API routes
│ ├── (site)/ # Main site pages
│ └── hooks/ # Custom React hooks
├── components/ # Reusable UI components
├── config/ # Configuration files
├── fonts/ # Custom fonts
├── interfaces/ # TypeScript interfaces
├── libs/ # Utility libraries
├── services/ # Business logic services
├── staticData/ # Static data files
├── styles/ # Global styles
├── types/ # TypeScript types
├── utils/ # Utility functions
└── middleware.ts # Middleware for session management
| Route | Description |
|---|---|
/ |
Home page |
/auth/signin |
Sign in with Web3Auth |
/user |
User dashboard/profile |
/proposals |
List all proposals |
/proposals/create |
Create a new proposal |
/proposals/[id] |
View a specific proposal |
/proposals/[id]/edit |
Edit a specific proposal |
/constitution |
View the EvoLabs constitution |
/faq |
Frequently Asked Questions |
/contact |
Contact page |
/whitepaper |
View the EvoLabs whitepaper |
/projects |
List of projects (if implemented) |
- User clicks "Sign In" → Web3Auth modal opens
- User connects wallet → Web3Auth provides user data
- User data processed → Zustand store updates with user information
- State persisted → Authentication state saved to localStorage
- User redirected → To protected dashboard/user area
- Cross-tab sync → Authentication state syncs across browser tabs
- Web3Auth Security: Leverages Web3Auth's built-in security features
- Client-Side Validation: Authentication state validated on the client
- Wallet Integration: Secure wallet connection and management
- Token Management: Web3Auth handles token lifecycle
- Cross-Tab Synchronization: Consistent authentication state across tabs
// In middleware.ts
const protectedRoutes = ['/user', '/proposals/create', '/dashboard'];// Client components
import { useAuth } from '@/app/hooks/useAuth';
function MyComponent() {
const { user, isAuthenticated, signOut } = useAuth();
if (!isAuthenticated) {
return <div>Please sign in</div>;
}
return <div>Welcome, {user?.name}!</div>;
}
// Server components
import { requireAuth } from '@/libs/serverAuth';
async function ServerComponent() {
const session = await requireAuth();
return <div>Welcome, {session.user?.name}!</div>;
}The application is ready for deployment on platforms like Vercel, Netlify, or any Node.js hosting service. Make sure to:
- Set all required environment variables
- Configure your database connection
- Set up Web3Auth client ID for production
- Configure Web3Auth network settings
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
TBD