Skip to content
Shop

CommunityJoin Our PatreonDonate

Sponsored Ads

Sponsored Ads

Learning a Codebase

Coming Soon!

For this lesson, we will refer to a large codebase on github for an application I really like called Excalidraw. I've never looked the codebase for this application, so we will be learning it together.

Reading Code

Start with the big stuff, end with the little stuff.

  • languages and frameworks

  • System design

  • libraries/packages/models (code that may not be in the codebase). Get an idea of what is used to make the app.

    • python- equirements.txt
    • nodejs - package.json
    • rails - Gemfile
    • if you can't find this type of file, look at all imports (require)
    • .env
  • database

    • Could be a file or
  • Classes & Methods

    • Superclasses as well, module class or custom class?
    • This app uses functional programming. Very few classes
  • functions

    • packages/excalidraw/fonts/index.ts
      • register()
  • variables, conditions

  • config, .env

  • scripts

  • cron jobs

  • Write your own business rules from what you learn.

  • important folders

    • packages/escalidraw

Here are some questions we should answer:

Backend:

  • Libraries - Other services or features not explorable in the codebase (have to go to another codebase)
  • Where is the Database to get the schema
  • Variables - container to store data
  • Functions - What is happening to the data
  • Classes - Logical groups of related code
  • Conditions - When code is triggered
  • frontend/backend

Packages

husky - https://github.com/typicode/husky jsdom - https://github.com/jsdom/jsdom pepjs - https://www.npmjs.com/package/pepjshttps://www.npmjs.com/package/rewire vite react

For Web apps:

  • Schema - all of the data
  • Routes - api endpoints that call methods or functions
python
class Beneficiary():
    pass
class PushService():
    @classmethod
    def notify(beneficiary,message):
        pass

class Notifier:
    def __init__(self):
        self.transaction = Transaction()
        self.sender = sender(transaction)
        self.beneficiary = Beneficiary()
    PushService.notify(
        self.beneficiary,
        f"You received {self.transaction.amount()} from {self.sender.name}"
    )

The code above notifies a beneficiary of a transaction; of the amount that was transferred and who sent it.

Writing Code

Resources