The Codex Framework is a comprehensive Java framework designed to streamline application development by offering robust dependency injection, custom ORM, data mapping, and automated database schema generation. It integrates annotation-based configuration to simplify entity management and dependency handling.
- Dependency Injection: Streamline object creation and dependency management.
- Custom ORM: Simplify database interactions with an intuitive ORM.
- Data Mapping: Effortlessly map database tables to Java objects.
- Automated Table Creation: Automatically generate database tables from your Java classes.
- Annotation-Based Configuration: Configure your entities and dependencies using annotations for cleaner and more maintainable code.
-
Clone the repository:
git clone [email protected]:bouanani-soufiane/Codex-Framework.git
-
Navigate to the project directory:
cd Codex-Framework
-
Install the framework to your local Maven repository:
mvn clean install
-
Add the following dependency to your project's
pom.xml
:<dependency> <groupId>com.codex</groupId> <artifactId>Codex</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
-
Add .env file with your custom database config
DB_URL=jdbc:postgresql://localhost:5432/yourDataBaseName DB_USERNAME= DB_PASSWORD= DB_DRIVER=org.postgresql.Driver
Create a main class and use the Kernel.run()
method to start your application:
import com.codex.framework.Kernel;
public class Main {
public static void main(String[] args) throws Exception {
Kernel.run(Main.class);
}
}
Use annotations to define and inject dependencies:
package com.codex.testing.Components;
import com.codex.framework.DIContainer.annotations.Autowired;
import com.codex.framework.DIContainer.annotations.Component;
import com.codex.framework.DIContainer.annotations.Qualifier;
import com.codex.testing.Components.interfaces.IBook;
import com.codex.testing.Components.interfaces.IUser;
@Component
public class Book implements IBook {
private IUser user;
@Autowired
@Qualifier(User2.class)
public Book(IUser user) {
this.user = user;
}
@Override
public void index() {
System.out.println(user.getName());
}
}
Define entities using annotations:
package com.codex.testing.entities;
import com.codex.framework.EntityManager.Annotations.Column.Column;
import com.codex.framework.EntityManager.Annotations.Entity.Entity;
import com.codex.framework.EntityManager.Annotations.Entity.Table;
import com.codex.framework.EntityManager.Annotations.Id.ID;
import com.codex.framework.EntityManager.Annotations.Relationship.*;
import java.util.Set;
@Entity
@Table(name = "Administrator")
public class Admin {
@ID
private String id;
@Column
private String name;
@ManyToOne(cascade = "PERSIST")
private Employee employee_id;
@ManyToMany(cascade = "REFRESH")
@JoinTable(
name = "admin_roles",
joinColumns = @JoinColumn(name = "admin_id"),
inverseJoinColumns = @JoinColumn(name = "role_id")
)
private Set<Roles> roles;
}
package com.codex.testing.entities;
import com.codex.framework.EntityManager.Annotations.Column.Column;
import com.codex.framework.EntityManager.Annotations.Entity.Entity;
import com.codex.framework.EntityManager.Annotations.Id.ID;
@Entity
public class Employee {
@ID
private int id;
@Column(name = "em_name")
private String name;
}
package com.codex.testing.entities;
import com.codex.framework.EntityManager.Annotations.Column.Column;
import com.codex.framework.EntityManager.Annotations.Entity.Entity;
import com.codex.framework.EntityManager.Annotations.Id.ID;
@Entity
public class Roles {
@ID
private String id;
@Column
private String name;
}
Entity Manager Process | IOC Context |
---|---|
- Fork the repository and create a new branch.
- Write clear and concise commit messages.
- Ensure all tests pass before submitting a pull request.
- Follow the project's coding standards and guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.