# codeyourfuture/tech-products-demo architecture

> Architecture diagram of the GitHub repository codeyourfuture/tech-products-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codeyourfuture/tech-products-demo
- Repository: https://github.com/codeyourfuture/tech-products-demo

## Overview

##### Main Components

a. Client-Side (Frontend):
- Components Layer (Button, Form, Header, etc.)
- Pages Layer (Home, About, Account, etc.)
- Services Layer (resourceService, topicService)
- State Management (authContext)
- Styles (SCSS modules)

b. Server-Side (Backend):
- API Routes Layer
- Controllers Layer (auth, resources, topics, users)
- Services Layer
- Repositories Layer
- Middleware
- Utils (config, logger)

c. Database:
- Resources
- Users
- Topics
- Auth-related tables

d. External Services:
- "GitStub" (mock GitHub OAuth/API) container
- Authentication flow connections

##### Component Relationships

- Frontend → Backend (HTTP/API calls)
- Backend → Database (queries/operations)
- Frontend ↔ GitStub (OAuth flow)
- Backend ↔ GitStub (API interactions)

##### Technical Stack Details

- Frontend: React, Vite, SCSS
- Backend: Express.js, Node.js
- Database: PostgreSQL
- Testing: Jest, Cypress
- DevOps: Docker, GitHub Actions

##### Architecture Patterns to Highlight

- MVC pattern in the backend:
- Controllers (resourcesController, etc.)
- Services (businessLogic)
- Repositories (data access)

- Component-based architecture in frontend:
- Shared components
- Page components
- Custom hooks
- Services

##### Infrastructure Components

Containers for:
- Docker environment
- Development tools (migrations, scripts)
- CI/CD pipeline (GitHub Actions)

##### Additional Details

Annotations for:
- Port mappings (4201, 4202, 4211, 4212)
- Development/Production modes
- API documentation endpoint
- Migration flows

For this specific project, emphasize the separation between the client and server applications, the database schema evolution through migrations, and the authentication flow with the mock GitHub service (GitStub).

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend["Frontend Application"]
        direction TB
        FE["React App"]:::frontend
        click FE "https://github.com/CodeYourFuture/tech-products-demo/tree/main/client/src"
        
        subgraph FComponents["Components Layer"]
            direction TB
            FCOMP["UI Components"]:::frontend
            click FCOMP "https://github.com/CodeYourFuture/tech-products-demo/tree/main/client/src/components"
        end
        
        subgraph FPages["Pages Layer"]
            direction TB
            FPAGES["Route Pages"]:::frontend
            click FPAGES "https://github.com/CodeYourFuture/tech-products-demo/tree/main/client/src/pages"
        end
        
        subgraph FServices["Services Layer"]
            direction TB
            FSERV["API Services"]:::frontend
            click FSERV "https://github.com/CodeYourFuture/tech-products-demo/tree/main/client/src/services"
        end
        
        FSTATE["Auth Context"]:::frontend
        click FSTATE "https://github.com/CodeYourFuture/tech-products-demo/blob/main/client/src/authContext.jsx"
        
        FSTYLES["SCSS Modules"]:::frontend
        click FSTYLES "https://github.com/CodeYourFuture/tech-products-demo/tree/main/client/src/styles"
    end
    
    subgraph Backend["Backend Application"]
        direction TB
        BE["Express Server"]:::backend
        click BE "https://github.com/CodeYourFuture/tech-products-demo/tree/main/server"
        
        subgraph BRoutes["API Routes"]
            direction TB
            BAPI["API Endpoints"]:::backend
            click BAPI "https://github.com/CodeYourFuture/tech-products-demo/blob/main/server/api.js"
        end
        
        subgraph BControllers["Controllers"]
            direction TB
            AUTH["Auth Controller"]:::backend
            RESOURCES["Resources Controller"]:::backend
            TOPICS["Topics Controller"]:::backend
            USERS["Users Controller"]:::backend
            click AUTH "https://github.com/CodeYourFuture/tech-products-demo/blob/main/server/auth/authController.js"
            click RESOURCES "https://github.com/CodeYourFuture/tech-products-demo/blob/main/server/resources/resourcesController.js"
            click TOPICS "https://github.com/CodeYourFuture/tech-products-demo/blob/main/server/topics/topicsController.js"
            click USERS "https://github.com/CodeYourFuture/tech-products-demo/blob/main/server/users/usersController.js"
        end
        
        subgraph BUtils["Utils"]
            direction TB
            MIDDLEWARE["Middleware"]:::backend
            CONFIG["Configuration"]:::backend
            LOGGER["Logger"]:::backend
            click MIDDLEWARE "https://github.com/CodeYourFuture/tech-products-demo/blob/main/server/utils/middleware.js"
            click CONFIG "https://github.com/CodeYourFuture/tech-products-demo/blob/main/server/utils/config.js"
            click LOGGER "https://github.com/CodeYourFuture/tech-products-demo/blob/main/server/utils/logger.js"
        end
        
        DOCS["API Documentation"]:::backend
        click DOCS "https://github.com/CodeYourFuture/tech-products-demo/tree/main/server/docs"
    end
    
    subgraph Database["Database Layer"]
        direction TB
        DB[(PostgreSQL)]:::database
        MIGRATIONS["DB Migrations"]:::database
        click MIGRATIONS "https://github.com/CodeYourFuture/tech-products-demo/tree/main/migrations"
    end
    
    subgraph External["External Services"]
        direction TB
        GITSTUB["GitStub Mock"]:::external
        click GITSTUB "https://github.com/CodeYourFuture/tech-products-demo/tree/main/.devcontainer/gitstub"
    end
    
    subgraph DevOps["Infrastructure"]
        direction TB
        DOCKER["Docker Environment"]:::infra
        CICD["GitHub Actions"]:::infra
        E2E["E2E Tests"]:::infra
        click DOCKER "https://github.com/CodeYourFuture/tech-products-demo/blob/main/.devcontainer"
        click CICD "https://github.com/CodeYourFuture/tech-products-demo/tree/main/.github/workflows"
        click E2E "https://github.com/CodeYourFuture/tech-products-demo/tree/main/e2e"
    end
    
    %% Relationships
    FE --> BAPI
    BE --> DB
    FE <--> GITSTUB
    BE <--> GITSTUB
    MIGRATIONS --> DB
    
    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef infra fill:#95a5a6,stroke:#7f8c8d,color:white
```
