Giter Site home page Giter Site logo

wnederhof / basecode Goto Github PK

View Code? Open in Web Editor NEW
18.0 1.0 0.0 6.71 MB

๐Ÿš€ Full-stack scaffolding tool for Java/Kotlin + React apps.

License: MIT License

JavaScript 2.77% Go 81.33% Java 15.09% Shell 0.80%
spring-boot typescript graphql react kotlin java

basecode's Introduction

Welcome to Basecode!

We are very excited to have you here!

Basecode is a full-stack scaffolding tool for Java/Kotlin + React applications. The platform consists of several generators to generate the basic structure of your web application.

The goal of Basecode is to minimize the time spent on bootstrapping a new project and maximize the time spent on delivering business value.

Basecode / the code generated by Basecode is:

  • Productive, as it allows you to generate authentication and CRUD functionality with 1-N relations, including migrations, GraphQL schema files, unit tests and integration tests.
  • Maintainable, as it provides a package-by-feature structuring approach, GraphQL communication and domain events between different aggregates, so you get a highly decoupled and extensible architecture.
  • Incremental, as it allows you to start with almost no code. Then, once you're ready for the next step, add scaffolds, authentication, a frontend and more at your own pace.

Basecode generates code consisting of:

  • Java / Kotlin + Spring Boot
  • GraphQL schema files + DB migrations
  • Typescript + React (through Next.js)

Finally, Basecode is open source (MIT).

โญ If you like Basecode, please consider giving it a star. Your support can help the project grow and deliver exciting features.

Installation

In order to use Basecode, make sure you have the following software installed:

  • Go 1.16 or later
  • JDK 21 or later
  • Node 18 or later
  • Docker

You can install Basecode using the following command:

go install github.com/wnederhof/basecode/cmd/basecode@latest

Usage

For each of the following commands (except for new), you can use -o to allow overwriting existing files and -d to delete the specified set of files. Note that the flags go after generate.

For example: basecode generate -o scaffold Post title contents:string

Create a New Project

To create a new project, simply type:

basecode new <groupId> <artifactId>

Here, groupId and artifactId are the name of the group and artifact respectively, as defined by Maven.

For example:

basecode new com.example blog

By default, this will create a Kotlin + React project. However, Basecode can generate Java code by specifying --backend java. For example:

basecode new --backend java com.example blog

Scaffold Generation

Using basecode generate, you can generate code based using one of the following generators.

   backend:scaffold, bes   Backend Scaffold
   backend:model, bem      Model files, including migration script, entity and repository
   backend:api, bea        GraphQL API (schema and resolvers)
   backend:service, bsv    Service between API and repository
   frontend, fe            Frontend Support
   frontend:scaffold, fes  Frontend Scaffold (Generate frontend support first)
   scaffold, s             Backend and Frontend Scaffold (Generate frontend support first)
   backend:auth, ba        Backend Authentication
   frontend:auth, fa       Frontend Authentication
   auth, a                 Authentication

For more information about the generators, run:

basecode generate <generator name> -h

For example:

basecode generate scaffold -h

In most cases, you will want to use scaffold. This generator takes a model name and a list of field names and types and will generate backend and frontend code for the model you specified. For example:

basecode generate scaffold Post title:string description:text

Available types:

  • string
  • int
  • text
  • date
  • datetime
  • boolean

Starting the program

In order to start your newly generated program, you need to:

  • Run docker-compose up in the <artifactId>-server directory to start up a local database
  • Run ./mvnw spring-boot:run in the <artifactId>-server server to start the backend (or launch the Application in your IDE)
  • Run npm install in the <artifactId>-web directory to install the frontend dependencies
  • Run npm dev in the <artifactId>-web directory to start the frontend development server

Tips

  • If you want to update an existing scaffolding, make start with an empty commit. This way, you can easily see overwrite existing code using the -o (overwrite) flag and use the Git diff to determine what code you want to keep and what code you want to overwrite.

Resources

Credits

basecode's People

Contributors

wnederhof avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

basecode's Issues

Stronger separation between FE/BE

Currently, the BE and FE have a root in the same folder, which is great for a monolith setup with Nuxt.js. However, it may be better to separate BE and FE more strongly, as this would make the project more flexible, because it would also allow for building microservices, utilize microfrontends, use projects such as NX, allow for CrudCodeGen to support Next.js and other generators, and more. The only downside is that, for a monolith, the code is less cohesive, because the frontend and backend parts of the projects are further away. In this case, I believe that the upsides outweigh the downsides.

Finally, this structure also allows one to create a separate BE+FE application per bounded context, and tie them all together using something like NX (in the case of a monorepo).

The proposal is to have a structure as following:

  • petstore
    • server
      • src
      • pom.xml
      • ...
    • web
      • src
      • package.json
      • ...
    • client
      • _root.graphqls
      • ...

So why not backend, frontend but server and web? Because this allows us to add mobile in the future as well ๐Ÿ˜‹

CI/CD Pipeline

The CI/CD pipeline has not yet been set up for CrudCodeGen. As such, currently, the only way to use the project is by compiling it by source.

Add authentication

Having authentication features built-in will save a lot of time when developing a new application, and will be needed in ~90% of all applications. So basic scaffolding features for this application would definitely make sense.

Slow startup time

The project starts up a bit too slow. This is caused by the use of Spring Boot on a CLI application, which may make the project a bit heavy. The proposed fix is to use GraalVM, which is slowly getting more and more supported by the Spring team. In the CI/CD pipeline, we can set up a multiarch release pipeline to ensure that users of this project can easily download a binary.

Wrong dir names

In the Go rewrite, java directories have actual dots instead of slashes.

Cloud Native

To make CrudCodeGen useful within a cloud environment, we should support GraalVM to build native images, as the memory usage and the startup performance are much better.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.