A modern, full-stack web application built with Go backend and React frontend. The application features a robust API server with comprehensive response handling, configuration management, and a responsive user interface.
PWS follows a monorepo structure with clearly separated frontend and backend applications:
PWS/
├── apps/
│ ├── server/ # Go backend API server
│ │ ├── main.go # Application entry point
│ │ ├── api/ # API layer (routes, middleware, responses)
│ │ ├── config/ # Configuration management
│ │ ├── database/ # Database connection and models
│ │ ├── lib/ # Helper functions
│ │ ├── services/ # Business logic services
│ │ └── types/ # Shared type definitions
│ └── ui/ # React frontend application
│ ├── app/ # React Router v7 application
│ ├── public/ # Static assets
│ └── build/ # Production build output
├── LICENSE # Project license
└── README.md # This documentation
- Go 1.25.0 - High-performance programming language
- Fiber v3.0.0-rc.1 - Express-inspired web framework
- slog - Structured logging (Go standard library)
- goccy/go-json - High-performance JSON encoding
- godotenv - Environment variable management
- React 19 - Modern UI library with latest features
- React Router v7 - File-based routing with SSR support
- TypeScript - Type safety and developer experience
- Tailwind CSS v4 - Utility-first CSS framework
- Vite - Fast build tool and development server
- Bun - Package manager and runtime
- High Performance: Built with Fiber for exceptional speed and low memory usage
- Structured Logging: Comprehensive logging with slog for debugging and monitoring
- Configuration Management: Singleton pattern for thread-safe environment management
- Response Builder Pattern: Fluent API for consistent response formatting
- CORS Support: Configurable cross-origin resource sharing
- Type Safety: Strong typing throughout the application
- Extensible Middleware: Easy-to-extend middleware architecture
- Server-Side Rendering: React Router v7 with SSR capabilities
- Dark Mode Support: Automatic theme switching with Tailwind CSS
- Type-Safe Routing: TypeScript integration for route definitions
- Responsive Design: Mobile-first design with Tailwind utilities
- Hot Module Replacement: Fast development with instant updates
- Optimized Builds: Production-ready builds with code splitting
- Go 1.25.0 - Download Go
- Bun (recommended) or Node.js 18+ - Install Bun
- Git - For version control
-
Clone the repository:
git clone [email protected]:MonkyMars/PWS.git cd PWS
-
Start the backend server:
cd apps/server # Install dependencies go mod tidy # Copy environment configuration cp .env.example .env # Start development server go run main.go
The API server will be available at
http://localhost:8080 -
Start the frontend application (in a new terminal):
cd apps/ui # Install bun npm install -g bun # Install dependencies bun install # Start development server bun run dev
The UI will be available at
http://localhost:5173
Backend:
cd apps/server
go build -o pws-server main.go
./pws-serverFrontend:
cd apps/ui
bun run build
bun run start- Environment Variables: Centralized loading and validation
- Logging Setup: Structured logging configuration with slog
- Fiber Configuration: Web server setup with optimized settings
- Singleton Pattern: Thread-safe access to configuration
- Standardized Responses: Consistent API response format
- Builder Pattern: Fluent API for response construction
- Error Handling: Structured error responses with codes and details
- Pagination Support: Built-in pagination for list endpoints
- CORS: Cross-origin resource sharing configuration
- Extensible Design: Easy addition of new middleware components
- Request/Response Processing: Standardized middleware patterns
- RESTful Design: Standard REST API patterns
- Route Organization: Feature-based route grouping
- Handler Functions: Clean separation of route logic
- Logic: Contains all the business logic in an organized way
- Core: The core of the server
- Health: Clean health routes logic
- Root Layout: Base HTML structure and global providers
- Route Components: File-based routing with React Router v7
- Welcome Component: Landing page with responsive design
- TypeScript Integration: Full type safety throughout
- Tailwind CSS: Utility-first styling approach
- Responsive Design: Mobile-first breakpoints
- Component Styling: Scoped styles with CSS modules support
All API endpoints return responses in the following format:
{
"success": true,
"message": "Operation completed successfully",
"data": {
// Response data
},
"pagination": {
"page": 1,
"limit": 10,
"total": 100,
"pages": 10
},
"timestamp": "2024-01-15T10:30:00Z"
}{
"success": false,
"message": "Error description",
"error": {
"code": "ERROR_CODE",
"message": "Detailed error message",
"details": {
// Additional error context
}
},
"timestamp": "2024-01-15T10:30:00Z"
}These endpoints are only available in the development environment
GET /health- Basic server health checkGET /health/database- Ping the database and check for errors
- Follow Go Conventions: Use standard Go naming and structure conventions
- Document Public APIs: Include Go doc comments for all exported functions
- Handle Errors Properly: Use structured error responses with context
- Write Tests: Comprehensive test coverage for business logic
- Use Structured Logging: Include relevant context in all log messages
Example handler function:
// GetUsers retrieves a paginated list of users
func GetUsers(c *fiber.Ctx) error {
users, total, err := userService.GetUsers(c.Context())
if err != nil {
return response.Error(c).
Message("Failed to retrieve users").
Code("USER_FETCH_ERROR").
Details(err.Error()).
Send()
}
return response.Success(c).
Message("Users retrieved successfully").
Data(users).
Pagination(1, 10, total).
Send()
}- Use TypeScript: Strong typing for all components and utilities
- Follow React Patterns: Functional components with hooks
- Document Components: JSDoc comments for component interfaces
- Responsive Design: Mobile-first approach with Tailwind utilities
- Accessibility: Include proper ARIA labels and semantic HTML
Example component:
/**
* User profile component displaying user information.
*
* @param props - Component properties
* @returns User profile JSX element
*/
export function UserProfile({ user, onEdit }: UserProfileProps) {
return (
<div className="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6">
<h2 className="text-xl font-semibold text-gray-900 dark:text-white">
{user.name}
</h2>
<p className="text-gray-600 dark:text-gray-300">{user.email}</p>
<button
onClick={onEdit}
className="mt-4 px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"
aria-label={`Edit profile for ${user.name}`}
>
Edit Profile
</button>
</div>
);
}
interface UserProfileProps {
user: {
name: string;
email: string;
};
onEdit: () => void;
}- Go: Use
go fmt,go vet, andgolangci-lint - TypeScript: Use Prettier and ESLint for code formatting
- Testing: Maintain test coverage above 80%
- Documentation: Update README files for package changes
This project is licensed under the terms specified in the LICENSE file.
For questions, issues, or contributions:
- Check existing issues in the repository
- Create a new issue with detailed information
- Follow the contribution guidelines
- Join community discussions
Built with modern technologies for performance, scalability, and developer experience.