Web interface made in React to interact with Conluz, an energy management system focused on energy communities.
- Framework: React 19.1 with TypeScript
- Build Tool: Vite 7.0
- Routing: React Router 7.6
- UI Components: Material-UI (MUI) 7.2
- State Management: TanStack React Query 5.81
- API Client: Auto-generated from OpenAPI spec using Orval
- Testing: Vitest with React Testing Library
- Charts: ApexCharts
- Date Handling: Day.js
- HTTP Client: Axios
conluz-web/
βββ src/
β βββ api/ # Auto-generated API client (organized by tags)
β β βββ authentication/
β β βββ configuration/
β β βββ consumption/
β β βββ models/
β β βββ plants/
β β βββ prices/
β β βββ production/
β β βββ supplies/
β β βββ users/
β βββ components/ # Reusable UI components
β β βββ AppAccordion/
β β βββ AppCard/ # Base card primitive
β β βββ Auth/
β β βββ Breadcrumb/
β β βββ CardGrid/
β β βββ DetailHeader/ # Shared header for detail pages
β β βββ ErrorBoundries/
β β βββ Errors/
β β βββ FilterChips/
β β βββ Forms/
β β βββ Graph/
β β βββ Header/
β β βββ Menu/
β β βββ Modals/ # AppModal + confirmation/import modals
β β βββ PaginatedList/
β β βββ Pagination/
β β βββ SearchBar/
β β βββ Stat/
β β βββ SupplyCard/
β β βββ SupplyDetailCard/
β β βββ SupplyForm/
β β βββ PageHeader/
β βββ context/ # React Context providers (auth, user)
β βββ layouts/ # Page layouts
β β βββ authenticated.layout.tsx
β β βββ login.layout.tsx
β β βββ dynamic.layout.tsx
β βββ pages/ # Route pages
β β βββ Home.tsx
β β βββ Login.tsx
β β βββ ForgotPassword.tsx
β β βββ NewPassword.tsx
β β βββ SupplyPointsPage.tsx
β β βββ SupplyDetailPage.tsx
β β βββ CreateSupply.tsx
β β βββ EditSupply.tsx
β β βββ Contact.page.tsx
β βββ utils/ # Utility functions
βββ docker/ # Docker configuration
β βββ docker-compose.yaml
β βββ Dockerfile
β βββ nginx.conf
β βββ env.sh
βββ public/ # Static assets
βββ docs/ # Documentation
βββ api-docs.json # OpenAPI specification
- Supply Point Management: Create, edit, and view energy supply points
- Authentication System: Login, password recovery, token-based auth
- Energy Data Visualization: Consumption and production graphs using ApexCharts
- Responsive Design: Mobile-friendly interface with MUI responsive breakpoints
- Multi-layout Support: Different layouts for authenticated/unauthenticated pages
- Auto-generated API: Type-safe API client generated from OpenAPI specification
- Real-time Data: Energy consumption and production tracking
- User Management: Profile management and user settings
- Home (
/): Dashboard/landing page - Supply Points (
/supply-points): List and manage energy supply points - New Supply (
/supply-points/new): Create a new supply point - Supply Detail (
/supply-points/:id): Detailed view of a supply point - Edit Supply (
/supply-points/:id/edit): Edit supply point information - Login (
/login): User authentication - Forgot Password (
/forgot-password): Password recovery flow - Reset Password (
/forgot-password/:token): Password reset with token - Contact (
/contact): Support and contact page
- Node.js (v18 or higher recommended)
- npm (comes with Node.js)
- Clone the repository:
git clone https://github.com/lucoenergia/conluz-web.git
cd conluz-web- Install dependencies:
npm install- Configure environment variables (optional):
export CONLUZ_API_URL=http://localhost:8443To run the project for development with hot-reloading:
npm run devThe application will be available at http://localhost:3001
npm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLint
npm test # Run tests
npm run generate-client # Regenerate API client from OpenAPI specPrerequisites: Docker and Docker Compose must be installed on your system.
Run the application using Docker Compose:
cd docker
docker compose up -dThe application will be available at http://localhost:3001
You can configure the docker-compose.yml file to use a locally built image:
build:
context: ..
dockerfile: docker/DockerfileA new Docker image (ghcr.io/lucoenergia/conluz-web:latest) is automatically built and published to GitHub Container Registry whenever code is pushed to the main branch.
To use the pre-built image:
- Login to GitHub Container Registry (if the image is private):
echo $GITHUB_TOKEN | docker login ghcr.io -u $GITHUB_USERNAME --password-stdinGITHUB_TOKEN: A personal access token withread:packagesscopeGITHUB_USERNAME: Your GitHub username
- Pull and run the image:
docker compose pull
docker compose up -dThe models and methods to interact with the backend API are auto-generated from the OpenAPI specification using Orval.
-
Get the latest OpenAPI spec from the backend:
- Download from Swagger UI of a running backend instance
- Save as
api-docs.jsonin the project root
-
Regenerate the API client:
npm run generate-clientThis will update all TypeScript interfaces, models, and API methods in the src/api/ directory.
There is currently only one environment variable that can be configured:
CONLUZ_API_URL
This variable configures the URL of the backend to which the requests will be sent.
If new variables were to be included they must start with CONLUZ_ in order to be recognized by the vite build system. Furthermore, they must be included in the Dockerfile like this:
ARG CONLUZ_<VARIABLE_NAME>="CONLUZ_<VARIABLE_NAME>"In order to be hotswaped at the container startup. Further reading of the method used can be found here
- API Generation: Models and API methods are auto-generated from the backend's OpenAPI specification (
api-docs.json) using Orval - State Management:
- Global state managed through React Context (AuthContext, LoggedUserContext)
- Server state managed with TanStack React Query for caching and synchronization
- Authentication: Token-based authentication with automatic token persistence and refresh
- Error Handling:
- Global error boundaries for React component errors
- Query error handling with automatic 401 response handling
- Styling Strategy: MUI-only β the theme in
src/theme/is the single source of truth for all design tokens (colours, radii, shadows, typography). Seedocs/styling-conventions.mdfor authoring rules. - Code Splitting: Manual chunks configuration in Vite for optimized bundle sizes
- Testing Strategy: Component testing with Vitest and React Testing Library, MSW for API mocking
- Type Safety: Full TypeScript coverage with auto-generated types from OpenAPI spec
The project includes unit tests for critical components. Run tests with:
# Run tests once
npm test
# Run tests in watch mode
npm run test -- --watch# Build for production
npm run build
# Preview production build
npm run previewPlease read CONTRIBUTE.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the terms described in the LICENSE file.