# shopnobanerjee/the-good-ads architecture

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

- Interactive diagram: https://gitdiagram.com/shopnobanerjee/the-good-ads
- Repository: https://github.com/shopnobanerjee/the-good-ads

## Overview

##### Project type and purpose
- This is a full-stack web application named “The GoodAds.”
- Frontend: a Next.js/React app styled with Tailwind CSS.
- Backend: a Python FastAPI service with SQLAlchemy models, Alembic migrations, and PostgreSQL.
- Deployed via Docker Compose.

##### High-Level Components
a. Frontend (Client)
- Next.js framework (pages/app router under `client/app`).
- UI components (header, navigation, buttons, etc.) under `client/components`.
- Tailwind CSS + PostCSS for styles.
b. Backend (Server)
- FastAPI entrypoint (`server/app/main.py`).
- API v1 endpoints (`/api/v1/endpoints/*.py`).
- CRUD layer (`server/app/crud`).
- Pydantic schemas (`server/app/schemas`).
- SQLAlchemy models (`server/app/models`).
- DB session & initialization (`server/app/db`).
- Alembic for migrations.
c. Database
- PostgreSQL container managed via Docker Compose.
d. Infrastructure
- Dockerfile & docker-compose.yml for multi-container orchestration.

##### Interactions & Data Flow
- Browser → (HTTPS) → Next.js server
- Next.js → (HTTP fetch) → FastAPI endpoints
- FastAPI → (SQLAlchemy) → PostgreSQL
- Alembic runs migrations on startup via Docker Compose

##### Key Architectural Patterns
- Layered architecture on the backend: routers → CRUD → models → DB.
- Component-based UI on the frontend.
- Infrastructure as code via Docker Compose.
- Separation of concerns between client and server.

## Diagram (Mermaid)

```mermaid
flowchart TD
    NextJS["Next.js Frontend"]:::frontend
    FastAPI["FastAPI Service"]:::backend
    Postgres["PostgreSQL Database"]:::database

    NextJS -->|"HTTP/HTTPS"| FastAPI
    FastAPI -->|"SQLAlchemy"| Postgres

    click NextJS "https://github.com/shopnobanerjee/the-good-ads/blob/main/client/app/page.jsx"
    click NextJS "https://github.com/shopnobanerjee/the-good-ads/blob/main/client/app/layout.jsx"
    click NextJS "https://github.com/shopnobanerjee/the-good-ads/blob/main/client/app/landing/page.jsx"
    click NextJS "https://github.com/shopnobanerjee/the-good-ads/blob/main/client/app/globals.css"
    click NextJS "https://github.com/shopnobanerjee/the-good-ads/blob/main/client/components/header.jsx"
    click NextJS "https://github.com/shopnobanerjee/the-good-ads/blob/main/client/components/mobileNav.jsx"
    click NextJS "https://github.com/shopnobanerjee/the-good-ads/blob/main/client/components/ui/button.jsx"
    click NextJS "https://github.com/shopnobanerjee/the-good-ads/blob/main/client/components/ui/scroll-area.jsx"
    click NextJS "https://github.com/shopnobanerjee/the-good-ads/blob/main/client/components/ui/select.jsx"
    click NextJS "https://github.com/shopnobanerjee/the-good-ads/blob/main/client/components/ui/sheet.jsx"
    click NextJS "https://github.com/shopnobanerjee/the-good-ads/blob/main/client/components/ui/tabs.jsx"
    click NextJS "https://github.com/shopnobanerjee/the-good-ads/blob/main/client/components/ui/tooltip.jsx"
    click NextJS "https://github.com/shopnobanerjee/the-good-ads/blob/main/client/tailwind.config.mjs"
    click NextJS "https://github.com/shopnobanerjee/the-good-ads/blob/main/client/postcss.config.mjs"
    click NextJS "https://github.com/shopnobanerjee/the-good-ads/blob/main/client/next.config.mjs"

    click FastAPI "https://github.com/shopnobanerjee/the-good-ads/blob/main/server/app/main.py"
    click FastAPI "https://github.com/shopnobanerjee/the-good-ads/blob/main/server/app/api/v1/endpoints/societies.py"
    click FastAPI "https://github.com/shopnobanerjee/the-good-ads/blob/main/server/app/crud/crud_society.py"
    click FastAPI "https://github.com/shopnobanerjee/the-good-ads/blob/main/server/app/schemas/society.py"
    click FastAPI "https://github.com/shopnobanerjee/the-good-ads/blob/main/server/app/models/society.py"
    click FastAPI "https://github.com/shopnobanerjee/the-good-ads/blob/main/server/app/db/session.py"
    click FastAPI "https://github.com/shopnobanerjee/the-good-ads/blob/main/server/app/db/init_db.py"
    click FastAPI "https://github.com/shopnobanerjee/the-good-ads/blob/main/server/app/db/base.py"
    click FastAPI "https://github.com/shopnobanerjee/the-good-ads/blob/main/server/app/db/base_class.py"
    click FastAPI "https://github.com/shopnobanerjee/the-good-ads/blob/main/server/alembic.ini"
    click FastAPI "https://github.com/shopnobanerjee/the-good-ads/blob/main/server/alembic/env.py"
    click FastAPI "https://github.com/shopnobanerjee/the-good-ads/blob/main/server/alembic/script.py.mako"
    click FastAPI "https://github.com/shopnobanerjee/the-good-ads/tree/main/server/Dockerfile"
    click FastAPI "https://github.com/shopnobanerjee/the-good-ads/blob/main/server/docker-compose.yml"

    classDef frontend fill:#cce5ff,stroke:#3399ff,color:#000;
    classDef backend fill:#d4edda,stroke:#2e7d32,color:#000;
    classDef database fill:#ffe5b4,stroke:#e65100,color:#000;
```
