Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Yurben-bit/Sistema-de-Administraci-n-Escolar-Backend/llms.txt

Use this file to discover all available pages before exploring further.

Prerequisites

Before you begin, ensure you have the following installed on your system:

Java 8+

JDK 8 or higher required

Maven 3.x

For dependency management

MySQL 8.0+

Database server running
You’ll also need Git to clone the repository.

Quick Installation

1

Clone the Repository

Clone the EduTec Backend repository to your local machine:
git clone <repository-url>
cd edutec-backend
2

Set Up MySQL Database

Create a new MySQL database for the application:
CREATE DATABASE edutec_db;
CREATE USER 'edutec_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON edutec_db.* TO 'edutec_user'@'localhost';
FLUSH PRIVILEGES;
Make sure to replace your_password with a secure password of your choice.
3

Configure Database Connection

Update the src/main/resources/application.properties file with your database credentials:
spring.application.name=edutec

# Database Configuration
spring.datasource.url=jdbc:mysql://localhost:3306/edutec_db
spring.datasource.username=edutec_user
spring.datasource.password=your_password
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

# JPA Configuration
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect

# Server Configuration
server.port=8080
4

Install Dependencies

Use Maven to download all required dependencies:
./mvnw clean install
The Maven wrapper (./mvnw) is included in the project and doesn’t require Maven to be installed globally.
5

Run the Application

Start the Spring Boot application:
./mvnw spring-boot:run
The application will start on http://localhost:8080You should see output similar to:
Started EdutecApplication in X.XXX seconds

Verify Installation

Once the application is running, verify that everything is working correctly.

Check Application Health

Test the application by making a request to the login endpoint:
curl -X POST http://localhost:8080/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "username": "testuser",
    "password": "testpass"
  }'
Since this is a development build without full authentication validation, the endpoint will generate a JWT token for any username provided.

Expected Response

You should receive a JWT token response:
eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0dXNlciIsImlhdCI6MTY4MDE1MzYwMCwiZXhwIjoxNjgwMTg5NjAwfQ.xxxxxxxxxxxxxxxxxxxxx
This token is valid for 10 hours and can be used for authenticated requests (once authentication middleware is implemented).

Understanding the Code

Now that you have the application running, let’s understand the key components:

Main Application Class

The entry point of the application is defined in EdutecApplication.java:
src/main/java/com/tecmilenio/edutec/EdutecApplication.java
package com.tecmilenio.edutec;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class EdutecApplication {

	public static void main(String[] args) {
		SpringApplication.run(EdutecApplication.class, args);
	}

}

Authentication Controller

The AuthController handles login requests at /auth/login:
src/main/java/com/tecmilenio/edutec/controller/AuthController.java
@RestController
@RequestMapping("/auth")
public class AuthController {
    @Autowired
    private JwtService jwtService;

    @PostMapping("/login")
    public String login(@RequestBody LoginRequest loginRequest) {
        System.out.println("El usuario " + loginRequest.getUsername() + " está intentando entrar");
        return jwtService.generateToken(loginRequest.getUsername());
    }
}

JWT Service

The JwtService generates secure JWT tokens for authenticated users:
src/main/java/com/tecmilenio/edutec/security/JwtService.java
@Service
public class JwtService {
    private static final String SECRET_KEY = "12345678910111213141516171819200";
    private static final Key KEY = Keys.hmacShaKeyFor(SECRET_KEY.getBytes());

    public String generateToken(String username) {
        return Jwts.builder()
                .setSubject(username)
                .setIssuedAt(new Date(System.currentTimeMillis()))
                .setExpiration(new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 10))
                .signWith(KEY, SignatureAlgorithm.HS256)
                .compact();
    }
}
The current JWT secret key is hardcoded for development purposes. In production, this should be moved to environment variables or a secure configuration service.

User Model

The User entity represents users in the database:
src/main/java/com/tecmilenio/edutec/model/User.java
@Entity
@Table(name = "usuarios")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class User {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false, unique = true)
    private String username;

    @Column(nullable = false)
    private String password;
}

Login Request DTO

The LoginRequest DTO handles incoming login data:
src/main/java/com/tecmilenio/edutec/dto/LoginRequest.java
public class LoginRequest {
    private String username;
    private String password;

    public LoginRequest() {}

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}

Development Workflow

Running in Development Mode

Spring Boot DevTools is included in the project, enabling automatic restart when code changes:
./mvnw spring-boot:run
Any changes to Java files will trigger an automatic application restart.

Database Schema Management

The application uses JPA’s ddl-auto=update setting, which automatically creates and updates database tables based on your entity classes.
For production deployments, consider using a migration tool like Flyway or Liquibase instead of automatic schema generation.

Common Issues

Ensure MySQL is running and accessible:
sudo systemctl status mysql
Check that the port 3306 is not blocked by a firewall.
Change the server port in application.properties:
server.port=8081
Clear the Maven cache and rebuild:
./mvnw clean install -U

Next Steps

Now that you have EduTec Backend running locally, you can:

Need Help?

If you encounter any issues, please open an issue on GitHub.

Build docs developers (and LLMs) love