Introduction
This page will guide you on how to set up Fluxend locally. We assume you’re interested in modifying functionality or fixing bugs in either the Frontend or the Backend parts of the application. If you follow to end, you’ll fully understand how to make changes in either part.Prerequisites
Before installing Fluxend, ensure you have the following tools installed and available via your command line interface:- Docker: Container platform for running applications
- Docker Compose: Tool for defining multi-container applications
- Make: Build automation tool for making your life easier
- Git: Version control system
- Golang:
^1.23.xinstalled and accessible by runninggo version - Node:
^20.16.xinstalled and accessible by runningnode --version - Yarn: Build tool responsible for frontend app
- Goose: Database migration tool, must be accessible at
goose version
docker --version, docker-compose --version, make --version, and git --version in your terminal.
Setup
Once you have all requirements satisfied, follow the Quickstart guide for initial setup. The basic installation process. The next steps will be different. If you’re only interested inbackend, you can ignore frontend and vice versa.
Please ensure to set
URL_SCEHEME to http to avoid SSL issues when running application locallyBackend
Our backend app runs a compiled binary insidefluxend_api container. If you’re interested in changing/developing a feature in this area, you should run this without a container to see realtime changes without having to re-compile each time. You can following command inside
fluxend directory to initiate a real-time Golang Echo server
ENV for frontend app by modifiying web/.env file and point it to http://api.localhost:8080/
Frontend
Our frontend app runs on React and using containerfluxend_frontend In order to see changes realtime, you should first install dependencies by running:
Architecture
This section dives deep into architecture. It will give you an overview of directory structure, design principals, and other related topics.File structure
Clean Architecture Foundation
Our BaaS follows Uncle Bob’s Clean Architecture principles with four distinct layers:- Domain Layer (innermost) - Pure business logic, no external dependencies
- Application Layer - Use cases and application services
- Infrastructure Layer - External concerns (database, web, file system)
- Interface Layer - Controllers, presenters, and gateways
Dependency Rule
Source code dependencies must point only toward higher-level policies:- Domain layer has no dependencies on other layers
- Application layer depends only on domain
- Infrastructure layer depends on application and domain
- Interface layer depends on all inner layers
Debugging
You can usepkg.DumpJSON to print debug info when dealing with go related issues. We also use Zerolog so you can use it for printing information. Also, try looking into other files under pkg directory.
When it comes to frontend, console.log is your friend.
We’ll be updating this section with more helpful resources.
Go Conventions
When writing code, please ensure to follow best practices and write consistent code.Naming Conventions
- Variables & Functions: Use
camelCasefor all variables, functions, and methods - Constants: Use
PascalCasefor constants - Types & Structs: Use
PascalCasefor exported types,camelCasefor unexported - Interfaces: Use
PascalCasewith descriptive names (e.g.,UserRepository,EmailSender)
- File Names: Use
snake_casefor all Go files - Test Files: Append
_test.goto the corresponding file name
Database Management
- Always Close Connections: Database connections must be closed properly
- Use defer: Close connections immediately after opening
- Context Handling: Use context for timeout management
- Error Handling: Always check connection errors
Error Handling
- Same-Line if Statements: Use inline error checking for cleaner code
- Wrap Errors: Use
fmt.Errorfwith%wverb for error wrapping - Early Returns: Return errors early to reduce nesting