Skip to content

cloud-blitz/EasyCRUD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EasyCRUD - Student Registration System

A full-stack web application for student registration with a React frontend and Spring Boot backend.

πŸš€ Current Status

The application is currently configured to run without database dependencies for easy development and testing. All data is stored in memory and will be reset when the application restarts.

πŸ“ Project Structure

EasyCRUD/
β”œβ”€β”€ backend/                    # Spring Boot Backend
β”‚   β”œβ”€β”€ src/main/java/
β”‚   β”‚   └── com/student/registration/
β”‚   β”‚       └── student_registration_backend/
β”‚   β”‚           β”œβ”€β”€ controller/     # REST Controllers
β”‚   β”‚           β”œβ”€β”€ model/          # Data Models
β”‚   β”‚           └── config/         # Configuration
β”‚   β”œβ”€β”€ src/main/resources/
β”‚   β”‚   └── application.properties  # App Configuration
β”‚   β”œβ”€β”€ database_schema.sql         # Complete Database Schema
β”‚   β”œβ”€β”€ simple_schema.sql           # Minimal Database Schema
β”‚   β”œβ”€β”€ DATABASE_SETUP.md           # Database Setup Guide
β”‚   └── pom.xml                     # Maven Dependencies
└── frontend/                   # React Frontend
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ components/         # React Components
    β”‚   β”œβ”€β”€ api/               # API Service
    β”‚   └── hooks/             # Custom Hooks
    └── package.json           # Node Dependencies

πŸ› οΈ Quick Start

Prerequisites

  • Java 17 or higher
  • Node.js 16 or higher
  • Maven (or use the included Maven wrapper)

Backend Setup

  1. Navigate to backend directory:

    cd backend
  2. Build the application:

    # Make Maven wrapper executable (first time only)
    chmod +x mvnw
    
    # Build the project
    ./mvnw clean package
  3. Run the application:

    # Using Maven
    ./mvnw spring-boot:run
    
    # Or using the JAR file
    java -jar target/student-registration-backend-0.0.1-SNAPSHOT.jar

The backend will start on http://localhost:8080

Frontend Setup

  1. Navigate to frontend directory:

    cd frontend
  2. Install dependencies:

    npm install
  3. Start the development server:

    npm run dev

The frontend will start on http://localhost:5173

πŸ“Š API Endpoints

Student Registration API

Method Endpoint Description
POST /api/register Register a new student
GET /api/users Get all students
DELETE /api/users/{id} Delete a student by ID

Sample API Usage

# Register a new student
curl -X POST http://localhost:8080/api/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "john@example.com",
    "course": "Computer Science",
    "studentClass": "Final Year",
    "percentage": 85.5,
    "branch": "Computer Engineering",
    "mobileNumber": "+1234567890"
  }'

# Get all students
curl http://localhost:8080/api/users

# Delete a student
curl -X DELETE http://localhost:8080/api/users/1

πŸ—„οΈ Database Integration (Optional)

Current State

  • βœ… No database dependencies - Application runs independently
  • βœ… In-memory storage - Data persists during runtime
  • βœ… Ready for database integration - Schema files provided

Database Schema Files

The project includes comprehensive database schemas:

  1. database_schema.sql - Complete schema with:

    • Users table with all fields
    • Courses and branches tables
    • User roles and permissions
    • Audit logging
    • Sample data (10 students, 6 courses, 5 branches)
  2. simple_schema.sql - Minimal schema with:

    • Basic users table
    • Sample data (5 students)
  3. DATABASE_SETUP.md - Complete setup guide

MariaDB Setup (Ubuntu)

  1. Install MariaDB:

    sudo apt update && sudo apt install mariadb-server -y
  2. Secure the installation:

    sudo mysql_secure_installation
  3. Create database and user:

    sudo mysql -u root -p
    CREATE DATABASE student_db;
    GRANT ALL PRIVILEGES ON student_db.* TO 'username'@'localhost' IDENTIFIED BY 'your_password';
    FLUSH PRIVILEGES;
    EXIT;
  4. Import the schema:

    mysql -u username -p student_db < database_schema.sql

Adding Database Support

When ready to add database support:

  1. Add dependencies to pom.xml:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
        <scope>runtime</scope>
    </dependency>
  2. Update application.properties:

    spring.datasource.url=jdbc:mariadb://localhost:3306/student_db
    spring.datasource.username=your_username
    spring.datasource.password=your_password
    spring.jpa.hibernate.ddl-auto=validate
    spring.jpa.show-sql=true
  3. Restore JPA annotations in User.java:

    @Entity
    @Data
    public class User {
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private Long id;
        // ... other fields
    }
  4. Recreate UserRepository.java:

    @Repository
    public interface UserRepository extends JpaRepository<User, Long> {
    }

πŸ”§ Configuration

Environment Variables

When using database, set these environment variables:

export DB_HOST=localhost
export DB_USER=your_username
export DB_PASS=your_password
export DB_PORT=3306
export DB_NAME=student_db

Application Properties

Key configuration options in application.properties:

# Server Configuration
server.port=8080

# Database Configuration (when enabled)
spring.datasource.url=jdbc:mariadb://localhost:3306/student_db
spring.datasource.username=${DB_USER:root}
spring.datasource.password=${DB_PASS:}
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.show-sql=true

πŸ§ͺ Testing

Backend Testing

cd backend
./mvnw test

API Testing

# Test registration
curl -X POST http://localhost:8080/api/register \
  -H "Content-Type: application/json" \
  -d '{"name":"Test User","email":"test@example.com","course":"CS","studentClass":"First Year","percentage":85.0,"branch":"Computer Engineering","mobileNumber":"+1234567890"}'

# Test retrieval
curl http://localhost:8080/api/users

πŸ“ Features

Current Features

  • βœ… Student registration form
  • βœ… View all registered students
  • βœ… Delete students
  • βœ… Responsive UI design
  • βœ… Form validation
  • βœ… In-memory data storage

Planned Features (with Database)

  • πŸ”„ Persistent data storage
  • πŸ”„ User authentication
  • πŸ”„ Role-based access control
  • πŸ”„ Data export/import
  • πŸ”„ Advanced search and filtering
  • πŸ”„ Audit logging

πŸ› Troubleshooting

Common Issues

  1. Maven build fails:

    • Ensure Java 17+ is installed
    • Check if Maven wrapper is executable: chmod +x mvnw
  2. Port already in use:

    • Change port in application.properties: server.port=8081
  3. Frontend can't connect to backend:

    • Check CORS configuration in WebConfig.java
    • Verify backend is running on correct port
  4. Database connection issues:

    • Verify MariaDB service is running: sudo systemctl status mariadb
    • Check credentials and permissions
    • Ensure database exists: SHOW DATABASES;

πŸ“š Documentation

  • DATABASE_SETUP.md - Complete database setup guide
  • database_schema.sql - Full database schema with sample data
  • simple_schema.sql - Minimal database schema for quick setup

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

πŸ“„ License

This project is open source and available under the MIT License.

πŸ†˜ Support

For issues and questions:

  1. Check the troubleshooting section
  2. Review the database setup guide
  3. Check application logs for error messages
  4. Verify all prerequisites are installed

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •