- Elixir 1.14.3 or later
- Erlang/OTP 25.0 or later
- MySQL 8.0
- Firebase project with Realtime Database
- Git
- Clone and setup the project:
# Clone repository
git clone https://github.com/yourusername/realtime_server.git
cd realtime_server
# Install dependencies
mix deps.get- Configure environment variables:
# Copy example env file
cp .env.example .env
# Edit your .env file with your settings
export FIREBASE_URL="your-firebase-url"
export FIREBASE_PROJECT_ID="your-project-id"
export GUARDIAN_SECRET_KEY="your-secret-key"
export DATABASE_USERNAME="your-db-username"
export DATABASE_PASSWORD="your-db-password"
export DATABASE_HOST="localhost"- Setup the database:
mix ecto.create
mix ecto.migrate- Install development tools:
# Install pre-commit hooks
chmod +x scripts/pre-commit.sh
ln -s ../../scripts/pre-commit.sh .git/hooks/pre-commitWe follow Elixir's standard code style with some additional rules:
# Good
def some_function(arg1, arg2) do
case process_args(arg1, arg2) do
{:ok, result} -> {:ok, result}
{:error, reason} -> {:error, reason}
end
end
# Bad
def some_function arg1,arg2 do
case process_args arg1,arg2 do
{:ok,result}->{:ok,result}
{:error,reason}->{:error,reason}
end
endmain- Production-ready codedevelop- Integration branchfeature/*- New featuresfix/*- Bug fixesrelease/*- Release preparation
Follow conventional commits:
feat: add user presence tracking
fix: handle disconnected socket
docs: update API documentation
test: add channel tests
refactor: improve firebase sync- Create feature branch
- Write tests
- Update documentation
- Submit PR
- Address review comments
- Merge after approval
# Run all tests
mix test
# Run specific test file
mix test test/realtime_server/firebase_test.exs
# Run tests with coverage
mix coveralls.html
# Run continuous testing
mix test.watch# Run all quality checks
mix test.all
# Format code
mix format
# Run Credo
mix credo --strict
# Run Dialyzer
mix dialyzerdef some_function do
require IEx; IEx.pry
# code to debug
endrequire Logger
Logger.debug("Debug message")
Logger.info("Info message")
Logger.warn("Warning message")
Logger.error("Error message")# Use Ecto.Repo.explain
Repo.explain(:all, query)
# Use async tasks for background operations
Task.async(fn ->
# Background work
end)- Monitor connection count
- Implement rate limiting
- Use presence for tracking
-
Install extensions:
- ElixirLS
- Phoenix Framework
- GitLens
-
Configure settings.json:
{
"elixir.enableTestLenses": true,
"elixir.credo.strictMode": true,
"editor.formatOnSave": true,
"editor.rulers": [120],
"[elixir]": {
"editor.defaultFormatter": "JakeBecker.elixir-ls"
}
}