Skip to content

Instantly share code, notes, and snippets.

@shanna
Created August 2, 2011 09:24
Show Gist options
  • Save shanna/1119879 to your computer and use it in GitHub Desktop.
Save shanna/1119879 to your computer and use it in GitHub Desktop.
Basic application structure.
/
/bin
#{project}
#{project}-cli
#{project}-db
#{project}-job
#{project}-web
#{project}-config
...
* We stole the CLI command hierarchy from git. E.g. ./bin/project web (start|stop|status) [options]
* Mixture of shell, ruby scripts or whatever you want.
* The entire application is controlled via the project bin.
/config
* Usual junk. unicorn, rack etc setup code.
/cron
* Crontabs to call project bin commands.
/lib
/#{project}
* Domain models go straight in the projects root at the moment though we've been debating this.
* As many levels deep as is required.
/cli
* CLI setup code. Grunt work in models.
/job
* Resque.
* Queue worker setup code. Grunt work in models.
/scheme
* Swift.
* Persistence layer. Documents, Records, Schema whatever you want to call them.
* Operated on, created etc by domain models.
/web
* Sinatra.
* We use a Rack::URLMap style extension for Sinatra to break up our app into 'controllers'.
class Project::Web::Server < Project::Web
map '/admin', Project::Web::Admin
end
/migrations
* With execution bit we execute them then wrap the resulting SQL in a transaction.
* Without execution bit we treat it as an sql file.
/public
/art
/javascript
/views
/web
/css
* .scss (Compass)
== Notes
* We don't use Rails, we stopped way back when Merb was a thing and now we use Sinatra with a couple extensions and patches Konstantin Haase stubbornly refuse to accept (yes I'm calling him out, the routing could be less confusing).
* The web interface is a small part of most applications. Don't let poor framework defaults dictate your application structure.
* Classes/Modules hierarchy always matches directory structure and file names 1:1. We are all old Perl programmers where this is the norm and because guessing games suck.
* Extensions and libraries that haven't been turned into their own gems live under lib/* along with (but outside) the project lib lib/#{project}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment