Table of Contents
- Install Node.js and npm: Download here.
- Clone the repository:
git clone https://github.com/hack4impact-uiuc/code-your-dreams.git cd code-your-dreams - Create a
.envfile from the dev channel and place it in thecode-your-dreamsfolder.- Important: Do not share these credentials or commit them to GitHub. Make sure .env is listed in the .gitignore file
- Open the project in VSCode:
- Open the
code-your-dreamsfolder in Visual Studio Code. - Ensure the terminal in VSCode is set to the root
code-your-dreamsfolder.
- Open the
- Install dependencies and start the development server:
npm install npm run dev
- Visit
http://localhost:3000in your browser to view the app.
- Switch to the main branch:
git checkout main git pull origin main
- Create a feature branch:
git checkout -b <your-initials>/<branch-name>
Replace
<project_name>with your intials (ex: ej) and<your-branch-name>with a name for your work, e.g.,ej/navbar. - Commit changes:
git add . git commit -m "Description of changes"
- Push your branch:
git push
- Open a Pull Request (PR):
- Go to the Pull Request page and create a new PR to merge changes from your feature branch (
<your-initials>/<branch-name>) into the main branch for your project (main). - Provide a detailed description and request a review from Evan.
- Once you PR is approved, you can merge it into the main branch!
- Go to the Pull Request page and create a new PR to merge changes from your feature branch (
Learn more about file and folder conventions here: https://nextjs.org/docs/app/getting-started/project-structure.
-
File and Folder Conventions
-
Pages: Create front-end pages in
app/<path|slug>/<page>.tsx. -
Navigation: Use
<Link>instead of the<a>tag for client-side navigation. Example:<Link href="/users">Users</Link>
-
-
Components
- Shared Components: General React components used across the entire site should be placed under the
components/folder. - Page-Specific Components: Components exclusive to a specific page should be stored within the corresponding project folder, e.g.,
classroom/components/*.tsx. - Naming Convention: The component file name must match the function name inside the file. Use PascalCase (e.g.,
CreateAssignmentForm.tsx).
- Shared Components: General React components used across the entire site should be placed under the
-
Routes
- Route Files: Create API routes in
app/api/<route_name>/route.tsx. Theroute_namecorresponds to the entity or object you're performing CRUD operations on (e.g.,users). - HTTP Requests: The
route.tsxfiles should contain the HTTP request logic (e.g.,GET,POST,PUT,DELETE). They should not include data storage or retrieval logic. - Server-Side Data Fetching: Use
fetch()for server-side data fetching within these route files.
- Route Files: Create API routes in
-
Database Functions
- Query Files: Write all database queries related to an entity or object in
lib/query/<object_name>.ts. For example,lib/query/users.tswill contain functions for CRUD operations on theuserstable. - Calling Queries: These query functions should be called within the corresponding API routes, e.g.,
app/api/users/route.tsx.
- Query Files: Write all database queries related to an entity or object in
-
Types
- Type Definitions: Define TypeScript types that correspond to the entities in your database tables in the
types/folder. The file name should match the route name or object name, e.g.,types/users.tsfor user-related types.
- Type Definitions: Define TypeScript types that correspond to the entities in your database tables in the
- Use
npm runto view available commands. - Install Prettier for consitent formatting
- Always pull the latest main branch before starting a new feature branch.
- Ensure you're on a feature branch before making any changes.
- Never commit directly to the main branch.
- Keep PRs small and focused on one feature. Note: The link uses CLs which are synonymous with PRs
- Commit frequently to avoid bundling unrelated changes or cluttering commit messages.