yakupbeyoglu / ForgeAPI

ForgeAPI is a powerful and automated C++ tool(compiler) designed to streamline the process of building RESTful APIs from structured JSON inputs.
MIT License
2 stars 0 forks source link

Requirements #1

Open yakupbeyoglu opened 1 month ago

yakupbeyoglu commented 1 month ago

We need to develop a compiler that converts a JSON schema into PHP Laravel code. This project is essential for automating the generation of Laravel applications based on JSON specifications, which will streamline development, reduce errors, and ensure consistency across projects.

Why This Project is Needed:

Tasks:

  1. Lexical Analysis

    • Task: Tokenize the JSON input to break it down into meaningful components.
    • Objective: Ensure that the JSON data is accurately read and prepared for further analysis.
  2. Syntax Analysis

    • Task: Validate the JSON structure and build a parse tree.
    • Objective: Confirm that the JSON adheres to expected syntax and structure, enabling correct processing.
  3. Semantic Analysis

    • Task: Validate the semantics of the JSON data, checking for correctness and completeness.
    • Objective: Ensure that the JSON definitions are meaningful and consistent, such as valid field types and relationships.
  4. Define Components

    • Task: Identify and categorize components including migrations, models, controllers, routes, middleware, and authorization groups.
    • Objective: Establish a clear understanding of what code needs to be generated.
  5. Define Dependencies

    • Task: Determine dependencies among components and how they interact.
    • Objective: Establish the order of processing to ensure that components are generated correctly.
  6. Build Dependency Graph

    • Task: Create a directed acyclic graph (DAG) to represent dependencies between components.
    • Objective: Visualize and manage dependencies to facilitate correct code generation order.
  7. Topological Sorting

    • Task: Perform topological sorting on the dependency graph to determine processing order.
    • Objective: Ensure that components are processed in the correct order based on their dependencies. The dependencies referred based on the database relation.
  8. Code Generation

    • Task: Generate PHP Laravel code files based on the sorted order of components.
    • Objective: Create migration files, model files, controller files, route definitions, and middleware applications.
  9. Handle Circular Dependencies

    • Task: Detect and resolve circular dependencies in the dependency graph. If there is circular dependency it should throw compile issue.
    • Objective: Avoid issues caused by circular dependencies and ensure a valid build order.
  10. Validate Code Generation

    • Task: Ensure that all generated code files are correct and adhere to Laravel conventions.
    • Objective: Verify the accuracy and functionality of the generated code.
  11. Error Handling

    • Task: Implement mechanisms for handling errors related to code generation and dependencies.
    • Objective: Manage and resolve issues that arise during the compilation process.
  12. Test Dependency Analyzer

    • Task: Write and execute tests to validate the dependency analyzer's accuracy.
    • Objective: Ensure that the dependency resolution process works correctly.
  13. Documentation

    • Task: Document the compiler process, including how to use it and troubleshoot issues.
    • Objective: Provide clear guidance for users and developers on the compiler's functionality and usage.
  14. Integration with Compiler

    • Task: Integrate the dependency analyzer and code generation with the overall compiler system.
    • Objective: Ensure seamless operation of the compiler components.
  15. Optimization

    • Task: Optimize the generated code and compiler performance.
    • Objective: Enhance the efficiency of both the generated PHP code and the compiler itself.

Expected Outcomes: