Skip to content

Commit

Permalink
typical codebase structure workshops (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
frinzekt authored Dec 17, 2021
1 parent 6796d75 commit a629aa4
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 0 deletions.
Binary file added docs/2021-2022-summer/images/about-us-cfc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/2021-2022-summer/images/stonks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/2021-2022-summer/images/wais-codebase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 104 additions & 0 deletions docs/2021-2022-summer/typical-codebase-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Typical Codebase Structure
*Codebase Jigsaw: How it all fits together!*

???+ info
This presentation is only intended to be a brief overview of the typical codebase structure

If you want more information about anything mentioned feel free to reach out to CFC committee and project helpers!

## Overview and Importance

- Most codebase will follow almost the same pattern (if they change, it will only change with little quirks)
- Structure helps every software engineer understand codebase and where to put it certain codes
(better code readability = better collaboration = better profit!)

???+ info "Profit"
![stonks](./images/stonks.png)

## Frontend
Example: [About Us - Coders for Causes Website](https://codersforcauses.org/about)

![website](./images/about-us-cfc.png)

### Different Folders and Purpose

#### Components
Components are individual parts/pieces of user interfaces

![components](./images/codebase-jigsaw-components.png)

#### Pages
Pages are the direct components that are related specific to a route or URL

![pages](./images/codebase-jigsaw-pages.png)

#### Public / Assets
Assets are usually elements that are referenced E.g. Images, Videos

![assets](./images/codebase-jigsaw-assets.png)

#### Utilities / Helpers
Pieces of code that are used as utilities or helpers to other codes

![helpers](./images/codebase-jigsaw-helpers.png)

#### Tests
- Scripts that tests that code works
- Usually E2E frontend

![tests](./images/codebase-jigsaw-tests.png)

### Comparison with Two Codebases
Slight difference, look at software documentation or ask other engineers

![codebases](./images/wais-codebase.png)


## Backend

???+ note "Context - Role and Subject"
In these example, when I mean "role", I mean the general role of file. "subject" means the feature or group functionality

### Method of Organisation

#### Subject-Oriented Driven Structure
As it can be seen here, both **different folders** will have the **same filenames based on its role**. App grows, those files can itself become folders as well.

Example: [erdem/DRF-TDD-example: An example Django REST framework project for test driven development. (github.com)](https://github.com/erdem/DRF-TDD-example)


![subject-oriented-file-structure](./images/subject-oriented-file-structure.png)

#### Role-Oriented Driven Structure
As it can be seen here, both **both different folders** will have the same **filenames based on its subject**

Example: [our-lab-training/olt-backend: Our Lab Training - Feathers Backend (github.com)](https://github.com/our-lab-training/olt-backend)

![role-oriented-file-structure](./images/role-oriented-file-structure.png)


### Different Folders and Purpose

#### Models / Database Connection
Object-Relational Model (ORM). Links the database into your app into objects

![orm](./images/codebase-jigsaw-orm.png)

#### Routing
Determines the rules for the URL pattern

![routing](./images/codebase-jigsaw-routing.png)

#### Views
- In REST API, Views are your main “view” of the API

![views](./images/codebase-jigsaw-views.png)

#### Tests
- Contains unit testing (+ possibly e2e testing)
- Most common candidate for transitioning from file to a folder containing more files

## Other Resources
- [Writing your first Django app, part 1 | Django documentation | Django (djangoproject.com)](https://docs.djangoproject.com/en/3.2/intro/tutorial01/)
- [File Structure – React (reactjs.org)](https://reactjs.org/docs/faq-structure.html)
- [Best practice for Django project working directory structure - Stack Overflow](https://stackoverflow.com/questions/22841764/best-practice-for-django-project-working-directory-structure)
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,6 @@ nav:
- Introduction to Backend Development with Django: 2021-2022-summer/introduction-to-backend-development-with-django.md
- MVC-MVMM Architecture and Communications: 2021-2022-summer/mvc-mvmm-architecture-and-communications.md
- Package Managers: 2021-2022-summer/package-managers.md
- Typical Codebase Structure: 2021-2022-summer/typical-codebase-structure.md
- 2021 Winter:
- Overview: 2021-winter/index.md

0 comments on commit a629aa4

Please sign in to comment.