Skip to content

Commit 4842d2f

Browse files
committed
Update README.md
1 parent fb77652 commit 4842d2f

File tree

1 file changed

+62
-232
lines changed

1 file changed

+62
-232
lines changed

README.md

+62-232
Original file line numberDiff line numberDiff line change
@@ -1,255 +1,90 @@
1-
# [CodeBuddies V3 Back-end]
2-
## Django proof-of-concept
3-
41
![Test](https://github.com/codebuddies/django-concept/workflows/Test/badge.svg)
52
[![codecov](https://codecov.io/gh/codebuddies/backend/branch/master/graph/badge.svg)](https://codecov.io/gh/codebuddies/backend)
63

7-
**Note:** This project is currently _in development_
8-
9-
**Note:** The production branch of this repo is called `main` [to support the black lives matters movement]
10-
11-
## Sponsors
12-
13-
Big thanks to the sponsors of this project!
14-
15-
<a href="https://opencollective.com/codebuddies/sponsor/0/website" target="_blank"><img src="https://opencollective.com/codebuddies/sponsor/0/avatar.svg"></a>
16-
<a href="https://opencollective.com/codebuddies/sponsor/1/website" target="_blank"><img src="https://opencollective.com/codebuddies/sponsor/1/avatar.svg"></a>
17-
<a href="https://opencollective.com/codebuddies/sponsor/2/website" target="_blank"><img src="https://opencollective.com/codebuddies/sponsor/2/avatar.svg"></a>
18-
<a href="https://opencollective.com/codebuddies/sponsor/3/website" target="_blank"><img src="https://opencollective.com/codebuddies/sponsor/3/avatar.svg"></a>
19-
20-
<a href="https://gitduck.com/codebuddies/join?t=60ktFkh1Rqnd_AS1kR8ZGyH" target="_blank">Join CodeBuddies on GitDuck</a>
21-
22-
## Features
23-
24-
- **Auto-reload** - modify the application code in your editor of choice. As you save changes, the application should reload automatically. There should be no need to restart containers to see code changes.
25-
<!-- TODO -->
26-
27-
## Reference
28-
29-
- [Background]
30-
- [The API spec all the proof-of-concept]
31-
- [Crowdsourced brainstorm of problems we want to solve]
32-
- Will interact as the API supporting the [Codebuddies V3 Front-end]
33-
34-
## Getting started
35-
36-
We recommend you run CodeBuddies locally using Docker. We assume you have Docker installed, but if not head on over to the Docker [Getting Started] guide and install Docker for your operating system.
37-
38-
These instructions have been used on the following operating systems.
39-
40-
- Linux
41-
- Mac OS
42-
- Windows 10 Pro - Please note that Windows 10 Home is not supported by Docker Desktop at this time.
43-
44-
1. Fork this repository. This creates a copy of the repository for you to work on. For more help see this GitHub guide: [Fork a repo].
45-
2. Clone your fork. This creates a copy on your local computer. For more help see this GitHub guide: [Cloning a repository].
46-
47-
```bash
48-
$ git clone https://github.com/codebuddies/backend codebuddies-backend
49-
```
50-
51-
3. Navigate into the project directory.
52-
53-
```bash
54-
$ cd codebuddies-backend
55-
```
56-
57-
4. Start the local development environment.
58-
59-
```bash
60-
$ docker-compose up -d
61-
```
62-
63-
**Note:** `-d` starts Docker in detatched mode. See [logs](#debugging-with-docker-logs)
64-
65-
### Local development environment details
66-
67-
This will run the following components:
68-
69-
- Nginx, a web server: http://localhost:8000 - view the application or make API calls
70-
- Mailhog, a dummy mailbox: http://localhost:8025
71-
- The Django web application
72-
- Adminer, a DB front-end: http://localhost:8001
73-
- A PostgreSQL database `postgres://babyyoda:mysecretpassword@localhost:5432/codebuddies`
74-
75-
You can access the database through the Adminer front-end or using a local PostgreSQL client
76-
77-
![screenshot of Adminer](https://i.imgur.com/Dtg5Yel.png =250x)
78-
79-
5. Create a superuser so that you can log into `http://localhost:8000/admin` by running the following in your terminal:
80-
81-
```bash
82-
$ docker-compose run --rm app python ./manage.py createsuperuser
83-
```
84-
85-
6. You can populate the database with some random test data for development purposes by running
86-
87-
```bash
88-
$ docker-compose run --rm app python ./manage.py init_data
89-
```
90-
91-
All user accounts created by this command have the password `codebuddies`.
4+
## Overview of CodeBuddies
5+
CodeBuddies is a remote-first community of independent code learners who enjoy sharing knowledge and helping each other learn faster via discussions and pairing. It is free and open-sourced, and supported by open source contributors and financial backers on our [Open Collective](https://opencollective.com/codebuddies).
6+
7+
We are building out a new platform (codebuddies version 3 - cbv3) to replace the old website at at [codebuddies.org](https://codebuddies.org).
8+
9+
The new version of the website will include features that will help users:
10+
share and recommend links to resources/tutorials
11+
find open source projects to work on
12+
form study groups
13+
collect learning paths and share them
14+
find 1-hour pair programming partners for any topic much more easily
9215

93-
See the `init_data --help` command for more information:
9416

95-
```bash
96-
$ docker-compose run --rm app python ./manage.py init_data --help
97-
98-
usage: manage.py init_data [-h] [--clear-db] [--num-users NUM-USERS]
99-
[--num-tags NUM-TAGS]
100-
[--num-resources NUM-RESOURCES] [--version]
101-
[-v {0,1,2,3}] [--settings SETTINGS]
102-
[--pythonpath PYTHONPATH] [--traceback]
103-
[--no-color] [--force-color]
104-
105-
Initialize the DB with some random fake data for testing and development
106-
107-
optional arguments:
108-
--clear-db Clear existing data from the DB before creating test
109-
data
110-
--num-users NUM-USERS
111-
Number of `User` objects to create (default 10)
112-
--num-tags NUM-TAGS Number of `Tag` objects to create (default 10)
113-
--num-resources NUM-RESOURCES
114-
Number of `Resource` objects to create (default 10)
115-
-v {0,1,2,3}, --verbosity {0,1,2,3}
116-
Verbosity level; 0=minimal output, 1=normal output,
117-
2=verbose output, 3=very verbose output
118-
```
119-
120-
[See PR 127]
121-
122-
---
123-
124-
To stop the application and remove all containers, run the following:
125-
126-
127-
```bash
128-
$ docker-compose down
129-
```
130-
131-
## Other Tasks
132-
133-
### Automated Tests
134-
135-
- We use [pytest](https://docs.pytest.org/en/latest/contents.html) with the [pytest-django](https://pytest-django.readthedocs.io/en/latest/) plugin for running tests.
136-
- Please add tests for your code when contributing.
137-
- Run the test suite using `docker-compose run --rm app pytest`
138-
- With test coverage report `docker-compose run --rm app pytest --cov-report=term --cov=.`
139-
140-
### Debugging with Docker Logs
141-
142-
View logs from all containers.
143-
144-
```bash
145-
$ docker-compose logs
146-
```
147-
148-
View logs from a single container (in this case the `app` container).
149-
150-
```bash
151-
$ docker-compose logs app
152-
```
153-
154-
You can use the same structure to view logs for the other containers; `nginx`, `db`, `mailhog`, `adminer`, `app`.
155-
156-
If you would like to tail the logs in the console then you remove the detach flag, `-d`, from the `docker-compose up` command that you use to start the application.
157-
158-
### Django Management
159-
160-
The following are examples of some common Django management commands that you may need to run.
161-
162-
- Make Migrations: `docker-compose run --rm app python ./manage.py makemigrations`
163-
- Merge Migrations: `docker-compose run --rm app python ./manage.py makemigrations --merge`
164-
- Run Migrations: `docker-compose run --rm app python ./manage.py migrate`
165-
- Make sure new packages are installed: `docker-compose up -d --build`
166-
167-
To see the full list of management commands use `help`.
168-
169-
```plain
170-
docker-compose run --rm app python ./manage.py help
171-
```
172-
173-
### Postman
174-
175-
<details>
176-
<summary>Importing Postman collection</summary>
177-
<br>
178-
Postman is a free interactive tool for verifying the APIs of your project. You can download it at postman.com/downloads.
179-
180-
Postman is an interactive tool for verifying the APIs of your project in an isolated environment--think of it as a a virtual playground where we can safely experiment and edit our API before we deploy it on our web app--just like virtual environments help us isolate our python dependencies.
181-
182-
We've created a shared Postman collection (a .json file) in the postman folder to help contributors more easily reproduce observed behaviour in our dev API.
17+
**Note:** This project is currently _in development_
18318

184-
To get it set up, please follow these steps:
19+
**Note:** The production branch of this repo is called `main` [to support the black lives matters movement]
18520

186-
1. Download Postman
21+
## Code of Conduct
22+
We expect contributors to follow our [code of conduct](https://codebuddies.org/slack).
18723

188-
Downloading Postman
189-
Please make sure it is at least v7.6.0, if installed, or you are downloading the latest stable version.
190-
Linux,
24+
## Role of the Backend
25+
The backend is a Django app that provides API endpoints that the frontend (a React app) consumes.
19126

192-
- Distro package manager:
193-
- use the search feature to find in your package manager
194-
- (RECOMMENDED) Flatpak
195-
- After setting up flatpak it through flatpak using flatpak install postman and enter "yes"/"y" for all the questions it will ask. Flatpak is designed to provide the most up-to-date versions of software for most distros, so if you have the option, use Flatpak to guarantee Linux OS compatibility and to keep Postman up-to-date.
27+
We have a technical decision log [here](https://github.com/codebuddies/backend/wiki/Decision-log), and we document technical discussions and learnings in the [discussions tab](https://github.com/codebuddies/backend/discussions).
19628

197-
2. Once you have Postman open, click on file -> import and import the .json file
198-
3. Click on the settings gear icon on the far top right (next to the eye icon) and click to add a new environment.
199-
4. Name your environment `dev` and create a variable called `api_url`. For both the "Initial Value" and "Current Value," fill in `http://localhost:8000` which is the URL of your Django dev environment when it is running.
200-
5. Now, as long you have the Django app (http://localhost:8000) running, you should be able to make requests like POST Create User and POST Authenticate.
201-
Click on this link to see what you should expect: https://imgur.com/hd9VB6k
29+
## Front End
30+
The front-end repo is built using React and is located at [github.com/codebuddies/frontend](https://github.com/codebuddies/frontend). Until a staging-api.codebuddies.org URL is live, contributors need to have this backend app running locally (localhost:8000) in order to develop on the front-end.
20231

203-
- `POST` Create User will create a new user in your `localhost:8000` running Django app,
204-
- making a request to `POST Authenticate` will authenticate whether or not that user exists.
32+
## Tech used
33+
The backend uses Django built on top of [Cookiecutter](https://cookiecutter.readthedocs.io/en/1.7.0/) and [Django Rest Framework](https://www.django-rest-framework.org/).
20534

206-
![screenshot of Postman environment variable setup](https://user-images.githubusercontent.com/4512699/88751261-14fa9280-d10c-11ea-80c4-2934c27254ad.png)
35+
We use Docker Compose to stand up local development environments, and GitHub Actions to deploy staging and production. We host on DigitalOcean and store everything in a managed PostgreSQL database.
20736

208-
5. Now, as long you have the Django app (http://localhost:8000) running, you should be able to make requests like `POST Create User` and `POST Authenticate` by clicking on the blue "Send" button in Postman.
37+
Some core dependencies we use:
38+
djangorestframework==3.10.2 # https://github.com/encode/django-rest-framework
39+
coreapi==2.3.3 # https://github.com/core-api/python-client
40+
drf-jwt==1.13.4 # https://github.com/Styria-Digital/django-rest-framework-jwt
20941

210-
</details>
42+
## Contributing & Development Environment Set-Up
21143

212-
## Removing Everything
44+
Please see [CONTRIBUTING.MD]
21345

214-
<details>
215-
<summary>To remove all containers</summary>
216-
<br>
217-
To remove all containers run the following:
46+
## Get Help
47+
Ways you can get help if you're stuck or have questions:
48+
-[ ] Create a new [discussion](https://github.com/codebuddies/backend/discussions) post with your question
49+
-[ ] Ask in the #codebuddies-meta channel on the CodeBuddies Slack (see: codebuddies.org/slack)
21850

219-
```bash
220-
$ docker-compose rm
221-
```
51+
## Other Ways to Contribute
52+
There are other ways to contribute to CodeBuddies besides making pull requests to the codebase!
22253

223-
This will leave a copy of the data volume (holding the PostgreSQL data) behind. To remove that you will need to identify and remove the data volume.
54+
You can:
55+
[x] participate in the community on Slack
56+
[x] share your feedback on GitHub issues or discussions
57+
[x] help review pull requests by checking out the branch and affirming that the expected changes are there
22458

225-
```bash
226-
$ docker volume ls
59+
## Sponsors
22760

228-
DRIVER VOLUME NAME
229-
local django-concept_db_data
230-
```
61+
Big thanks to the sponsors of this project!
23162

232-
Note the name of the data volume, in this case `django-concept_db_data` and delete it.
63+
<a href="https://opencollective.com/codebuddies/sponsor/0/website" target="_blank"><img src="https://opencollective.com/codebuddies/sponsor/0/avatar.svg"></a>
64+
<a href="https://opencollective.com/codebuddies/sponsor/1/website" target="_blank"><img src="https://opencollective.com/codebuddies/sponsor/1/avatar.svg"></a>
65+
<a href="https://opencollective.com/codebuddies/sponsor/2/website" target="_blank"><img src="https://opencollective.com/codebuddies/sponsor/2/avatar.svg"></a>
66+
<a href="https://opencollective.com/codebuddies/sponsor/3/website" target="_blank"><img src="https://opencollective.com/codebuddies/sponsor/3/avatar.svg"></a>
23367

234-
```bash
235-
$ docker volume rm django-concept_db_data
236-
```
68+
<a href="https://gitduck.com/codebuddies/join?t=60ktFkh1Rqnd_AS1kR8ZGyH" target="_blank">Join CodeBuddies on GitDuck</a>
23769

238-
**Note:** it is likely that cached copies of your container images will be retained by Docker on your local machine. This is done to speed things up if you require these images in future. To completely remove unused container images and networks, we recommend you follow Docker [pruning guide](https://docs.docker.com/config/pruning/).
70+
## Features
23971

240-
</details>
72+
- **Auto-reload** - modify the application code in your editor of choice. As you save changes, the application should reload automatically. There should be no need to restart containers to see code changes.
73+
<!-- TODO -->
24174

24275
## Proof-of-concept Goals
24376

244-
A resource datastore
77+
[MVP Progress tracker board](https://github.com/codebuddies/backend/projects/1)
78+
79+
1. A resource datastore
24580

24681
- [x] save resource
24782
- [x] delete resource
24883
- [x] update resource
24984
- [x] list resource
25085
- [x] search resources
25186

252-
Resource:
87+
2. Resource:
25388

25489
- [x] title
25590
- [x] description
@@ -258,33 +93,28 @@ Resource:
25893
- [x] url
25994
- [x] referrer
26095

261-
The start of a resource bookmarking/archiving service.
262-
263-
- [ ] Calendar/hangouts
264-
- How easy would it be to make a calendar widget that lets users block out times they're free for hangouts?
265-
266-
## Contributing
96+
3. Authentication
26797

268-
Please see [How to contribute here]
98+
## Reference Links
26999

270-
## Spec docs
271-
272-
- [CBV3 tech notes doc]
273-
- [The API spec all the proof-of-concept]
100+
- [Original Discussion]
101+
- [CBV3 tech notes doc] (note: we're moving technical discussion to the new [discussion tab](https://github.com/codebuddies/backend/discussions).
102+
- [API spec draft on Swaggerhub]
274103
- [Front-end decision log]
275104
- [Back-end decision log]
105+
- [Crowdsourced brainstorm of problems we want to solve]
276106

277107
<!-- TODO: # Findings -->
278108

279109
<!-- TODO: # Technologies Used -->
280110

281111
<!-- What codebuddies is building links: -->
282-
[Background]: https://github.com/codebuddies/codebuddies/issues/1136
112+
[Original Discussion]: https://github.com/codebuddies/codebuddies/issues/1136
283113
[CBV3 tech notes doc]: https://docs.google.com/document/d/1YuVO-v0n73ogoFIwpwJgI1Bkso8sP2mg5zqbX9FB3lU/edit
284114
[Crowdsourced brainstorm of problems we want to solve]: https://pad.riseup.net/p/BecKdThFsevRmmG_tqFa-keep
285115

286116
<!-- Contribution links -->
287-
[How to contribute here]: https://github.com/codebuddies/django-concept/wiki/Contribution-instructions
117+
[CONTRIBUTING.MD]: https://github.com/codebuddies/backend/blob/main/contributing.md
288118
[See PR 127]: https://github.com/codebuddies/backend/issues/127
289119

290120
<!-- Howto links -->
@@ -293,7 +123,7 @@ Please see [How to contribute here]
293123
[Getting Started]: https://www.docker.com/products/docker-desktop
294124

295125
<!-- Spec links -->
296-
[The API spec all the proof-of-concept]: https://app.swaggerhub.com/apis-docs/billglover/CodeBuddies/0.0.1
126+
[API spec draft on Swaggerhub]: https://app.swaggerhub.com/apis-docs/billglover/CodeBuddies/0.0.1
297127
[Front-end decision log]: https://github.com/codebuddies/frontend/wiki/Technical-decision-log
298128
[Back-end decision log]: https://github.com/codebuddies/backend/wiki/Decision-log
299129

0 commit comments

Comments
 (0)