Skip to content

Latest commit

Β 

History

History
78 lines (64 loc) Β· 2.2 KB

File metadata and controls

78 lines (64 loc) Β· 2.2 KB

πŸ”Ή β€œCity Events API” (PostgreSQL, FastAPI)

Goal: Build a public API that provides event data for different cities. Focus on querying, filtering, and handling real-world structured data.

πŸ“¦ Stack

  • FastAPI
  • PostgreSQL
  • SQLAlchemy + Alembic (for DB models and migrations)

πŸ“Š Dataset

  • Use or clean up an open dataset like:
  • Events in the UK
  • Or generate 300–500 rows using Faker or Mockaroo

πŸ“ Data Fields

  • Event title
  • Description
  • Date & Time
  • Location (city, venue)
  • Category (music, art, tech, etc.)
  • Ticket price

πŸ”§ API Endpoints

  • GET /events/getall – list all events
  • GET /events/{id} – get a single event
  • GET /events/search?city=London&category=tech – filter events
  • POST /events – add new event
  • PUT /events/{id} – update event
  • DELETE /events/{id} – delete event

🧠 Learnings

  • Clean schema design
  • Filtering with query parameters
  • Data sorting and pagination
  • Relationships (e.g., one city has many events)

Β 

FOLDER STRUCTURE

city_events_api/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ main.py               # FastAPI app instance
β”‚   β”œβ”€β”€ config.py             # DB and app settings
|   β”œβ”€β”€ logs/
β”‚   β”‚   └── app.log           # app log file
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── event.py          # SQLAlchemy Event model
β”‚   β”œβ”€β”€ schemas/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── event.py          # Pydantic schemas
β”‚   β”œβ”€β”€ crud/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── event.py          # DB logic (CRUD operations)
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── routes_event.py   # API route definitions
β”‚   β”œβ”€β”€ db/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ session.py        # DB connection
β”‚   β”‚   └── base.py           # Base class for models
β”‚   └── utils/
|       β”œβ”€β”€ logger.py         # app logger to log the events.
β”‚       └── populate.py       # Script to load fake or real data
β”œβ”€β”€ alembic/                  # DB migrations
β”‚   └── ...
β”œβ”€β”€ alembic.ini
β”œβ”€β”€ requirements.txt
└── README.md