Directory Structure

Directory Structure #

Full directory structure of a gFly project.

.
|-- app
|   |-- console
|   |   |-- commands
|   |   |-- queues
|   |   `-- schedules
|   |-- constants
|   |-- core
|   |-- domain
|   |   |-- models
|   |   `-- repository
|   |-- dto
|   |-- errors
|   |-- http
|   |   |-- controllers
|   |   |   |-- api
|   |   |   `-- page
|   |   |-- middleware
|   |   |-- request
|   |   |-- response
|   |   |-- routes
|   |   |-- transformers
|   |   `-- validations
|   |-- notifications
|   |-- services
|   `-- utils
|-- build
|-- core
|   |-- console
|   |-- db
|   |-- errors
|   |-- filesystem
|   |-- fluentsql
|   |   |-- builder
|   |   `-- data
|   |-- gfly
|   |-- log
|   |-- mail
|   |-- middleware
|   |-- notification
|   |   `-- slack
|   |-- oauth
|   |   |-- gothic
|   |   `-- providers
|   |       |-- facebook
|   |       |-- github
|   |       `-- google
|   |-- session
|   |   `-- providers
|   |       |-- memory
|   |       `-- redis
|   |-- utils
|   `-- validation
|-- database
|   `-- migrations
|       |-- mysql
|       `-- postgresql
|-- docker
|   `-- rootfs
|       |-- etc
|       |   `-- cont-init.d
|       |-- home
|       |   `-- gfly
|       `-- root
|-- docs
|-- public
|   |-- assets
|   |-- css
|   |-- docs
|   |-- js
|   `-- vendors
|       `-- alpinejs
|           `-- dist
|-- resources
|   |-- app
|   |-- tls
|   `-- views
|-- storage
|   |-- app
|   |   `-- public
|   |       `-- upload
|   |-- logs
|   `-- tmp
|-- test
`-- tmp

The app directory #

This is the main directory for the project. This is where files will be created and used throughout your project.

Understanding and placing source files in the correct folders will help us easily understand and manage them effectively. In fact, how to place it is not a mandatory issue. However, unity is needed to create consistency in your project. And this is how gFly is approaching. In addition, the components in the code also have certain close relationships to create logic and ease of understanding. We will clarify in the step “Understanding the lifecycle of a request in gFly”

.
|-- app
|   |-- console
|   |   |-- commands
|   |   |-- queues
|   |   `-- schedules
|   |-- constants
|   |-- core
|   |-- domain
|   |   |-- models
|   |   `-- repository
|   |-- dto
|   |-- errors
|   |-- http
|   |   |-- controllers
|   |   |   |-- api
|   |   |   `-- page
|   |   |-- middleware
|   |   |-- request
|   |   |-- response
|   |   |-- routes
|   |   |-- transformers
|   |   `-- validations
|   |-- notifications
|   |-- services
|   `-- utils

Requests can be created from many different places. It can be from the command line (console) or from an HTTP web service. And the programming code will be located in two directories, app/console and app/http respectively. The codes in those two folders will receive external requests for your application. Then there will be a need for app/services related processing called business logic.

Business logic is where almost all the main processing is held. And of course it needs to connect and use components like domains in the app/domain/*, app/utils, etc.

Some another directory app/constants to store all constants, app/dto to store all DTO, app/errors to store error type, error handling, app/notifications to store notification types, app/utils is common utils.

The build directory #

|-- build

Once you run make release (Local setup). It will make many execute files for Mac, Linux, Windows to folder build.

The core directory #

|-- core
|   |-- console
|   |-- db
|   |-- errors
|   |-- filesystem
|   |-- fluentsql
|   |   |-- builder
|   |   `-- data
|   |-- gfly
|   |-- log
|   |-- mail
|   |-- middleware
|   |-- notification
|   |   `-- slack
|   |-- oauth
|   |   |-- gothic
|   |   `-- providers
|   |       |-- facebook
|   |       |-- github
|   |       `-- google
|   |-- session
|   |   `-- providers
|   |       |-- memory
|   |       `-- redis
|   |-- utils
|   `-- validation

The directory contains all the gFly framework. You can change anything you want such as modifications, developing new functions,…

The database directory #

|-- database
|   `-- migrations
|       |-- mysql
|       `-- postgresql

Store things related to the database such as DB schema, DB migration,… Save changes and project DB design

The docker directory #

|-- docker
|   `-- rootfs
|       |-- etc
|       |   `-- cont-init.d
|       |-- home
|       |   `-- gfly
|       `-- root

Provides the necessary source code to help you deploy your application using Docker during development.

The docs directory #

|-- docs

If you write API doc with Swagger, this is where the document generated from your code will be stored. However, you can also archive project documentation if you want.

The public directory #

|-- public
|   |-- assets
|   |-- css
|   |-- docs
|   `-- js

Source code related to Frontend such as js, css, assets, html files will all be contained here.

TIP
If you develop Frontend with technologies like ReactJS, VueJS or AnguarJS,… you should specify the build directory to public.

The resources directory #

|-- resources
|   |-- app
|   |-- tls
|   `-- views

The directory contains resources related to the application. Currently there are 3 categories:

  • The app directory contains application resources.
  • The tls directory contains SSL certificates.
  • The views folder contains files for the view template engine.

The storage directory #

|-- storage
|   |-- app
|   |   `-- public
|   |       `-- upload
|   |-- logs
|   `-- tmp

The process of running the application will need a place to store it for many different purposes. This is the place to store files generated during the application process such as uploading files. Or is it a place to temporarily change resources, or store logs, etc.

  • The app directory contains application resources.
  • The logs directory contains log files.
  • The tmp is temporary folder.

The test & tmp directories #

|-- test
`-- tmp

During application development, we also need a place to test and temporarily store tmp