File Structure
The design of Chipledgers code is meant to be clean and understandable. Here is how it is layed out.
Table of Contents
Overview
Here are most of the directories in the Chipledger source code.
Directory | Definition |
/database/ | Holds the SQLite database file. |
/lib/ | Holds a majority of the code. |
/lib/bootstrap/ | Bootstrap source code. |
/lib/bootswatch-5/ | Customized version of Bootstrap from Bootswatch. |
/lib/chipledger/ | Chipledger's source code. |
/lib/chipledger/api/ | Chipledger's API source code. |
/lib/chipledger/css/ | Chipledgers custom CSS. Only Minor tweaks in here. |
/lib/chipledger/fonts/ | Fonts used by Bootswatch. I dont like using google fonts so they are here locally. |
/lib/chipledger/img/ | Images and Logos used in Chipledger |
/lib/chipledger/js/ | Where all of the JS is stored. |
/lib/chipledger/php/ | Occasional PHP scripts that are needed. (NOT THE API) |
/lib/chipledger/static/ | Where all static content is stored. |
The goal of this is simple: all code behind this project are put in subdirectories inside of the /lib/
folder, all with the name of the project they originated from.
All of bootstrap is in /lib/bootstrap/
, likewise with /lib/chipledger/
.
Root Directory
The root directory is where the webserver is started.
.htaccess
handles the stage #1 routing. Sends all traffic to index.php
index.php
decides if it is for static content or the actual app.
If it is the app, it then again routes all traffic to app.php
.
app.php
has an application skeleton, and chooses + includes the javascript for the user.
It is determined by if the user is logged in.
Lib Directory
As explained earlier, the lib directory stores different parts of the project. Each component is compartmentalized into its own folder.
API
The API folder contains all endpoints.
These are routed to from the /index.php
file.
Feel free to read more about the API Documentation.
JS
This folder contains all the frontend JS used by Chipledger.
Feel free to read more about the Javascript and Rendering.
Static
The static directory has all the content not on the main site. This includes the docs, blog, policy, and donate screen.
These all function differently than the original site.
Each HTML file is just the main content, included between the top.php
and bottom.php
files.
They also all contain a 404.html
, which is displayed if a user navigates further into the url.
Say the user goes to /donate/test
, it would then show the 404.html
.
All routing (and construction) to these pages is done within /index.php
.
Database
The /database/
folder only contains 2 files: .htaccess
and database.db
.
.htaccess
prevents all public traffic to the file.
database.db
is the SQLite database file.
Feel free to read more about the Database.