{"id":51332901,"url":"https://github.com/princepal-dev/ylca-blogger","last_synced_at":"2026-07-02T00:30:34.796Z","repository":{"id":330830022,"uuid":"1124027872","full_name":"princepal-dev/ylca-blogger","owner":"princepal-dev","description":null,"archived":false,"fork":false,"pushed_at":"2026-01-11T05:51:41.000Z","size":1508,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-11T12:45:38.852Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/princepal-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-28T06:53:32.000Z","updated_at":"2026-01-11T05:51:44.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/princepal-dev/ylca-blogger","commit_stats":null,"previous_names":["princepal-dev/ylca-blogger"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/princepal-dev/ylca-blogger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/princepal-dev%2Fylca-blogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/princepal-dev%2Fylca-blogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/princepal-dev%2Fylca-blogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/princepal-dev%2Fylca-blogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/princepal-dev","download_url":"https://codeload.github.com/princepal-dev/ylca-blogger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/princepal-dev%2Fylca-blogger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35028640,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-01T02:00:05.325Z","response_time":130,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-02T00:30:34.258Z","updated_at":"2026-07-02T00:30:34.790Z","avatar_url":"https://github.com/princepal-dev.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blogger API\n\nA comprehensive REST API for a blogging platform built with Spring Boot, featuring user authentication, blog management, image uploads, and role-based access control.\n\n**Created by Prince Pal**\n\n## 🚀 Features\n\n### Core Functionality\n- **User Authentication \u0026 Authorization**\n  - JWT-based authentication with HTTP-only cookies\n  - Role-based access control (Admin, Collaborator)\n  - Secure password hashing with BCrypt\n\n- **User Management**\n  - Admin user registration with secret key\n  - Admin can create users with auto-generated credentials\n  - Profile management for all users\n  - User deletion (admin only)\n\n- **Blog Management**\n  - Full CRUD operations for blog posts\n  - Rich text content support\n  - Author-based filtering\n  - Timestamp tracking (created/updated)\n\n- **Image Support**\n  - Multiple images per blog post\n  - File upload with validation (JPEG, PNG, GIF, WebP)\n  - Image ordering and management\n  - Automatic cleanup on blog deletion\n  - Static file serving\n\n### Security Features\n- JWT token authentication\n- Role-based permissions\n- Input validation and sanitization\n- Secure file upload handling\n- CSRF protection disabled for API\n- CORS configuration ready\n\n## 🛠️ Technology Stack\n\n- **Backend Framework**: Spring Boot 4.0.1\n- **Language**: Java 17\n- **Database**: MySQL 8.0+\n- **ORM**: Spring Data JPA with Hibernate\n- **Security**: Spring Security with JWT\n- **File Upload**: Spring Multipart\n- **Build Tool**: Maven\n- **Documentation**: Spring Boot Actuator (ready for Swagger)\n\n## 📋 Prerequisites\n\n- **Java**: JDK 17 or higher\n- **MySQL**: 8.0 or higher\n- **Maven**: 3.6+ (or use included Maven wrapper)\n- **Git**: For version control\n\n## 🔧 Installation \u0026 Setup\n\n### 1. Clone the Repository\n```bash\ngit clone \u003crepository-url\u003e\ncd blogger\n```\n\n### 2. Database Setup\nCreate a MySQL database:\n```sql\nCREATE DATABASE blogger_db;\n```\n\nUpdate database credentials in `src/main/resources/application.properties`:\n```properties\nspring.datasource.username=your_mysql_username\nspring.datasource.password=your_mysql_password\n```\n\n### 3. File System Setup\nCreate the image upload directory:\n```bash\nmkdir -p uploads/images\n```\n\n### 4. Build and Run\nUsing Maven wrapper (recommended):\n```bash\n./mvnw clean install\n./mvnw spring-boot:run\n```\n\nOr using system Maven:\n```bash\nmvn clean install\nmvn spring-boot:run\n```\n\nThe application will start on `http://localhost:8080`\n\n## ⚙️ Configuration\n\n### Application Properties\nKey configuration options in `application.properties`:\n\n```properties\n# Server\nserver.port=8080\n\n# Database\nspring.datasource.url=jdbc:mysql://localhost:3306/blogger_db?createDatabaseIfNotExist=true\nspring.datasource.username=root\nspring.datasource.password=password\n\n# JWT\nspring.app.jwtSecret=your-256-bit-secret\nspring.app.jwtExpirationMs=30000000\nspring.app.authKey=your-admin-secret-key\n\n# File Upload\nspring.servlet.multipart.max-file-size=10MB\nspring.servlet.multipart.max-request-size=50MB\napp.upload.dir=uploads/images/\n\n# Frontend (for CORS)\nfrontend.url=http://localhost:5173\n```\n\n## 📚 API Documentation\n\n### Authentication Endpoints (`/api/auth`)\n\n#### Register Admin\n```http\nPOST /api/auth/signup\nContent-Type: application/json\n\n{\n  \"username\": \"admin\",\n  \"password\": \"securepassword\",\n  \"secretKey\": \"__SecretKey__\"\n}\n```\n\n#### Login\n```http\nPOST /api/auth/signin\nContent-Type: application/json\n\n{\n  \"username\": \"admin\",\n  \"password\": \"securepassword\"\n}\n```\n**Response**: Sets JWT cookie + user info\n\n#### Create User (Admin Only)\n```http\nPOST /api/auth/users\nAuthorization: Bearer {jwt-token}\nContent-Type: application/json\n\n{\n  \"fullName\": \"John Doe\",\n  \"phoneNumber\": \"+1234567890\"\n}\n```\n**Response**: Generated credentials for the new user\n\n#### Update User Profile (Admin)\n```http\nPUT /api/auth/users/{userId}\nAuthorization: Bearer {jwt-token}\nContent-Type: application/json\n\n{\n  \"fullName\": \"Updated Name\",\n  \"phoneNumber\": \"+0987654321\"\n}\n```\n\n#### Update Own Profile\n```http\nPUT /api/auth/profile\nAuthorization: Bearer {jwt-token}\nContent-Type: application/json\n\n{\n  \"fullName\": \"My Updated Name\",\n  \"phoneNumber\": \"+0987654321\"\n}\n```\n\n#### Delete User (Admin Only)\n```http\nDELETE /api/auth/users/{userId}\nAuthorization: Bearer {jwt-token}\n```\n\n#### Logout\n```http\nPOST /api/auth/signout\n```\n**Response**: Clears JWT cookie\n\n### Blog Endpoints (`/api/blogs`)\n\n#### Create Blog\n```http\nPOST /api/blogs\nAuthorization: Bearer {jwt-token}\nContent-Type: application/json\n\n{\n  \"title\": \"My First Blog Post\",\n  \"description\": \"This is a comprehensive blog post content...\"\n}\n```\n\n#### Get All Blogs\n```http\nGET /api/blogs\n```\n\n#### Get Blog by ID\n```http\nGET /api/blogs/{id}\n```\n\n#### Get Blogs by Author\n```http\nGET /api/blogs/author/{authorId}\n```\n\n#### Get My Blogs\n```http\nGET /api/blogs/my\nAuthorization: Bearer {jwt-token}\n```\n\n#### Update Blog\n```http\nPUT /api/blogs/{id}\nAuthorization: Bearer {jwt-token}\nContent-Type: application/json\n\n{\n  \"title\": \"Updated Blog Title\",\n  \"description\": \"Updated content...\"\n}\n```\n\n#### Delete Blog\n```http\nDELETE /api/blogs/{id}\nAuthorization: Bearer {jwt-token}\n```\n\n### Image Endpoints (`/api/blogs`)\n\n#### Upload Single Image\n```http\nPOST /api/blogs/{blogId}/images\nAuthorization: Bearer {jwt-token}\nContent-Type: multipart/form-data\n\nfile: [image file]\ndisplayOrder: 1\n```\n\n#### Upload Multiple Images\n```http\nPOST /api/blogs/{blogId}/images/multiple\nAuthorization: Bearer {jwt-token}\nContent-Type: multipart/form-data\n\nfiles: [image1.jpg, image2.png]\ndisplayOrders: [1, 2]\n```\n\n#### Get Blog Images\n```http\nGET /api/blogs/{blogId}/images\n```\n\n#### Get Image by ID\n```http\nGET /api/blogs/images/{imageId}\n```\n\n#### Update Image Order\n```http\nPUT /api/blogs/images/{imageId}/order?displayOrder=2\nAuthorization: Bearer {jwt-token}\n```\n\n#### Delete Image\n```http\nDELETE /api/blogs/images/{imageId}\nAuthorization: Bearer {jwt-token}\n```\n\n## 🗄️ Database Schema\n\n### Tables Created Automatically\n- `users` - User accounts and profiles\n- `blogs` - Blog posts with author relationships\n- `images` - Image metadata with blog relationships\n\n### Key Relationships\n- User (1) → Blog (Many)\n- Blog (1) → Image (Many)\n\n## 🔒 Security \u0026 Permissions\n\n### User Roles\n- **ROLE_ADMIN**: Full access to all features\n- **ROLE_COLLABORATOR**: Blog and image management\n\n### Permission Matrix\n| Feature | Admin | Collaborator |\n|---------|-------|--------------|\n| Create Users | ✅ | ❌ |\n| Delete Users | ✅ | ❌ |\n| Manage All Blogs | ✅ | ❌ |\n| Manage Own Blogs | ✅ | ✅ |\n| Upload Images | ✅ | ✅ |\n| View All Content | ✅ | ✅ |\n\n## 📁 Project Structure\n\n```\nblogger/\n├── src/main/java/com/princeworks/blogger/\n│   ├── BloggerApplication.java          # Main application class\n│   ├── config/                          # Configuration classes\n│   │   ├── AppConfig.java              # ModelMapper bean\n│   │   └── WebMvcConfig.java           # Static resource config\n│   ├── controller/                      # REST controllers\n│   │   ├── AuthController.java         # Authentication \u0026 user management\n│   │   └── BlogController.java         # Blog \u0026 image operations\n│   ├── exceptions/                      # Custom exceptions\n│   ├── model/                          # JPA entities\n│   │   ├── User.java                   # User entity\n│   │   ├── Blog.java                   # Blog entity\n│   │   ├── Image.java                  # Image entity\n│   │   └── AppRole.java                # Role enum\n│   ├── payload/                        # DTOs\n│   ├── repositories/                   # Data access layer\n│   ├── security/                       # Security configuration\n│   │   ├── jwt/                        # JWT utilities\n│   │   ├── request/                    # Request DTOs\n│   │   ├── response/                   # Response DTOs\n│   │   ├── services/                   # User details services\n│   │   └── WebSecurityConfig.java      # Security config\n│   ├── service/                        # Business logic\n│   └── util/                           # Utility classes\n├── src/main/resources/\n│   ├── application.properties          # Configuration\n│   └── static/                         # Static resources\n├── src/test/                           # Test classes\n├── uploads/images/                     # Image storage (create manually)\n├── pom.xml                            # Maven configuration\n└── README.md                          # This file\n```\n\n## 🧪 Testing\n\n### Run Tests\n```bash\n./mvnw test\n```\n\n### API Testing\nUse tools like Postman, Insomnia, or curl to test endpoints. Import the following collection structure:\n\n1. **Authentication Flow**\n   - Register admin → Login → Get JWT token\n   - Create users → Test role-based access\n\n2. **Blog Management**\n   - Create blog → Upload images → Update content → Delete\n\n## 🚀 Deployment\n\n### Production Checklist\n- [ ] Update database credentials\n- [ ] Configure JWT secret key\n- [ ] Set up file storage permissions\n- [ ] Configure CORS for frontend domain\n- [ ] Set up reverse proxy (nginx/apache)\n- [ ] Configure SSL certificates\n- [ ] Set up log rotation\n- [ ] Configure backup strategy\n\n### Docker Support (Future Enhancement)\n```dockerfile\nFROM openjdk:17-jdk-slim\nCOPY target/*.jar app.jar\nEXPOSE 8080\nENTRYPOINT [\"java\",\"-jar\",\"/app.jar\"]\n```\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit changes (`git commit -m 'Add amazing feature'`)\n4. Push to branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n### Development Guidelines\n- Follow Java naming conventions\n- Add unit tests for new features\n- Update documentation\n- Ensure all tests pass\n- Use meaningful commit messages\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 📞 Support\n\nFor support, contact Prince Pal or create an issue in the repository.\n\n## 👨‍💻 Author\n\n**Prince Pal** - Project Creator \u0026 Developer\n\n## 🙏 Acknowledgments\n\n- Spring Boot team for the excellent framework\n- JWT.io for JWT implementation guidance\n- MySQL team for the database\n- All contributors and the open-source community\n\n---\n\n**Happy Blogging! 🎉**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprincepal-dev%2Fylca-blogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprincepal-dev%2Fylca-blogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprincepal-dev%2Fylca-blogger/lists"}