Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
832f7cd
Merge pull request #5 from bos-com/3-system-arch
RonaldRonnie Sep 7, 2025
da8af83
docs: update README with frontend details (Fixes #1)
kmuwanga83 Nov 13, 2025
7cb9ea5
Update issue templates
stevenkiwanukakafeero Mar 24, 2026
8e9c89d
Update README.md
RonaldRonnie Apr 21, 2026
c364dd7
Enhance API documentation structure and clarity
stevenkiwanukakafeero Apr 30, 2026
0841e6c
Merge pull request #3 from stevenkiwanukakafeero/stevenkiwanukakafeer…
stevenkiwanukakafeero Apr 30, 2026
88fa651
Create docker-setup.md
stevenkiwanukakafeero Apr 30, 2026
ada449e
Add missing ignore patterns for test reports and local environments
stevenkiwanukakafeero May 1, 2026
f4371e7
Merge pull request #4 from stevenkiwanukakafeero/stevenkiwanukakafeer…
stevenkiwanukakafeero May 1, 2026
6edf6c1
Update next steps in setup.sh for clarity
stevenkiwanukakafeero May 1, 2026
02298ca
Merge pull request #5 from stevenkiwanukakafeero/stevenkiwanukakafeer…
stevenkiwanukakafeero May 1, 2026
9b17e2a
Enhance security notes and update password placeholders
stevenkiwanukakafeero May 1, 2026
fbfd322
Merge pull request #6 from stevenkiwanukakafeero/stevenkiwanukakafeer…
stevenkiwanukakafeero May 1, 2026
73dcd64
Add testing guide for contributors
stevenkiwanukakafeero May 1, 2026
0bc1c0f
Merge pull request #7 from stevenkiwanukakafeero/stevenkiwanukakafeer…
stevenkiwanukakafeero May 1, 2026
0eab103
Implement user input validation in UserService
stevenkiwanukakafeero May 1, 2026
83a2ec9
Merge pull request #8 from stevenkiwanukakafeero/stevenkiwanukakafeer…
stevenkiwanukakafeero May 1, 2026
308d88c
Add handler for IllegalArgumentException
stevenkiwanukakafeero May 1, 2026
67d8434
Merge pull request #9 from stevenkiwanukakafeero/stevenkiwanukakafeer…
stevenkiwanukakafeero May 1, 2026
97f1f11
Add endpoint to retrieve active users
stevenkiwanukakafeero May 1, 2026
7dfa56d
Add method to find active users in UserRepository
stevenkiwanukakafeero May 1, 2026
3db7c48
Merge pull request #138 from stevenkiwanukakafeero/stevenkiwanukakafe…
RonaldRonnie May 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,13 @@ temp/
# Docker
.dockerignore
docker-compose.override.yml
# Test reports and coverage
coverage/
*.lcov
surefire-reports/
failsafe-reports/

# Local environment variants
.env.development
.env.test
.env.staging
298 changes: 19 additions & 279 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,288 +1,28 @@
# GreenCode Backend
# GreenCode

A robust Java backend application built with Spring Boot for the GreenCode project - an innovative platform focused on sustainable development and environmental initiatives.
GreenCode is an API core system designed to support esm_greencode .
It consists of a **Spring Boot backend API**

## 🎯 Project Overview
---

GreenCode is a comprehensive backend system designed to support environmental sustainability projects, green technology initiatives, and eco-friendly business operations. The platform provides robust APIs for managing environmental data, user authentication, and sustainable development metrics.
## 🚀 Features

## 🚀 Technology Stack
### Backend (Spring Boot)
- RESTful API
- JWT/OAuth authentication
- PostgreSQL database support
- Centralised configuration (`config/`, `.env`)
- Dockerized for easy deployment
- Swagger/OpenAPI documentation

- **Java 17** - Modern Java with latest features
- **Spring Boot 3.2.0** - Rapid application development framework
- **Spring Security** - Authentication and authorization
- **Spring Data JPA** - Data persistence layer
- **H2 Database** - In-memory database for development
- **PostgreSQL** - Production database support
- **Maven** - Dependency management and build tool
- **JWT** - JSON Web Token authentication
- **Swagger/OpenAPI** - API documentation
- **Spring Actuator** - Application monitoring and metrics

## 📋 Prerequisites

- Java 17 or higher
- Maven 3.6 or higher
- PostgreSQL (for production)

## 🛠️ Quick Start

### 1. Clone and Setup
```bash
git clone https://github.com/bos-com/GreenCode.git
cd GreenCode
```

### 2. Build and Run
```bash
mvn clean install
mvn spring-boot:run
```

The application will start on `http://localhost:8080`

## 🏗️ Project Structure

```
## 📁 Project Structure
GreenCode/
├── pom.xml # Maven configuration
├── Dockerfile # Containerization
├── docker-compose.yml # Multi-service setup
├── .env.example # Environment variables template
├── .gitignore # Git ignore rules
├── README.md # This file
├── docs/ # Project documentation
│ ├── api/ # API documentation
│ ├── deployment/ # Deployment guides
│ └── architecture/ # System architecture
├── scripts/ # Utility scripts
│ ├── setup.sh # Development setup
│ ├── deploy.sh # Deployment script
│ └── backup.sh # Database backup
├── config/ # External configuration
│ ├── nginx/ # Nginx configuration
│ └── docker/ # Docker configurations
├── src/
│ ├── main/
│ │ ├── java/com/greencode/
│ │ │ ├── GreenCodeApplication.java # Main application
│ │ │ ├── config/ # Configuration classes
│ │ │ │ ├── SecurityConfig.java # Security setup
│ │ │ │ ├── DatabaseConfig.java # Database configuration
│ │ │ │ ├── SwaggerConfig.java # API documentation
│ │ │ │ └── CorsConfig.java # CORS settings
│ │ │ ├── controller/ # REST controllers
│ │ │ │ ├── UserController.java # User management
│ │ │ │ ├── AuthController.java # Authentication
│ │ │ │ └── HealthController.java # Health checks
│ │ │ ├── dto/ # Data Transfer Objects
│ │ │ │ ├── UserDto.java # User DTO
│ │ │ │ ├── AuthDto.java # Authentication DTO
│ │ │ │ └── ResponseDto.java # Common responses
│ │ │ ├── entity/ # JPA entities
│ │ │ │ ├── BaseEntity.java # Base entity
│ │ │ │ ├── User.java # User entity
│ │ │ │ └── Project.java # Project entity
│ │ │ ├── exception/ # Exception handling
│ │ │ │ ├── GlobalExceptionHandler.java
│ │ │ │ ├── CustomException.java # Custom exceptions
│ │ │ │ └── ErrorCode.java # Error codes
│ │ │ ├── repository/ # Data access layer
│ │ │ │ ├── UserRepository.java # User repository
│ │ │ │ └── ProjectRepository.java # Project repository
│ │ │ ├── service/ # Business logic
│ │ │ │ ├── UserService.java # User service
│ │ │ │ ├── AuthService.java # Authentication service
│ │ │ │ └── ProjectService.java # Project service
│ │ │ ├── util/ # Utility classes
│ │ │ │ ├── JwtUtil.java # JWT utilities
│ │ │ │ ├── ValidationUtil.java # Validation helpers
│ │ │ │ └── DateUtil.java # Date utilities
│ │ │ └── constant/ # Constants
│ │ │ ├── AppConstants.java # Application constants
│ │ │ └── SecurityConstants.java # Security constants
│ │ └── resources/
│ │ ├── application.yml # Main configuration
│ │ ├── application-dev.yml # Development config
│ │ ├── application-prod.yml # Production config
│ │ ├── db/ # Database scripts
│ │ │ ├── schema.sql # Database schema
│ │ │ └── data.sql # Initial data
│ │ └── static/ # Static resources
│ └── test/
│ ├── java/com/greencode/
│ │ ├── GreenCodeApplicationTests.java
│ │ ├── controller/ # Controller tests
│ │ ├── service/ # Service tests
│ │ └── repository/ # Repository tests
│ └── resources/
│ └── application-test.yml # Test configuration
├── logs/ # Application logs
├── data/ # Data storage
└── reports/ # Generated reports
```

## 🔧 Configuration

### Environment Variables
Copy `.env.example` to `.env` and configure:
```bash
# Database
DB_HOST=localhost
DB_PORT=5432
DB_NAME=greencode
DB_USER=postgres
DB_PASSWORD=password

# JWT
JWT_SECRET=your-secret-key
JWT_EXPIRATION=86400000

# Server
SERVER_PORT=8080
SERVER_CONTEXT_PATH=/api
```

### Database Setup
```bash
# Development (H2 - automatic)
# Production (PostgreSQL)
psql -U postgres -c "CREATE DATABASE greencode;"
```

## 🌐 API Endpoints

### Authentication
- `POST /api/auth/login` - User login
- `POST /api/auth/register` - User registration
- `POST /api/auth/refresh` - Refresh token
- `POST /api/auth/logout` - User logout

### User Management
- `GET /api/users` - Get all users
- `GET /api/users/{id}` - Get user by ID
- `POST /api/users` - Create new user
- `PUT /api/users/{id}` - Update user
- `DELETE /api/users/{id}` - Delete user

### Project Management
- `GET /api/projects` - Get all projects
- `GET /api/projects/{id}` - Get project by ID
- `POST /api/projects` - Create new project
- `PUT /api/projects/{id}` - Update project
- `DELETE /api/projects/{id}` - Delete project

### Health & Monitoring
- `GET /api/health` - Application health
- `GET /api/metrics` - Application metrics
- `GET /api/info` - Application information

## 🔐 Security Features

- JWT-based authentication
- Role-based access control (USER, ADMIN, MODERATOR)
- Password encryption with BCrypt
- CORS configuration for frontend integration
- Input validation and sanitization
- Rate limiting protection

## 🗄️ Database Schema

### Core Tables
- **users** - User accounts and profiles
- **projects** - Environmental projects
- **roles** - User roles and permissions
- **audit_logs** - System activity tracking

### Key Features
- Soft delete support
- Audit trail for all changes
- Optimized indexes for performance
- Data validation constraints

## 🧪 Testing

```bash
# Run all tests
mvn test

# Run with coverage
mvn jacoco:report

# Run specific test
mvn test -Dtest=UserServiceTest

# Integration tests
mvn verify
```

## 🚀 Deployment

### Docker Compose
```bash
# Start all services
docker-compose up -d

# View logs
docker-compose logs -f

# Stop services
docker-compose down
```

### Production Deployment
```bash
# Build production JAR
mvn clean package -Pprod

# Run with production profile
java -jar -Dspring.profiles.active=prod target/greencode-backend-1.0.0.jar
```

## 📊 Monitoring

- **Health Checks**: `/api/health`
- **Metrics**: Prometheus format available
- **Logging**: Structured logging with logback
- **Tracing**: Request tracing for debugging

## 🔄 Development Workflow

1. **Feature Development**
- Create feature branch: `git checkout -b feature/new-feature`
- Implement changes with tests
- Submit pull request

2. **Code Quality**
- Run tests: `mvn test`
- Check style: `mvn checkstyle:check`
- Security scan: `mvn dependency:check`

3. **Deployment**
- Development: Automatic deployment on push to dev branch
- Production: Manual deployment with approval process

## 🤝 Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes with tests
4. Ensure all tests pass
5. Submit a pull request

### Code Standards
- Follow Java naming conventions
- Add Javadoc for public methods
- Include unit tests for new features
- Use meaningful commit messages

## 📝 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
├── src/ # Spring Boot source code
├── config/ # external configuration & scripts
├── docs/ # architecture, API docs
├── greencode-frontend/ # React frontend (new)
├── pom.xml # Maven build file
└── docker-compose.yml # Docker orchestration

## 🆘 Support

- **Documentation**: Check the `docs/` folder
- **Issues**: Create an issue in the repository
- **Discussions**: Use GitHub Discussions for questions
- **Email**: Contact the development team
Loading