- Customer Accounts Management & Invoicing MVP
- Ruby Version
- Service/Vendor dependencies
- System Dependencies
- Configuration
- Running the app for the first time
- Database management
- How to run the test suite
- Services (job queues, cache servers, search engines, etc.)
- Deployment instructions
- Development
- Integration Partners
- Guides and References
- Future Work
3.2.2
- Ngrok for local development tunneling
System dependencies are defined in the following configuration files:
.tool-versions
(see.tool-versions.example
)Gemfile
Brewfile
package.json
yarn.lock
Service | Port |
---|---|
Rails | 16006 |
Redis | 16079 |
Postgres (app store) | 16032 |
MongoDB (invoicing score) | 16017 |
If you use asdf, you will also need to setup the following plugins and install their corresponding versions with the
asdf install
command:
asdf plugin add ruby
asdf plugin add nodejs
New toasdf
? here's a primer to get started.
Review the .env.example
file to ensure the environment variables are set. You can control which variables are made available in each environment while working locally using the following files:
.env.local
.env.test
The .envrc
(see .envrc.example
) file should be included for compatibility with other features like docker compose
and simply sources the .env.local
file.
# Install system dependencies
brew bundle
# Setup the ASDF dependencies file
cp -v .tool-versions.example .tool-versions
# Install Ruby dependencies
bundle install
# Install Node dependencies
yarn install
Search for development.yml.enc
to locate the entry in the KeePass store
with the application's encrypted secrets files.
Run the following code to update the application for the corresponding environments. You will need to do this before running the test suite.
# Help menu for the secrets command
bin/thor help lx-cli:secrets:edit
# Edit the secrets file (for the development environment)
bin/thor lx-cli:secrets:edit --environment development
bin/start-docker
# Get help with the DB setup command
bin/thor help lx-cli:db:setup
# Initialize the app store database
bin/thor lx-cli:db:setup --postgres
# Initialize the invoicing score database
bin/thor lx-cli:db:setup --mongodb
You can also start up the app's non-dockerized services with the included IDE configurations for RubyMine in the
.ide-configs
folder.
This is the same command you'll need any time you want to start up the application:
bin/dev
Review the list of available rake tasks for managing the MongoDB
database:
bundle exec rake -T | grep mongoid
# Sample output
rake db:mongoid:create_collections # Create collections for Mongoid models
rake db:mongoid:create_collections:force # Drop and create collections for Mongoid models
rake db:mongoid:create_indexes # Create indexes specified in Mongoid models
rake db:mongoid:drop # Drop the database of the default Mongoid client
rake db:mongoid:purge # Drop all non-system collections
rake db:mongoid:remove_indexes # Remove indexes specified in Mongoid models
rake db:mongoid:remove_undefined_indexes # Remove indexes that exist in the database but are not specified in Mongoid models
rake db:mongoid:shard_collections # Shard collections with shard keys specified in Mongoid models
This guide is intended as a temporary solution until we can come up with something better for bringing up the document store with the right set of permissions the first time the application setup is run.
# Show help menu for mongosh
docker exec -it mongodb.accounts.larcity mongosh --help
# Run the command to initialize the database
docker exec -it mongodb.accounts.larcity mongosh \
--authenticationDatabase admin
--file ./development/mongodb/docker-entrypoint-initdb.d/init-doc-stores
--username <MONGO_INITDB_ROOT_USERNAME>
--password <MONGO_INITDB_ROOT_PASSWORD>
# Run the command to connect the mongodb container
bin/thor lx-cli:db:connect --mongodb
Once connected to the database instance, run the following commands to setup test credentials:
// List databases
show dbs
// Use the admin database
use admin
// Create a new user
db.createUser({
user: "db_admin",
pwd: `${process.env.MONGO_INITDB_ROOT_PASSWORD}`,
roles: [
{ role: "dbOwner", db: "doc_store_development" },
{ role: "dbOwner", db: "doc_store_test" },
]
})
use doc_store_test
// Create a new user (for testing purposes)
db.createUser({
user: "db_admin",
pwd: passwordPrompt(),
roles: [
{ role: "dbOwner", db: "doc_store_test" }
]
})
use doc_store_development
// Create a new user (for development purposes)
db.createUser({
user: "db_admin",
pwd: passwordPrompt(),
roles: [
{ role: "dbOwner", db: "doc_store_development" }
]
})
// Example: Grant roles to an existing user
db.grantRolesToUser("db_admin", ["dbOwner"])
TODO: Add test suite instructions
TODO: Add services
TODO: Add deployment instructions
To edit credentials in your IDE, run the following command in your console:
bin/thor lx-cli:secrets:edit
To view help information about managing application credentials, run the following command in your console:
bin/rails credentials:help
To edit the credentials file for your development environment using the rails credentials scripts and your command line, run the following code in your console:
EDITOR=nano bin/rails credentials:edit --environment ${RAILS_ENV:-development}
Follow these steps to setup ngrok
for your local environment:
-
Ensure you have updated your
.envrc
file with theNGROK_AUTH_TOKEN
. You can get this from KeePass -
Run the following script to export the token to your local
ngrok.yml
config file:ngrok config add-authtoken ${NGROK_AUTH_TOKEN}
Then you can open a tunnel to your local environment by running:
thor lx-cli:tunnel:open_all
rails g model Invoice --orm=mongoid
After generating the model, if you would like to inherit application functionality for document records,
you can include the DocumentRecord
concern in the model:
class Invoice
include DocumentRecord
end
bin/thor help lx-cli:secrets:print_key
Go to
Settngs | Editor | Inspections | Ruby | RBS
and uncheckMissing type signature
- MongoDB Tutorial
- Rails API
- Rails Guides
- Introduction to Sidekiq for Rails
- The beginner's guide to magic links
- The complete guide for Deprecation Warnings in Rails
- Devise
- Classic to Zeitwerk HOWTO
- Pre-compiling assets
- Dart Sass for Rails
- Fontawesome Icons
- Pundit
- CanCanCan developer guide - an alternative to
Pundit
- Feature flags for backup providers e.g. with feature flagging payment providers like Stripe, PayPal & SplitIt or auth providers like Apple, Google & native passwordless authentication
- Dynamic roles in a Rails app
- Review Yahoo + Google updated email sender requirements and make any needed changes to the Brevo configs
- Implement forbidden rescue page (or just set a flash message and redirect to the root path)
- "Continue with Google" quick link in the profile dropdown
- Fix web concurrency support (issues here might be related to log streaming). Here's the error message:
objc[97397]: +[NSCharacterSet initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug
- AASM for account status
- Setup and update production credentials in the
config/credentials/production.yml.enc
file - Implement
:confirmable
to secure accounts when switching/adding auth providers - Implement magic links
- Implement Omniauth via apple
- Implement FontAwesome library for SVG icons
- Secure accounts with MFA
- Setup secrets using docker images' compatibility with secret files
- Vite CJS API is deprecated and will be removed in v6. Update the
vite.config.js
file to use the ESM build instead - New ESLint configuration system is available. You will need to create a new
eslint.config.js
file to use the new configuration system - Setup RSwag for baller request specs & API tools
- Setup flipper for feature flags
- Knapsack Pro for parallelizing tests
- Check out Redis Stack for docker for advanced indexing & search features with redis data
- Playwright E2E test suite
- Implement default authorization policies
- Consolidate vite configuration & dependencies right now, vite is a dependency of both the front and backend separately. Is there a better way?